From 0e8079c81c1c526a6ee78c97f16644fcc19051ad Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Wed, 18 Aug 1999 18:23:41 +0000 Subject: [PATCH] Declared yyerrcnt to be static Added YY_USER_INIT macro to set the input buffer size to the config file size (plus a bit). This is supposed to be a workaround for the REJECT problem. --- src/lexer.l | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/lexer.l b/src/lexer.l index c109111..8d99bd6 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -4,7 +4,7 @@ * Date created: March 15, 1999 (Monday, 17:16h) * Author: Copyright (C) 1999 Thomas Jensen * tsjensen@stud.informatik.uni-erlangen.de - * Version: $Id: lexer.l,v 1.14 1999/08/16 16:28:03 tsjensen Exp tsjensen $ + * Version: $Id: lexer.l,v 1.15 1999/08/18 15:40:10 tsjensen Exp tsjensen $ * Language: lex (ANSI C) * Purpose: flex lexical analyzer for boxes configuration files * @@ -20,10 +20,17 @@ * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA + * - We don't use the yylineno %option. It is not only inefficient, + * but also doesn't work. :-| *doh* * * Revision History: * * $Log: lexer.l,v $ + * Revision 1.15 1999/08/18 15:40:10 tsjensen + * Added %options never-interactive and caseless + * Added code for DELIMITER statements + * Rewrote string rules to deal with delimiter statements + * * Revision 1.14 1999/08/16 16:28:03 tsjensen * Implemented new SAMPLE block syntax * Replaced states SAMPLE1 and SAMPLE2 with new state SAMPLE - this is now @@ -80,6 +87,8 @@ #include "config.h" #include +#include +#include #include "shape.h" #define FILE_LEXER_L #include "boxes.h" @@ -94,15 +103,33 @@ static const char rcsid_lexer_l[] = - "$Id: lexer.l,v 1.14 1999/08/16 16:28:03 tsjensen Exp tsjensen $"; + "$Id: lexer.l,v 1.15 1999/08/18 15:40:10 tsjensen Exp tsjensen $"; int yylineno = 1; -int yyerrcnt = 0; +static int yyerrcnt = 0; static char sdel = '\"'; static char sesc = '\\'; + +/* + * Since this scanner must use REJECT in order to be able to process the + * string delimiter commands, it cannot dynamically enlarge its input + * buffer to accomodate larger tokens. Thus, we simply set the buffer size + * to the input file size plus 10 bytes margin-of-error. + */ +#define YY_USER_INIT { \ + struct stat sinf; \ + \ + if (stat(yyfilename, &sinf)) { \ + perror (PROJECT); \ + exit (EXIT_FAILURE); \ + } \ + yy_delete_buffer (YY_CURRENT_BUFFER); \ + YY_CURRENT_BUFFER = yy_create_buffer (yyin, sinf.st_size+10); \ +} + %} %option nounput