Ignore:
Timestamp:
Apr 4, 2007 10:15:27 AM (17 years ago)
Author:
bennylp
Message:

Ticket #208: Allow single quotes for attributes in XML (thanks Tory Patnoe)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c

    r974 r1145  
    340340 
    341341PJ_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 
     348PJ_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 
    347358    /* 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) { 
    349366        pj_scan_syntax_err(scanner); 
    350367        return; 
     
    356373    do { 
    357374        /* loop until end_quote is found. */ 
    358         while (*s && *s != '\n' && *s != end_quote) { 
     375        while (*s && *s != '\n' && *s != end_quote[qpair]) { 
    359376            ++s; 
    360377        } 
    361378 
    362379        /* check that no backslash character precedes the end_quote. */ 
    363         if (*s == end_quote) { 
     380        if (*s == end_quote[qpair]) { 
    364381            if (*(s-1) == '\\') { 
    365382                if (s-2 == scanner->begin) { 
     
    390407 
    391408    /* Check and eat the end quote. */ 
    392     if (*s != end_quote) { 
     409    if (*s != end_quote[qpair]) { 
    393410        pj_scan_syntax_err(scanner); 
    394411        return; 
     
    404421    } 
    405422} 
     423 
    406424 
    407425PJ_DEF(void) pj_scan_get_n( pj_scanner *scanner, 
Note: See TracChangeset for help on using the changeset viewer.