diff options
author | Alexander Barkov <alexander.barkov@oracle.com> | 2011-01-18 09:50:03 +0300 |
---|---|---|
committer | Alexander Barkov <alexander.barkov@oracle.com> | 2011-01-18 09:50:03 +0300 |
commit | 8a576b8360d440b27f926c1815f8d1c1e3a808a7 (patch) | |
tree | 4c1a9099a9669e9c5c3ccd7b2a331902d47c1240 /strings | |
parent | 3712d6c12ff8054c7b2d7c11334e70891978e62b (diff) | |
parent | cf0e22fe757c817d58ff2f403dd9718a51561fd0 (diff) | |
download | mariadb-git-8a576b8360d440b27f926c1815f8d1c1e3a808a7.tar.gz |
Merging from 5.1.
Diffstat (limited to 'strings')
-rw-r--r-- | strings/xml.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/strings/xml.c b/strings/xml.c index f3cfaad54fa..dee9da2864c 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -106,6 +106,13 @@ static void my_xml_norm_text(MY_XML_ATTR *a) } +static inline my_bool +my_xml_parser_prefix_cmp(MY_XML_PARSER *p, const char *s, size_t slen) +{ + return (p->cur + slen > p->end) || memcmp(p->cur, s, slen); +} + + static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) { int lex; @@ -123,16 +130,20 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) a->beg=p->cur; a->end=p->cur; - if ((p->end - p->cur > 3) && !memcmp(p->cur,"<!--",4)) + if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<!--"))) { - for (; (p->cur < p->end) && memcmp(p->cur, "-->", 3); p->cur++) - {} - if (!memcmp(p->cur, "-->", 3)) - p->cur+=3; + for (; p->cur < p->end; p->cur++) + { + if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("-->"))) + { + p->cur+= 3; + break; + } + } a->end=p->cur; lex=MY_XML_COMMENT; } - else if (!memcmp(p->cur, "<![CDATA[",9)) + else if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<![CDATA["))) { p->cur+= 9; for (; p->cur < p->end - 2 ; p->cur++) |