- xml: use <foo/> markup for empty tags.
authorjbj <devnull@localhost>
Mon, 14 Jun 2004 17:00:13 +0000 (17:00 +0000)
committerjbj <devnull@localhost>
Mon, 14 Jun 2004 17:00:13 +0000 (17:00 +0000)
CVS patchset: 7324
CVS date: 2004/06/14 17:00:13

CHANGES
lib/formats.c

diff --git a/CHANGES b/CHANGES
index 109bd15..043e566 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,7 @@
        - add 'requires' and 'conflicts' tag aliases.
        - python: return ds, not tuple, for ds iteration.
        - python: permit integer keys to ts.dbMatch().
+       - xml: use <foo/> markup for empty tags.
 
 4.3 -> 4.3.1:
        - fix: don't add leading space to %* argv expansion (#119059).
index 5084d89..dd87842 100644 (file)
@@ -350,12 +350,19 @@ static /*@only@*/ char * xmlFormat(int_32 type, const void * data,
     }
 /*@=branchstate@*/
 
-    nb = 2 * strlen(xtag) + sizeof("\t<></>") + xmlstrlen(s);
-    te = t = alloca(nb);
-    te = stpcpy( stpcpy( stpcpy(te, "\t<"), xtag), ">");
-    te = xmlstrcpy(te, s);
-    te += strlen(te);
-    te = stpcpy( stpcpy( stpcpy(te, "</"), xtag), ">");
+    nb = xmlstrlen(s);
+    if (nb == 0) {
+       nb += strlen(xtag) + sizeof("\t</>");
+       te = t = alloca(nb);
+       te = stpcpy( stpcpy( stpcpy(te, "\t<"), xtag), "/>");
+    } else {
+       nb += 2 * strlen(xtag) + sizeof("\t<></>");
+       te = t = alloca(nb);
+       te = stpcpy( stpcpy( stpcpy(te, "\t<"), xtag), ">");
+       te = xmlstrcpy(te, s);
+       te += strlen(te);
+       te = stpcpy( stpcpy( stpcpy(te, "</"), xtag), ">");
+    }
 
     /* XXX s was malloc'd */
 /*@-branchstate@*/