summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2020-11-26 07:25:25 -0500
committerEric S. Raymond <esr@thyrsus.com>2020-11-26 07:25:25 -0500
commitb528c7efdc06ec59ce354d9db63a475514884a10 (patch)
treec6d0589668d9a59ac5c7dabca5e2e7905a33d380
parent9f1c6960ceea2903153e2d5d7a41bfe9b6808072 (diff)
downloadflex-git-b528c7efdc06ec59ce354d9db63a475514884a10.tar.gz
Improve standards conformance in C99 and Go skeletons.
-rw-r--r--src/c99-flex.skl19
-rw-r--r--src/go-flex.skl19
2 files changed, 24 insertions, 14 deletions
diff --git a/src/c99-flex.skl b/src/c99-flex.skl
index ddf4185..cb7af3c 100644
--- a/src/c99-flex.skl
+++ b/src/c99-flex.skl
@@ -406,12 +406,17 @@ M4_YY_SC_DEFS
typedef struct yy_buffer_state *yybuffer;
-%# These are not part of the exported interface and can safewly be renamed
-const int EOB_ACT_CONTINUE_SCAN = 0;
-const int EOB_ACT_END_OF_FILE = 1;
-const int EOB_ACT_LAST_MATCH = 2;
-const int YY_BUFFER_NEW = 0;
-const int YY_BUFFER_NORMAL = 1;
+%# These are not part of the exported interface and can safely be renamed
+/* These must be #defines, not const variables, because they're used as case
+ * arm values. GCC will allow case arm expressions to include references to
+ * const variables, but this is not standard-conformant and other compilers
+ * may not.
+ */
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
@@ -422,7 +427,7 @@ const int YY_BUFFER_NORMAL = 1;
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
-const int YY_BUFFER_EOF_PENDING = 2;
+#define YY_BUFFER_EOF_PENDING 2
struct yy_buffer_state {
FILE *yy_input_file;
diff --git a/src/go-flex.skl b/src/go-flex.skl
index 41b14d3..50de080 100644
--- a/src/go-flex.skl
+++ b/src/go-flex.skl
@@ -325,12 +325,17 @@ M4_YY_SC_DEFS
typedef struct yy_buffer_state *yybuffer;
-%# These are not part of the exported interface and can safely be renamed
-const int EOB_ACT_CONTINUE_SCAN = 0;
-const int EOB_ACT_END_OF_FILE = 1;
-const int EOB_ACT_LAST_MATCH = 2;
-const int YY_BUFFER_NEW = 0;
-const int YY_BUFFER_NORMAL = 1;
+%# These are not part of the exported interface and can safely be renamed.
+/* These must be #defines, not const variables, because they're used as case
+ * arm values. GCC will allow case arm expressions to include references to
+ * const variables, but this is not standard-conformant and other compilers
+ * may not.
+ */
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
@@ -341,7 +346,7 @@ const int YY_BUFFER_NORMAL = 1;
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
-const int YY_BUFFER_EOF_PENDING = 2;
+#define YY_BUFFER_EOF_PENDING 2
struct yy_buffer_state {
FILE *yyInputFile;