Bison emits a bunch of code to pretty print token names for error
messages, doing things like removing quotes and backslashes.
But this is all totally pointless: all of the relevant strings are
already correctly formatted (in part because fix-yytname.awk does
some of this at compile time), and the process will not alter them.
They simply need to be copied as-is.
Fortunately, Bison provides a simple mechanism to replace this with
our own function, and wouldn't you know it we already have a suitable
copying function in the library, so let's use that.
size_t cdecl__advance(struct output_state *dst, size_t amount);
size_t cdecl__emit(struct output_state *dst, const char *src);
+size_t cdecl__strlcpy(char *dst, const char *src, size_t len);
const char *cdecl__emit_specs(struct output_state *dst,
struct cdecl_declspec *s,
return amount;
}
-static size_t cdecl__strlcpy(char *dst, const char *src, size_t dstlen)
+size_t cdecl__strlcpy(char *dst, const char *src, size_t dstlen)
{
if (dst)
snprintf(dst, dstlen, "%s", src);
ALLOC(ptr, sizeof (type)); \
*(ptr) = (type) { __VA_ARGS__ }; \
} while (0)
+
+/*
+ * With the postprocessing performed by fix-yytname.awk, all the symbol
+ * name strings can be used directly in error messages and there is no
+ * need for any string processing.
+ */
+#define yytnamerr(a, b) cdecl__strlcpy(a, b, (a) ? INT_MAX : 0)
%}
%code requires {