Changeset 583 for pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
- Timestamp:
- Jul 3, 2006 10:08:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
r570 r583 18 18 */ 19 19 #include <pjlib-util/scanner.h> 20 #include <pj/ctype.h> 20 21 #include <pj/string.h> 21 22 #include <pj/except.h> … … 283 284 284 285 286 PJ_DEF(void) pj_scan_get_unescape( pj_scanner *scanner, 287 const pj_cis_t *spec, pj_str_t *out) 288 { 289 register char *s = scanner->curptr; 290 char *dst = s; 291 292 pj_assert(pj_cis_match(spec,0)==0); 293 294 /* Must not match character '%' */ 295 pj_assert(pj_cis_match(spec,'%')==0); 296 297 /* EOF is detected implicitly */ 298 if (!pj_cis_match(spec, *s) && *s != '%') { 299 pj_scan_syntax_err(scanner); 300 return; 301 } 302 303 out->ptr = s; 304 do { 305 if (*s == '%') { 306 if (s+3 <= scanner->end) { 307 /* This doesn't check if the hex digits are valid. 308 * If they dont' it will produce garbage characters, but 309 * no harm is done to the application (e.g. no illegal 310 * memory access. 311 */ 312 *dst = (pj_uint8_t) ((pj_hex_digit_to_val(*(s+1)) << 4) + 313 pj_hex_digit_to_val(*(s+2))); 314 ++dst; 315 s += 3; 316 } else { 317 *dst++ = *s++; 318 *dst++ = *s++; 319 break; 320 } 321 } 322 323 if (pj_cis_match(spec, *s)) { 324 char *start = s; 325 do { 326 ++s; 327 } while (pj_cis_match(spec, *s)); 328 329 if (dst != start) pj_memmove(dst, start, s-start); 330 dst += (s-start); 331 } 332 333 } while (*s == '%'); 334 335 scanner->curptr = s; 336 out->slen = (dst - out->ptr); 337 338 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 339 pj_scan_skip_whitespace(scanner); 340 } 341 } 342 343 285 344 PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner, 286 345 int begin_quote, int end_quote,
Note: See TracChangeset
for help on using the changeset viewer.