[xml] outputting empty attributes in test{HTML,SAX}.c

Date view Thread view Subject view Author view

From: Wayne Davison (wayned@blorf.net)
Date: Tue Aug 15 2000 - 23:27:10 EDT


The code in testHTML.c and testSAX.c doesn't handle the outputting of
empty attributes cleanly (it passes a NULL pointer to printf). The
following simple patch causes the ='value' section to be omitted when
the value is NULL.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: testHTML.c
@@ -372,8 +372,9 @@
     fprintf(stdout, "SAX.startElement(%s", (char *) name);
     if (atts != NULL) {
         for (i = 0;(atts[i] != NULL);i++) {
- fprintf(stdout, ", %s='", atts[i++]);
- fprintf(stdout, "%s'", atts[i]);
+ fprintf(stdout, ", %s", atts[i++]);
+ if (atts[i])
+ fprintf(stdout, "='%s'", atts[i]);
         }
     }
     fprintf(stdout, ")\n");
Index: testSAX.c
@@ -370,8 +370,9 @@
     fprintf(stdout, "SAX.startElement(%s", (char *) name);
     if (atts != NULL) {
         for (i = 0;(atts[i] != NULL);i++) {
- fprintf(stdout, ", %s='", atts[i++]);
- fprintf(stdout, "%s'", atts[i]);
+ fprintf(stdout, ", %s", atts[i++]);
+ if (atts[i])
+ fprintf(stdout, "='%s'", atts[i]);
         }
     }
     fprintf(stdout, ")\n");
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---

----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 20:43:14 EDT