From 75da1e1d8a8dc0b89803495b951627e76e821822 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 19 Nov 2020 17:33:02 -0500 Subject: In the Go back end, elimate some forwards. --- src/go-flex.skl | 68 +++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/go-flex.skl b/src/go-flex.skl index 4964359..0790613 100644 --- a/src/go-flex.skl +++ b/src/go-flex.skl @@ -254,14 +254,37 @@ struct yy_buffer_state { int yyBufferStatus; }; -/* These forwards can simply deleted when poerting to a target language - * with two-pass name resoltion. - */ -void *yyalloc (size_t, yyscan_t yyscanner); -void *yyrealloc (void *, size_t, yyscan_t yyscanner); -void yyfree (void *, yyscan_t yyscanner); -/* Begin user sect3 */ +m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, +[[ +void *yyalloc(size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return malloc(size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, +[[ +void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + return realloc(ptr, size); +} +]]) + +m4_ifdef([[M4_YY_NO_FLEX_FREE]],, +[[ +void yyfree(void * ptr, yyscan_t yyscanner) { + (void)yyscanner; /* forestall unused-argument warning */ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + free((char *) ptr); +} +]]) m4_ifdef([[M4_MODE_NO_YYWRAP]], [[ int yywrap(yyscan_t yyscanner) { @@ -2279,37 +2302,6 @@ m4_ifdef([[M4_MODE_USES_REJECT]], return 0; } -m4_ifdef([[M4_YY_NO_FLEX_ALLOC]],, -[[ -void *yyalloc(size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return malloc(size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_REALLOC]],, -[[ -void *yyrealloc(void *ptr, size_t size, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - return realloc(ptr, size); -} -]]) - -m4_ifdef([[M4_YY_NO_FLEX_FREE]],, -[[ -void yyfree(void * ptr, yyscan_t yyscanner) { - (void)yyscanner; /* forestall unused-argument warning */ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - free((char *) ptr); -} -]]) - m4_ifdef([[M4_YY_MAIN]], [[ int main () { yyscan_t lexer; -- cgit v1.2.1