summaryrefslogtreecommitdiff
path: root/pjlib-util/src/pjlib-util/scanner.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-04 10:15:27 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-04 10:15:27 +0000
commitca871a3193a03d01323244e5499fbda41ae17108 (patch)
tree6027887697a9fabc75c405dcaa57e7f3b1ff1b32 /pjlib-util/src/pjlib-util/scanner.c
parentaafa82d9e93387af71d2332d0a3d42222b17d0ec (diff)
Ticket #208: Allow single quotes for attributes in XML (thanks Tory Patnoe)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1145 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util/src/pjlib-util/scanner.c')
-rw-r--r--pjlib-util/src/pjlib-util/scanner.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/pjlib-util/src/pjlib-util/scanner.c b/pjlib-util/src/pjlib-util/scanner.c
index 77f189a7..c7a9cf9b 100644
--- a/pjlib-util/src/pjlib-util/scanner.c
+++ b/pjlib-util/src/pjlib-util/scanner.c
@@ -339,13 +339,30 @@ PJ_DEF(void) pj_scan_get_unescape( pj_scanner *scanner,
PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner,
- int begin_quote, int end_quote,
- pj_str_t *out)
+ int begin_quote, int end_quote,
+ pj_str_t *out)
+{
+ pj_scan_get_quotes(scanner, (char*)&begin_quote, (char*)&end_quote, 1, out);
+}
+
+PJ_DEF(void) pj_scan_get_quotes(pj_scanner *scanner,
+ const char *begin_quote, const char *end_quote,
+ int qsize, pj_str_t *out)
{
register char *s = scanner->curptr;
-
+ int qpair = -1;
+ int i;
+
+ pj_assert(qsize > 0);
+
/* Check and eat the begin_quote. */
- if (*s != begin_quote) {
+ for (i = 0; i < qsize; ++i) {
+ if (*s == begin_quote[i]) {
+ qpair = i;
+ break;
+ }
+ }
+ if (qpair == -1) {
pj_scan_syntax_err(scanner);
return;
}
@@ -355,12 +372,12 @@ PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner,
*/
do {
/* loop until end_quote is found. */
- while (*s && *s != '\n' && *s != end_quote) {
+ while (*s && *s != '\n' && *s != end_quote[qpair]) {
++s;
}
/* check that no backslash character precedes the end_quote. */
- if (*s == end_quote) {
+ if (*s == end_quote[qpair]) {
if (*(s-1) == '\\') {
if (s-2 == scanner->begin) {
break;
@@ -389,7 +406,7 @@ PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner,
} while (1);
/* Check and eat the end quote. */
- if (*s != end_quote) {
+ if (*s != end_quote[qpair]) {
pj_scan_syntax_err(scanner);
return;
}
@@ -404,6 +421,7 @@ PJ_DEF(void) pj_scan_get_quote( pj_scanner *scanner,
}
}
+
PJ_DEF(void) pj_scan_get_n( pj_scanner *scanner,
unsigned N, pj_str_t *out)
{