]> granicus.if.org Git - flex/commitdiff
scanner: Skeleton no longer includes integer limit macros.
authorExplorer09 <explorer09@gmail.com>
Thu, 8 Mar 2018 01:59:35 +0000 (09:59 +0800)
committerWill Estes <westes575@gmail.com>
Thu, 8 Mar 2018 21:00:24 +0000 (16:00 -0500)
The [U]INT{8,16,32}_{MIN,MAX} macros are never used in skeleton code.
Having them in skeleton just increases the chance of conflicts in case
that user defines them in non-C99 environment (see issue #307, when
flex code is built in Visual C++ (before VS2013)).

flexint.h is now split in two files. Only "flexint_shared.h" will be
included in skeleton now, which defines flex integral types.
flexint.h contains integer limits macros that would be used in flex
only.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
src/Makefile.am
src/flex.skl
src/flexint.h
src/flexint_shared.h [new file with mode: 0644]

index 6e7189351fc52d57c25f13ccc58db64acb018f83..fb4c485f7412dedc6a5154fdb3a764947bc27c9c 100644 (file)
@@ -58,6 +58,7 @@ COMMON_SOURCES = \
        filter.c \
        flexdef.h \
        flexint.h \
+       flexint_shared.h \
        gen.c \
        main.c \
        misc.c \
@@ -95,7 +96,7 @@ CLEANFILES = stage1scan.c stage1flex$(EXEEXT)
 
 MAINTAINERCLEANFILES = skel.c
 
-skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c
+skel.c: flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c
        $(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp
        mv $@.tmp $@
 
index 67eea3c9d6a370758dc4dae1fbdce5c10d730f27..1043238cfceb4690b7a12070ba233e8f97d3a6d9 100644 (file)
@@ -248,10 +248,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], ,
 %endif
 /* end standard C headers. */
 
-%if-c-or-c++
-m4preproc_include(`flexint.h')
-%endif
-
 /* begin standard C++ headers. */
 %if-c++-only
 #include <iostream>
@@ -262,6 +258,10 @@ m4preproc_include(`flexint.h')
 /* end standard C++ headers. */
 %endif
 
+%if-c-or-c++
+m4preproc_include(`flexint_shared.h')
+%endif
+
 /* TODO: this is always defined, so inline it */
 #define yyconst const
 
index 4b9e691fffcd4e3eb48aee6c0fd4fad3c2d64f95..3576eaa644487c46176412afa4e37c7291a5228f 100644 (file)
@@ -3,10 +3,6 @@
 #ifndef FLEXINT_H
 #define FLEXINT_H
 
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
 /* C++ systems might need __STDC_LIMIT_MACROS defined before including
  * <stdint.h>, if you want the limit (max/min) macros for int types.
  */
 #define __STDC_LIMIT_MACROS 1
 #endif
 
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t; 
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
+/* "flexint_shared.h" will be included also in skeleton. It will include
+ * <inttypes.h> (if available) and define flex's integral types.
+ */
+#include "flexint_shared.h"
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -65,6 +51,4 @@ typedef unsigned int flex_uint32_t;
 #define SIZE_MAX               (~(size_t)0)
 #endif
 
-#endif /* ! C99 */
-
 #endif /* ! FLEXINT_H */
diff --git a/src/flexint_shared.h b/src/flexint_shared.h
new file mode 100644 (file)
index 0000000..569f073
--- /dev/null
@@ -0,0 +1,22 @@
+/* flex integer type definitions */
+
+/* Prefer C99 integer types if available. */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+/* Include <inttypes.h> and not <stdint.h> because Solaris 2.6 has the former
+ * and not the latter.
+ */
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */