From 5aaebfb786bc3dcecee1f8f9ae4e016bd28f72c6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 9 Feb 2020 17:55:12 +0000 Subject: [PATCH] temporary changes for optimizations --- src/output/spv/spvxml-helpers.c | 16 ++++++++++++---- src/output/spv/spvxml-helpers.h | 1 + src/output/spv/xml-parser-generator | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/output/spv/spvxml-helpers.c b/src/output/spv/spvxml-helpers.c index fb1420351d..d9d05e0d0a 100644 --- a/src/output/spv/spvxml-helpers.c +++ b/src/output/spv/spvxml-helpers.c @@ -29,6 +29,7 @@ #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) @@ -332,11 +333,16 @@ find_attribute (struct spvxml_node_context *nctx, const char *name) 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; @@ -781,6 +787,8 @@ spvxml_content_error (struct spvxml_node_context *nctx, const xmlNode *node, 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 "); diff --git a/src/output/spv/spvxml-helpers.h b/src/output/spv/spvxml-helpers.h index 16f7335013..6ffdf2a65b 100644 --- a/src/output/spv/spvxml-helpers.h +++ b/src/output/spv/spvxml-helpers.h @@ -79,6 +79,7 @@ struct spvxml_attribute { const char *name; bool required; + bool multi; char *value; }; diff --git a/src/output/spv/xml-parser-generator b/src/output/spv/xml-parser-generator index df34fbf8ff..ba6140de42 100644 --- a/src/output/spv/xml-parser-generator +++ b/src/output/spv/xml-parser-generator @@ -440,8 +440,9 @@ def print_attribute_decls(name, attributes): 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 };') -- 2.30.2