- Timestamp:
- Apr 4, 2007 10:15:27 AM (18 years ago)
- Location:
- pjproject/trunk/pjlib-util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/scanner.h
r754 r1145 351 351 352 352 /** 353 * Get characters between quotes. If current input doesn't match begin_quote, 354 * syntax error will be thrown. Note that the resulting string will contain 355 * the enclosing quote. 356 * 357 * @param scanner The scanner. 358 * @param begin_quotes The character array to begin the quotes. For example, 359 * the two characters " and '. 360 * @param end_quotes The character array to end the quotes. The position 361 * found in the begin_quotes array will be used to match 362 * the end quotes. So if the begin_quotes was the array 363 * of "'< the end_quotes should be "'>. If begin_array 364 * matched the ' then the end_quotes will look for ' to 365 * match at the end. 366 * @param qsize The size of the begin_quotes and end_quotes arrays. 367 * @param out String to store the result. 368 */ 369 PJ_DECL(void) pj_scan_get_quotes(pj_scanner *scanner, 370 const char *begin_quotes, 371 const char *end_quotes, int qsize, 372 pj_str_t *out); 373 374 375 /** 353 376 * Get N characters from the scanner. 354 377 * -
pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
r974 r1145 340 340 341 341 PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner, 342 int begin_quote, int end_quote, 343 pj_str_t *out) 344 { 345 register char *s = scanner->curptr; 346 342 int begin_quote, int end_quote, 343 pj_str_t *out) 344 { 345 pj_scan_get_quotes(scanner, (char*)&begin_quote, (char*)&end_quote, 1, out); 346 } 347 348 PJ_DEF(void) pj_scan_get_quotes(pj_scanner *scanner, 349 const char *begin_quote, const char *end_quote, 350 int qsize, pj_str_t *out) 351 { 352 register char *s = scanner->curptr; 353 int qpair = -1; 354 int i; 355 356 pj_assert(qsize > 0); 357 347 358 /* Check and eat the begin_quote. */ 348 if (*s != begin_quote) { 359 for (i = 0; i < qsize; ++i) { 360 if (*s == begin_quote[i]) { 361 qpair = i; 362 break; 363 } 364 } 365 if (qpair == -1) { 349 366 pj_scan_syntax_err(scanner); 350 367 return; … … 356 373 do { 357 374 /* loop until end_quote is found. */ 358 while (*s && *s != '\n' && *s != end_quote ) {375 while (*s && *s != '\n' && *s != end_quote[qpair]) { 359 376 ++s; 360 377 } 361 378 362 379 /* check that no backslash character precedes the end_quote. */ 363 if (*s == end_quote ) {380 if (*s == end_quote[qpair]) { 364 381 if (*(s-1) == '\\') { 365 382 if (s-2 == scanner->begin) { … … 390 407 391 408 /* Check and eat the end quote. */ 392 if (*s != end_quote ) {409 if (*s != end_quote[qpair]) { 393 410 pj_scan_syntax_err(scanner); 394 411 return; … … 404 421 } 405 422 } 423 406 424 407 425 PJ_DEF(void) pj_scan_get_n( pj_scanner *scanner, -
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r974 r1145 109 109 if (*scanner->curptr == '=') { 110 110 pj_scan_get_char( scanner ); 111 pj_scan_get_quote(scanner, '"', '"', &attr->value);111 pj_scan_get_quotes(scanner, "\"'", "\"'", 2, &attr->value); 112 112 /* remove quote characters */ 113 113 ++attr->value.ptr;
Note: See TracChangeset
for help on using the changeset viewer.