Add comments to various %option items to explain what they're doing.

Move the %options to the beginning if they weren't already there, and
put them in the same order in all files.

Add "prefix=" options to .l files that don't already have them, so we
don't have to pass a "-P" option.

Add "never-interactive" and "noyywrap" options to our lexical analyzers,
to remove extra isatty() checks and to eliminate the need for yywrap()
from the Flex library.

Get rid of %option nostdinit - that's the default.

Add .l.c: rules to Makefile.am files, replacing the rules for specific
.l files.  Have those rules all check that $(LEX) is set.

Update the address for the FSF.


git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@22424 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
guy 2007-07-30 20:22:37 +00:00
parent c17ebb799f
commit 5c9beb6180
14 changed files with 209 additions and 61 deletions

View File

@ -125,20 +125,12 @@ tvbtest: tvbtest.o tvbuff.o except.o strutil.o emem.o
exntest: exntest.o except.o
$(LINK) $^ $(GLIB_LIBS)
radius_dict.c: radius_dict.l
$(LEX) $^
uat_load.c: uat_load.l
$(LEX) -ouat_load.c $(srcdir)/uat_load.l
diam_dict.c: diam_dict.l
$(LEX) -odiam_dict.c $(srcdir)/diam_dict.l
dtd_parse.c : dtd_parse.l
$(LEX) -odtd_parse.c $(srcdir)/dtd_parse.l
dtd_preparse.c : dtd_preparse.l
$(LEX) -odtd_preparse.c $(srcdir)/dtd_preparse.l
.l.c:
@if [ ! -x "$(LEX)" ]; then \
echo "Neither lex nor flex was found"; \
exit 1; \
fi
$(LEX) -o$@ $<
dtd_grammar.h: dtd_grammar.c

View File

@ -93,12 +93,12 @@ EXTRA_DIST = \
scanner.l \
Makefile.nmake
scanner.c : scanner.l
.l.c:
@if [ ! -x "$(LEX)" ]; then \
echo "Neither lex nor flex was found"; \
exit 1; \
fi
$(LEX) -Pdf_ -oscanner.c $(srcdir)/scanner.l
$(LEX) -o$@ $<
scanner.o : scanner.c grammar.h

View File

@ -1,3 +1,24 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "df_" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="df_"
%{
/*
* $Id$
@ -18,7 +39,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@ -68,12 +89,6 @@ GString* quoted_string = NULL;
%x RANGE_PUNCT
%x DQUOTE
/* we don't use unput, so don't generate code for it.
* This is flex-only, but current thinking is that our lexers don't work
* with non-flex anyway...
*/
%option nounput
%%
[[:blank:]\n]+ /* ignore whitespace */

View File

@ -1,10 +1,34 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read from the terminal.
*/
%option never-interactive
%option prefix="DiamDict"
/*
* The language we're scanning is case-insensitive.
*/
%option caseless
/*
* We use start condition stacks.
*/
%option stack
/*
* Prefix scanner routines with "DiamDict" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="DiamDict"
%option outfile="diam_dict.c"
%{
@ -27,9 +51,9 @@
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor,
** Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H

View File

@ -1,9 +1,26 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
%option outfile="dtd_parse.c"
%option prefix="Dtd_Parse_"
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "Dtd_Parse_" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="Dtd_Parse_"
%option outfile="dtd_parse.c"
%{
/* dtd_parse.l
@ -30,7 +47,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <glib.h>

View File

@ -1,8 +1,29 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
%option prefix="Dtd_PreParse_"
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* The language we're scanning is case-insensitive.
*/
%option caseless
/*
* Prefix scanner routines with "Dtd_PreParse_" rather than "yy", so this
* scanner can coexist with other scanners.
*/
%option prefix="Dtd_PreParse_"
%option outfile="dtd_preparse.c"
%{
@ -35,7 +56,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <glib.h>

View File

@ -1,10 +1,29 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read from the terminal.
*/
%option never-interactive
%option prefix="Radius"
/*
* The language we're scanning is case-insensitive.
*/
%option caseless
/*
* Prefix scanner routines with "Radius" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="Radius"
%option outfile="radius_dict.c"
%{
@ -30,8 +49,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H

View File

@ -1,8 +1,24 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
%option prefix="uat_load_"
%option never-interactive
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "uat_load_" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="uat_load_"
%{
/*
* uat_load.l
@ -31,7 +47,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"

View File

@ -130,8 +130,12 @@ EXTRA_DIST = \
moduleinfo.nmake \
plugin.rc.in
mate_parser.c : mate_parser.l
$(LEX) -Pdf_ -omate_parser.c $(srcdir)/mate_parser.l
.l.c:
@if [ ! -x "$(LEX)" ]; then \
echo "Neither lex nor flex was found"; \
exit 1; \
fi
$(LEX) -o$@ $<
LEMON = ../../tools/lemon

View File

@ -1,6 +1,22 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "Mate" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="Mate"
%{
@ -28,7 +44,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mate.h"

View File

@ -1,5 +1,10 @@
/* -*-mode: flex-*- */
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
%{
/********************************************************************************
@ -16,8 +21,6 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@ -30,7 +33,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*******************************************************************************/
@ -52,12 +55,6 @@ text [^ \n\t]+
mailfwd >
eol \r?\n\r?
/* we don't use unput, so don't generate code for it.
* This is flex-only, but current thinking is that our lexers don't work
* with non-flex anyway...
*/
%option nounput
%%
{byte} { parse_token(T_BYTE, yytext); }

View File

@ -79,12 +79,9 @@ ascend-grammar.c : ascend-grammar.y
fi
$(YACC) -d -p ascend -o ascend-grammar.c $(srcdir)/ascend-grammar.y
ascend-scanner.c : ascend-scanner.l
.l.c:
@if [ ! -x "$(LEX)" ]; then \
echo "Neither lex nor flex was found"; \
exit 1; \
fi
$(LEX) -Pascend -oascend-scanner.c $(srcdir)/ascend-scanner.l
k12text.c : k12text.l
$(LEX) -ok12text.c $(srcdir)/k12text.l
$(LEX) -o$@ $<

View File

@ -1,3 +1,19 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "ascend" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="ascend"
%{
/* ascend-scanner.l
*
@ -18,7 +34,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@ -59,9 +75,6 @@ int mul, scratch;
%}
%option nostdinit
%option noyywrap
D [0-9]
H [A-Fa-f0-9]

View File

@ -1,8 +1,26 @@
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
%option outfile="k12text.c"
%option prefix="K12Text_"
/*
* We don't read from the terminal.
*/
%option never-interactive
/*
* Prefix scanner routines with "K12Text_" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="K12Text_"
%option outfile="k12text.c"
%{
/* k12text.l
*