summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-11-19 17:33:02 -0500
committerEric S. Raymond <esr@thyrsus.com>2020-11-19 17:33:02 -0500
commit75da1e1d8a8dc0b89803495b951627e76e821822 (patch)
tree0a0af7bedc19a07aab996fa67ca59c02503c8a23
parentdf34448330392a583a878b6a9990c63dde5aa412 (diff)
downloadflex-git-75da1e1d8a8dc0b89803495b951627e76e821822.tar.gz
In the Go back end, elimate some forwards.
-rw-r--r--src/go-flex.skl68
1 files 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;