temporary changes for optimizations
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 9 Feb 2020 17:55:12 +0000 (17:55 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 9 Feb 2020 17:56:48 +0000 (17:56 +0000)
src/output/spv/spvxml-helpers.c
src/output/spv/spvxml-helpers.h
src/output/spv/xml-parser-generator

index fb1420351d18bff4cb14ec9bf9eb23f9533e93ec..d9d05e0d0a2de5957f68192994dac0b24c603b63 100644 (file)
@@ -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 ");
index 16f73350131d10f090f736fd31424e77c3afc98c..6ffdf2a65bb0c280d5c6f50448f94165fda06673 100644 (file)
@@ -79,6 +79,7 @@ struct spvxml_attribute
   {
     const char *name;
     bool required;
+    bool multi;
     char *value;
   };
 
index df34fbf8fffb41b8de9bbe1afa9c22a79d0ca505..ba6140de4218f509afe0f49080cf82bf23d83a3a 100644 (file)
@@ -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 };')