]> granicus.if.org Git - libexpat/commitdiff
Comment change: explain why attribute count is twice what you expect
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 21 Feb 2017 17:24:39 +0000 (17:24 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 16:56:23 +0000 (18:56 +0200)
expat/tests/runtests.c

index a3befc85e278b8c1fff0a8a80eeec3ce30c84d27..0542f9ad3b81928a48e9448356c9176cd95fc881 100644 (file)
@@ -1970,7 +1970,12 @@ counting_start_element_handler(void *userData,
     }
     if (info->name == NULL)
         fail("Element not recognised");
-    /* Note attribute count is doubled */
+    /* The attribute count is twice what you might expect.  It is a
+     * count of items in atts, an array which contains alternating
+     * attribute names and attribute values.  For the naive user this
+     * is possibly a little unexpected, but it is what the
+     * documentation in expat.h tells us to expect.
+     */
     count = XML_GetSpecifiedAttributeCount(parser);
     if (info->attr_count * 2 != count) {
         fail("Not got expected attribute count");
@@ -2000,6 +2005,7 @@ counting_start_element_handler(void *userData,
             fail("Attribute has wrong value");
             return;
         }
+        /* Remember, two entries in atts per attribute (see above) */
         atts += 2;
     }
 }