summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2021-05-27 21:17:16 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2021-05-27 21:21:22 +0100
commit873ed6e236f7669afd3ef44259c34addc6dc95b6 (patch)
treedf4077d95a872ec93ad82ec577fdcfe5f17fa4a5 /src
parentd88075747d5d300254c97ad7c572ed483230c7f9 (diff)
downloadlibhubbub-master.tar.gz
libhubbub-master.tar.bz2
treebuilder: Fix debug build variant with new element_type_to_name().HEADmaster
This uses the gperf-generated wordlist.
Diffstat (limited to 'src')
-rw-r--r--src/treebuilder/element-type.c19
-rw-r--r--src/treebuilder/element-type.h8
-rw-r--r--src/treebuilder/treebuilder.c19
3 files changed, 27 insertions, 19 deletions
diff --git a/src/treebuilder/element-type.c b/src/treebuilder/element-type.c
index f6d3247..7e2772c 100644
--- a/src/treebuilder/element-type.c
+++ b/src/treebuilder/element-type.c
@@ -28,3 +28,22 @@ element_type element_type_from_name(
return value->type;
}
+
+/**
+ * Convert an element type to a name
+ *
+ * \param type The element type
+ * \return Pointer to name
+ */
+const char *element_type_to_name(element_type type)
+{
+ size_t i;
+
+ for (i = 0; i < sizeof(wordlist) / sizeof(wordlist[0]); i++) {
+ if (wordlist[i].type == type) {
+ return wordlist[i].name;
+ }
+ }
+
+ return "UNKNOWN";
+}
diff --git a/src/treebuilder/element-type.h b/src/treebuilder/element-type.h
index 93b168c..75612fd 100644
--- a/src/treebuilder/element-type.h
+++ b/src/treebuilder/element-type.h
@@ -53,5 +53,13 @@ element_type element_type_from_name(
hubbub_treebuilder *treebuilder,
const hubbub_string *tag_name);
+/**
+ * Convert an element type to a name
+ *
+ * \param type The element type
+ * \return Pointer to name
+ */
+const char *element_type_to_name(element_type type);
+
#endif
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index 2d2d047..f11875e 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -1397,24 +1397,5 @@ void formatting_list_dump(hubbub_treebuilder *treebuilder, FILE *fp)
}
}
-/**
- * Convert an element type to a name
- *
- * \param type The element type
- * \return Pointer to name
- */
-const char *element_type_to_name(element_type type)
-{
- size_t i;
-
- for (i = 0;
- i < sizeof(name_type_map) / sizeof(name_type_map[0]);
- i++) {
- if (name_type_map[i].type == type)
- return name_type_map[i].name;
- }
-
- return "UNKNOWN";
-}
#endif