chiark / gitweb /
cleanup: use flex-generated declarations for scanner interface
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Jun 2011 11:07:48 +0000 (12:07 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jun 2011 15:38:42 +0000 (16:38 +0100)
We now pass the --header=... option to flex.  This causes it to
generate a header file describing the flex interface.  We #include
this almost everywhere we #include conffile_internal.h, and that makes
the declarations of yyin and yylex in conffile_internal.h redundant so
remove them.

Note that flex generates a conffile.yy.c which also contains many of
the same declarations as in conffile.yy.h.  So, unfortunately, we
should not #include conffile.yy.h in conffile.hh.c and therefore not
in conffile_internal.h either (if we want -Wredundant-decls, which we do).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
Makefile.in
conffile.c
conffile.y
conffile_internal.h

index 86e03e0ed03e2a69e3b77219abd5dfceffba44f9..999fbeeefae09768431632ead6354c0eac479a40 100644 (file)
@@ -1,7 +1,7 @@
 *.o
 *.d
 conffile.tab.[ch]
-conffile.yy.c
+conffile.yy.[ch]
 version.c
 /secnet
 
index fba120258e564c79438e393c1ed3021c9fad19b9..30ce8f6c53ec5faa6967a54f9881041d9fd22460 100644 (file)
@@ -85,7 +85,7 @@ DISTSUBDIRS:=debian/copyright debian/changelog debian/control \
 %.c:   %.y
 
 %.yy.c:        %.fl
-       flex -o$@ $<
+       flex --header=$*.yy.h -o$@ $<
 
 %.tab.c %.tab.h:       %.y
        bison -d -o $@ $<
@@ -129,6 +129,7 @@ $(DEPENDS): ${srcdir}/depend.sh
 
 # Manual dependencies section
 conffile.yy.c: conffile.fl conffile.tab.c
+conffile.yy.h: conffile.yy.c
 conffile.tab.c:        conffile.y
 # End of manual dependencies section
 
index 90235290fb03a72b436524892c28240fa2f82186..db7c58e31b447beb07d89dc1716ae2fd0ad38203 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>
 #include "conffile.h"
 #include "conffile_internal.h"
+#include "conffile.yy.h"
 #include "util.h"
 #include "ipaddr.h"
 
index 1a8ef364a215567579bbf5fb230d0bf75b5ce0fd..1625122fe762f4a83831eda9c9b3ad55bfd3201b 100644 (file)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include "secnet.h"
 #include "conffile_internal.h"
+#include "conffile.yy.h"
 #include "util.h"
 #define YYERROR_VERBOSE
 
index 69ff195e61df742089648fcb6ebec8b5896b7822..4e022b81211d58dae5799f3155334b648571e698 100644 (file)
@@ -4,8 +4,6 @@
 #include <stdio.h>
 #include "secnet.h"
 
-extern FILE *yyin;
-
 typedef cstring_t atom_t;
 
 /* Parse tree for configuration file */
@@ -37,7 +35,6 @@ struct p_node {
     struct p_node *r;
 };
 
-extern int yylex(void);
 extern cstring_t config_file;
 extern uint32_t config_lineno;
 extern int yynerrs;