diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-02-15 15:53:27 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-02-15 15:53:27 +0100 |
commit | a2cf90d9ce532dd03d58a16402faa8924f5492a6 (patch) | |
tree | c06ae026dc5049fcc8551fb32635a5d0a52fc57a /storage/connect/libdoc.cpp | |
parent | b2f11bf0c41916daa0bd2bf6eed6f9e61e4e95d5 (diff) | |
download | mariadb-git-a2cf90d9ce532dd03d58a16402faa8924f5492a6.tar.gz |
Suppress multiple blanks and control characters from the
node text retrieved by libxml2.
Modified:
libdoc.cpp
Diffstat (limited to 'storage/connect/libdoc.cpp')
-rw-r--r-- | storage/connect/libdoc.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 36e920540aa..5768dfa8177 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -461,7 +461,27 @@ char *XML2NODE::GetText(char *buf, int len) xmlFree(Content); if ((Content = xmlNodeGetContent(Nodep))) { - int rc = ((PXDOC2)Doc)->Decode(Content, buf, len); + char *p1, *p2; + bool b = false; + int rc = ((PXDOC2)Doc)->Decode(Content, buf, len); + + // Eliminate extra characters + for (p1 = p2 = buf; *p1; p1++) + if (strchr(" \t\r\n", *p1)) { + if (b) { + *p2++ = ' '; + b = false; + } // endif b + + } else { + *p2++ = *p1; + b = true; + } // endif p1 + + if (*(p2 - 1) == ' ') + *(p2 - 1) = 0; + else + *p2 = 0; if (trace) htrc("GetText buf='%s' len=%d rc=%d\n", buf, len, rc); |