summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 7114747..0a50497 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -692,7 +692,13 @@ namespace
{
while (!is_chartype(*s, ct_parse_pcdata)) ++s;
- if (opt_eol && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
+ if (*s == '<') // PCDATA ends here
+ {
+ *g.flush(s) = 0;
+
+ return s + 1;
+ }
+ else if (opt_eol && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair
{
*s++ = '\n'; // replace first one with 0x0a
@@ -702,12 +708,6 @@ namespace
{
s = strconv_escape(s, g);
}
- else if (*s == '<') // PCDATA ends here
- {
- *g.flush(s) = 0;
-
- return s + 1;
- }
else if (*s == 0)
{
return s;
@@ -741,22 +741,35 @@ namespace
gap g;
- // Trim whitespaces
- if (opt_wnorm)
+ // trim leading whitespaces
+ if (opt_wnorm && is_chartype(*s, ct_space))
{
char* str = s;
- while (is_chartype(*str, ct_space)) ++str;
+ do ++str;
+ while (is_chartype(*str, ct_space));
- if (str != s)
- g.push(s, str - s);
+ g.push(s, str - s);
}
while (true)
{
while (!is_chartype(*s, (opt_wnorm || opt_wconv) ? ct_parse_attr_ws : ct_parse_attr)) ++s;
- if (opt_wnorm && is_chartype(*s, ct_space))
+ if (*s == end_quote)
+ {
+ char* str = g.flush(s);
+
+ if (opt_wnorm)
+ {
+ do *str-- = 0;
+ while (is_chartype(*str, ct_space));
+ }
+ else *str = 0;
+
+ return s + 1;
+ }
+ else if (opt_wnorm && is_chartype(*s, ct_space))
{
*s++ = ' ';
@@ -788,19 +801,6 @@ namespace
if (*s == '\n') g.push(s, 1);
}
- else if (*s == end_quote)
- {
- char* str = g.flush(s);
-
- if (opt_wnorm)
- {
- do *str-- = 0;
- while (is_chartype(*str, ct_space));
- }
- else *str = 0;
-
- return s + 1;
- }
else if (opt_escape && *s == '&')
{
s = strconv_escape(s, g);