X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/3e6656f9ab66ae7e629f8e5d5b41810bf070f09d..fe22d5d20ff5a88a3a0dba28a11623b235a422ab:/src/struniq.c?ds=sidebyside diff --git a/src/struniq.c b/src/struniq.c index 4260a70f..a42f7862 100644 --- a/src/struniq.c +++ b/src/struniq.c @@ -20,6 +20,7 @@ #include "system.h" #include "quotearg.h" +#include "error.h" #include "hash.h" #include "struniq.h" @@ -36,23 +37,35 @@ static struct hash_table *struniqs_table = NULL; | Create the struniq for S if needed. | `-------------------------------------*/ -const struniq_t +struniq_t struniq_new (const char *s) { - /* Keep the struniqs in a printable form. */ - struniq_t res = hash_lookup (struniqs_table, - quotearg_style (escape_quoting_style, s)); - + struniq_t res = hash_lookup (struniqs_table, s); if (!res) { /* First insertion in the hash. */ - res = xstrdup (quotearg_style (escape_quoting_style, s)); + res = xstrdup (s); hash_insert (struniqs_table, res); } return res; } +/*------------------------------. +| Abort if S is not a struniq. | +`------------------------------*/ + +void +struniq_assert (const char *s) +{ + if (!hash_lookup (struniqs_table, s)) + { + error (0, 0, "not a struniq: %s", quotearg (s)); + abort (); + } +} + + /*--------------------. | Print the struniq. | `--------------------*/