#include "gl/c-ctype.h"
#include "gl/xvasprintf.h"
+#include "gl/xalloc.h"
char * WARN_UNUSED_RESULT
spvxml_context_finish (struct spvxml_context *ctx, struct spvxml_node *root)
for (struct spvxml_attribute *a = nctx->attrs;
a < &nctx->attrs[nctx->n_attrs]; a++)
{
+ if (!strcmp (a->name, name))
+ return a;
+
+ if (!a->multi)
+ continue;
+
size_t a_len = strlen (a->name);
- if (!strcmp (a->name, name)
- || (a->name[a_len - 1] == '#'
- && !strncmp (name, a->name, a_len - 1)
- && all_digits (name + a_len - 1))
+ if ((a->name[a_len - 1] == '#'
+ && !strncmp (name, a->name, a_len - 1)
+ && all_digits (name + a_len - 1))
|| (a->name[a_len - 1] == '%'
&& !strncmp (name, a->name, a_len - 1)))
return a;
if (nctx->up->error)
return;
+ nctx->up->error = xstrdup ("error");
+ return;
struct string s = DS_EMPTY_INITIALIZER;
ds_put_cstr (&s, "error parsing content of ");
print(' struct spvxml_attribute attrs[] = {')
for unique_name, (xml_name, value, required) in sorted(attributes.items()):
c_name = name_to_id(unique_name)
- print(' [ATTR_%s] = { "%s", %s, NULL },'
- % (c_name.upper(), xml_name, 'true' if required else 'false'))
+ print(' [ATTR_%s] = { "%s", %s, %s, NULL },'
+ % (c_name.upper(), xml_name, 'true' if required else 'false',
+ 'true' if '#' in xml_name or '%' in xml_name else 'false'))
print(' };')
print(' enum { N_ATTRS = sizeof attrs / sizeof *attrs };')