Add a script as a front-end for Flex, to work around various problems,
authorGuy Harris <guy@alum.mit.edu>
Sat, 4 Aug 2007 02:13:52 +0000 (02:13 -0000)
committerGuy Harris <guy@alum.mit.edu>
Sat, 4 Aug 2007 02:13:52 +0000 (02:13 -0000)
such as the fact that Flex strips all but the last component of the "-o"
argument, and that it doesn't generate a header file to declare routines
the generated lexical analyzer defines.  Use that script when building
lexical analyzers, and, for each lexical analyzer, include the generated
header file in the generated analyzer.

svn path=/trunk/; revision=22446

23 files changed:
Makefile.am.inc
Makefile.nmake.inc
epan/Makefile.am
epan/Makefile.common
epan/Makefile.nmake
epan/dfilter/Makefile.am
epan/dfilter/Makefile.nmake
epan/dfilter/scanner.l
epan/diam_dict.l
epan/dtd_parse.l
epan/dtd_preparse.l
epan/radius_dict.l
epan/uat_load.l
plugins/mate/Makefile.am
plugins/mate/Makefile.common
plugins/mate/Makefile.nmake
plugins/mate/mate_parser.l
tools/Makefile.am
wiretap/Makefile.am
wiretap/Makefile.common
wiretap/Makefile.nmake
wiretap/ascend-scanner.l
wiretap/k12text.l

index 00fd7d23f19152f62123a304ab82370c062942cf..3c77dba0d8859ee20e92c71eb8423e034f6ba0f5 100644 (file)
@@ -22,8 +22,4 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 .l.c:
-       @if [ ! -x "$(LEX)" ]; then \
-               echo "Neither lex nor flex was found"; \
-               exit 1; \
-       fi
-       $(LEX) -o$@ $<
+       $(RUNLEX) "$(LEX)" -o$@ $<
index 8dc5e2ef0a81b00177c0cd37b9aa4c218aa79db0..545e3c50269fff6bdf1252b954210eb5dfaf5248 100644 (file)
@@ -24,4 +24,4 @@
 .SUFFIXES: .l
 
 .l.c:
-       $(LEX) -o$@ $<
+       $(SH) $(RUNLEX) "$(LEX)" -o$@ $<
index 402a81e280e65f24c59502207b529ba1ead1bb65..1555c790f92e9eabea2198022ec14e666a1061e0 100644 (file)
@@ -127,10 +127,22 @@ tvbtest: tvbtest.o tvbuff.o except.o strutil.o emem.o
 exntest: exntest.o except.o
        $(LINK) $^ $(GLIB_LIBS)
 
-dtd_grammar.h: dtd_grammar.c
+RUNLEX=$(top_srcdir)/tools/runlex.sh
+
+diam_dict_lex.h: diam_dict.c
+
+dtd_parse_lex.h: dtd_parse.c
+
+dtd_preparse_lex.h: dtd_preparse.c
+
+radius_dict_lex.h: radius_dict.c
+
+uat_load_lex.h: uat_load.c
 
 LEMON=../tools/lemon
 
+dtd_grammar.h: dtd_grammar.c
+
 dtd_grammar.c: dtd_grammar.lemon $(LEMON)/lemon$(EXEEXT)
        $(LEMON)/lemon$(EXEEXT) t=$(srcdir)/$(LEMON)/lempar.c $(srcdir)/dtd_grammar.lemon
        
index 3d7c12427d0a207555dbe113fab616ca302840f0..3d5bbde8942f0dc492a24828e7b622463edfcd42 100644 (file)
@@ -111,10 +111,15 @@ LIBWIRESHARK_DISTCLEAN_GENERATED_SRC = \
 #
 LIBWIRESHARK_NODISTCLEAN_GENERATED_SRC = \
        diam_dict.c             \
+       diam_dict_lex.h         \
        dtd_parse.c             \
+       dtd_parse_lex.h         \
        dtd_preparse.c          \
+       dtd_preparse_lex.h      \
        radius_dict.c           \
-       uat_load.c
+       radius_dict_lex.h       \
+       uat_load.c              \
+       uat_load_lex.h
 
 LIBWIRESHARK_GENERATED_SRC =   \
        $(LIBWIRESHARK_DISTCLEAN_GENERATED_SRC) \
index dae50a16c26dd8fdc261b58e24581ac3070181cd..fbd7c553d5db25fad18a907216ca53e64b04f8ac 100644 (file)
@@ -258,20 +258,26 @@ inet_pton.c: ..\inet_pton.c
 sminmpec.c: enterprise-numbers make-sminmpec.pl
        $(PERL) make-sminmpec.pl enterprise-numbers sminmpec.c
 
-dtd_grammar.h: dtd_grammar.c
-
-radius_dict.obj : radius_dict.c
-
+RUNLEX=..\tools\runlex.sh
+diam_dict_lex.h: diam_dict.c
 diam_dict.obj : diam_dict.c
 
+dtd_parse_lex.h: dtd_parse.c
 dtd_parse.obj : dtd_parse.c
 
 dtd_preparse.obj : dtd_preparse.c
+dtd_preparse_lex.h: dtd_preparse.c
 
+radius_dict_lex.h: radius_dict.c
+radius_dict.obj : radius_dict.c
+
+uat_load_lex.h: uat_load.c
 uat_load.obj : uat_load.c
 
 LEMON=..\tools\lemon
 
+dtd_grammar.h: dtd_grammar.c
 dtd_grammar.c: dtd_grammar.lemon $(LEMON)\lemon.exe
        $(LEMON)\lemon t=$(LEMON)\lempar.c dtd_grammar.lemon
 
index ad45ac442460968e8bc756974e5535b7e6472e65..50589e2d6fbc3cd0c7ede33a03bc63d090b89216 100644 (file)
@@ -44,7 +44,8 @@ DISTCLEANFILES = \
 
 MAINTAINERCLEANFILES = \
        Makefile.in     \
-       scanner.c
+       scanner.c       \
+       scanner_lex.h
 
 INCLUDES = -I$(srcdir)/../.. -I$(srcdir)/.. -I$(srcdir)/$(LEMON)
 
@@ -86,7 +87,8 @@ libdfilter_la_CFLAGS = $(AM_NON_GENERATED_CFLAGS)
 libdfilter_generated_la_SOURCES = \
        grammar.c               \
        grammar.h               \
-       scanner.c
+       scanner.c               \
+       scanner_lex.h
 
 libdfilter_la_LIBADD = libdfilter_generated.la
 libdfilter_la_DEPENDENCIES = libdfilter_generated.la
@@ -96,7 +98,9 @@ EXTRA_DIST = \
        scanner.l               \
        Makefile.nmake          
 
-scanner.o : scanner.c grammar.h
+RUNLEX=$(top_srcdir)/tools/runlex.sh
+
+scanner_lex.h : scanner.c
 
 LEMON=../../tools/lemon
 
index 3ea7f83037f8b600480be48327fe7da9aaea758b..ed7c50689ab0edb4500ac755f2592f641b27270c 100644 (file)
@@ -58,10 +58,13 @@ clean:
 # the same for now.
 #
 distclean: clean
-       rm -f scanner.c grammar.c grammar.h grammar.out
+       rm -f scanner.c scanner_lex.h grammar.c grammar.h grammar.out
 
 maintainer-clean: distclean
 
+RUNLEX=..\..\tools\runlex.sh
+
+scanner_lex.h : scanner.c
 scanner.obj : scanner.c grammar.h
 
 grammar.h : grammar.c
index 9dec41e808effa05c90e0322899a9a844c0649dd..2c0d036e295a59cdd849523fe24502ac8c9ba92c 100644 (file)
@@ -54,6 +54,7 @@
 #include "syntax-tree.h"
 #include "grammar.h"
 #include "dfunctions.h"
+#include "scanner_lex.h"
 
 /*
  * GLib 1.2[.x] doesn't define G_MAXINT32 or G_MININT32; if they're not
index e360672fa91e9dacbf9e7f618a2d882c429c8429..754bfd6af05cb02925c9c25fa57bfa7800663557 100644 (file)
@@ -68,6 +68,7 @@
 #include <stdarg.h>
 #include "emem.h"
 #include "diam_dict.h"
+#include "diam_dict_lex.h"
 
 typedef struct entity_t {
        char* name;
index 99537f677308ca9959d2e21b78d7d40158e411c7..c29040ca6235056c8cd67372a254be1d1776cef0 100644 (file)
@@ -56,6 +56,7 @@
 #include "dtd.h"
 #include "dtd_grammar.h"
 #include "dtd_parse.h"
+#include "dtd_parse_lex.h"
        
        struct _proto_xmlpi_attr {
                gchar* name;
index 9e558551a1b1aef028a140da2ca4eb4eceb726eb..921b3fda315b78d8bb89b47d1ad5318ff98af89b 100644 (file)
@@ -64,6 +64,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include "dtd.h"
+#include "dtd_preparse_lex.h"
 
 #define ECHO g_string_append(current,yytext);
 
index fe68cf867c4c8741d5e70920731ad86246e2f6fa..dcdd5c18a6bb67822465667b2e3365f2e30460f5 100644 (file)
@@ -63,6 +63,7 @@
 #include <errno.h>
 #include <epan/packet.h>
 #include <epan/dissectors/packet-radius.h>
+#include "radius_dict_lex.h"
 #define ECHO
 #define MAX_INCLUDE_DEPTH 10
 
index e82220e70f17325cfea89825cf58bbbf0976f85b..e0b131a6f0ef4ceef1da44a3fccbe909dd64af6c 100644 (file)
@@ -63,6 +63,7 @@
 
 #include <epan/emem.h>
 #include "uat-int.h"
+#include "uat_load_lex.h"
        
        static uat_t* uat;
        static guint colnum;
index d4b3af143fe96e9fab8dfd77b4a87eaf6bdb3ee1..34f45d9347bc65f70b2972f275c8cda9fe445161 100644 (file)
@@ -122,6 +122,7 @@ DISTCLEANFILES = \
 MAINTAINERCLEANFILES = \
        Makefile.in             \
        mate_parser.c           \
+       mate_parser_lex.h       \
        plugin.c
 
 EXTRA_DIST = \
@@ -132,6 +133,10 @@ EXTRA_DIST = \
        moduleinfo.nmake        \
        plugin.rc.in
 
+RUNLEX = $(top_srcdir)/tools/runlex.sh
+
+mate_parser_lex.h : mate_parser.c
+
 LEMON = ../../tools/lemon
 
 mate_grammar.h : mate_grammar.c
index 8003e753f4fa602a06586533b786658d79da9bbf..73432c488f5ea75e91d0ff48a4bf7305470804f6 100644 (file)
@@ -34,6 +34,7 @@ DISSECTOR_SRC = \
 DISSECTOR_INCLUDES = \
        mate.h  \
        mate_grammar.h  \
+       mate_parser_lex.h       \
        mate_util.h
 
 # Dissector helpers.  They're included in the source files in this
index 99f9f93eae054b0ba209a98ebb22f4c2aeca31ec..9043776cb10d0adb7cc418dc23c7091a3fbb51be 100644 (file)
@@ -107,10 +107,14 @@ clean:
 # the same for now.
 #
 distclean: clean
-       rm -f mate_parser.c mate_grammar.c mate_grammar.h mate_grammar.out
+       rm -f mate_parser.c mate_parser_lex.h mate_grammar.c \
+       mate_grammar.h mate_grammar.out
 
 maintainer-clean: distclean
 
+RUNLEX = ..\..\tools\runlex.sh
+
+mate_parser_lex.h : mate_parser.c
 mate_parser.obj : mate_parser.c
 
 mate_grammar.h : mate_grammar.c
index 8d1089edee1458e23f1d095fd666524597702f17..7d99afcf1107c276af9d380a720a933ea37b148b 100644 (file)
@@ -49,6 +49,7 @@
        
 #include "mate.h"      
 #include "mate_grammar.h"
+#include "mate_parser_lex.h"
        
        void MateParser(void*,int, gchar*, mate_config* matecfg);
        void *MateParserAlloc(void *(*)(gulong));
index a8de4bb7e417f75414ef42bafa7e2039486a3ed6..4bb4a22458936dd6101878059d1526c42d2aa02e 100644 (file)
@@ -96,6 +96,7 @@ EXTRA_DIST = \
        msnchat                                         \
        netscreen2dump.py                               \
        pkt-from-core.py                                \
+       runlex.sh                                       \
        unix2dos.pl                                     \
        win32-setup.sh                                  \
        wireshark_be.py                                 \
index 982526e86b135f64f15b24d9cf8cba61d340684d..ecfc04692f41c424d0a208cea63deafef11199ae 100644 (file)
@@ -66,6 +66,7 @@ EXTRA_DIST = \
        config.h.win32          \
        Makefile.common         \
        Makefile.nmake          \
+       runlex.sh               \
        wtap.def                \
        file_util.c             \
        $(GENERATOR_SOURCES)    \
@@ -74,6 +75,12 @@ EXTRA_DIST = \
 libwiretap_la_LIBADD = libwiretap_generated.la
 libwiretap_la_DEPENDENCIES = libwiretap_generated.la
 
+RUNLEX = $(top_srcdir)/runlex.sh
+
+ascend-scanner_lex.h : ascend-scanner.c
+
+k12text_lex.h : k12text.c
+
 ascend-grammar.c : ascend-grammar.y
        @if [ -z "$(YACC)" ]; then \
                echo "Neither bison nor byacc has been found"; \
index 4e2fbd5b556d15462a90e462b47a6909aafd6eb7..1c67f09826afc80b1fa51cb50de115f7019b65fa 100644 (file)
@@ -123,7 +123,9 @@ GENERATED_C_FILES = \
 
 # The header files that they generate.
 GENERATED_HEADER_FILES = \
-       ascend-grammar.h
+       ascend-grammar.h        \
+       ascend-scanner_lex.h    \
+       k12text_lex.h
 
 # All the generated files.
 GENERATED_FILES = $(GENERATED_C_FILES) $(GENERATED_HEADER_FILES)
index 26170c68beb1ba6e8256ccdf5ed896fcbe8187a4..fdf2e627bdfb08332c077c7ddb0e85a474b19f9e 100644 (file)
@@ -40,13 +40,17 @@ wiretap-$(WTAP_VERSION).dll : $(OBJECTS) wtap.def ..\image\wiretap.res
 
 $(OBJECTS): config.h
 
-ascend-grammar.c ascend-grammar.h : ascend-grammar.y
-       $(YACC) $(YACC_OPTS) -d -p ascend ascend-grammar.y -o ascend-grammar.c
+RUNLEX = ..\runlex.sh
 
+ascend-scanner_lex.h : ascend-scanner.c
 ascend-scanner.obj : ascend-scanner.c ascend-grammar.h
 
+k12text_lex.h : k12text.c
 k12text.obj : k12text.c
 
+ascend-grammar.c ascend-grammar.h : ascend-grammar.y
+       $(YACC) $(YACC_OPTS) -d -p ascend ascend-grammar.y -o ascend-grammar.c
+
 config.h       : config.h.win32 ..\config.nmake
        sed -e s/@VERSION@/$(WTAP_VERSION)/ \
            -e "s/@HAVE_LIBZ@/$(ZLIB_CONFIG)/" \
index a586078c636d9720ed035bd6fc97e83341c37f42..0d63d63b94d7571050248f99962b1d25a3296c7c 100644 (file)
@@ -54,6 +54,7 @@
 #include "ascend-grammar.h"
 #include "ascend-int.h"
 #include "file_wrappers.h"
+#include "ascend-scanner_lex.h""
 
 FILE_T yy_fh;
 extern char *ascend_ra_ptr;
@@ -61,8 +62,6 @@ extern char *ascend_ra_last;
 #define YY_INPUT(buf,result,max_size) { int c = file_getc(yy_fh);  \
 result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); } 
 
-#define YY_NEVER_INTERACTIVE 1
-
 int at_eof;
 int mul, scratch;
 
index 6494c5fee9f59c6afb29b1785eb5f059a567635f..f69b2d71977bffa481c1f089bab408a9ab02456e 100644 (file)
@@ -62,6 +62,7 @@
 #include "file_wrappers.h"
 #include "buffer.h"
 #include "k12.h"
+#include "k12text_lex.h"
 
 static guint h;
 static guint m;