From d69a504a5a4f4a11cde04d63243ad30a75de33e4 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Tue, 21 Feb 2017 17:24:39 +0000 Subject: [PATCH] Comment change: explain why attribute count is twice what you expect --- expat/tests/runtests.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index a3befc85..0542f9ad 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -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; } } -- 2.40.0