Nikolay Sivov : msxml3: Fix a warning in DTD dumping code on recent libxml2 versions.

Alexandre Julliard julliard at winehq.org
Wed Aug 21 14:09:06 CDT 2013


Module: wine
Branch: master
Commit: 9554dfb13c9ecdad0c63f74d141f2ae48b2a9130
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9554dfb13c9ecdad0c63f74d141f2ae48b2a9130

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Aug 21 14:31:28 2013 +0400

msxml3: Fix a warning in DTD dumping code on recent libxml2 versions.

---

 dlls/msxml3/node.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c
index 79de75c..a196f4e 100644
--- a/dlls/msxml3/node.c
+++ b/dlls/msxml3/node.c
@@ -896,6 +896,50 @@ HRESULT node_get_xml(xmlnode *This, BOOL ensure_eol, BSTR *ret)
     return *ret ? S_OK : E_OUTOFMEMORY;
 }
 
+/* duplicates xmlBufferWriteQuotedString() logic */
+static void xml_write_quotedstring(xmlOutputBufferPtr buf, const xmlChar *string)
+{
+    const xmlChar *cur, *base;
+
+    if (xmlStrchr(string, '\"'))
+    {
+        if (xmlStrchr(string, '\''))
+        {
+	    xmlOutputBufferWrite(buf, 1, "\"");
+            base = cur = string;
+
+            while (*cur)
+            {
+                if (*cur == '"')
+                {
+                    if (base != cur)
+                        xmlOutputBufferWrite(buf, cur-base, (const char*)base);
+                    xmlOutputBufferWrite(buf, 6, """);
+                    cur++;
+                    base = cur;
+                }
+                else
+                    cur++;
+            }
+            if (base != cur)
+                xmlOutputBufferWrite(buf, cur-base, (const char*)base);
+	    xmlOutputBufferWrite(buf, 1, "\"");
+	}
+        else
+        {
+	    xmlOutputBufferWrite(buf, 1, "\'");
+            xmlOutputBufferWriteString(buf, (const char*)string);
+	    xmlOutputBufferWrite(buf, 1, "\'");
+        }
+    }
+    else
+    {
+        xmlOutputBufferWrite(buf, 1, "\"");
+        xmlOutputBufferWriteString(buf, (const char*)string);
+        xmlOutputBufferWrite(buf, 1, "\"");
+    }
+}
+
 static void htmldtd_dumpcontent(xmlOutputBufferPtr buf, xmlDocPtr doc)
 {
     xmlDtdPtr cur = doc->intSubset;
@@ -905,17 +949,17 @@ static void htmldtd_dumpcontent(xmlOutputBufferPtr buf, xmlDocPtr doc)
     if (cur->ExternalID)
     {
         xmlOutputBufferWriteString(buf, " PUBLIC ");
-        xmlBufferWriteQuotedString(buf->buffer, cur->ExternalID);
+        xml_write_quotedstring(buf, cur->ExternalID);
         if (cur->SystemID)
         {
             xmlOutputBufferWriteString(buf, " ");
-            xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
+            xml_write_quotedstring(buf, cur->SystemID);
 	}
     }
     else if (cur->SystemID)
     {
         xmlOutputBufferWriteString(buf, " SYSTEM ");
-        xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
+        xml_write_quotedstring(buf, cur->SystemID);
     }
     xmlOutputBufferWriteString(buf, ">\n");
 }




More information about the wine-cvs mailing list