make flex stuff as reentrant as i can
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 19 Mar 2003 20:08:26 +0000 (20:08 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 19 Mar 2003 20:08:26 +0000 (20:08 +0000)
lib/calib.c
lib/calib_lex.l
lib/calib_yacc.y
lib/libinternal.h

index 81d16223b3fe6522e1d3d459c17b6709fe01dc29..566fd99b8c140ffae95caa33cd9e7d68651dbf60 100644 (file)
@@ -32,13 +32,15 @@ static int check_cal_file( comedi_t *dev, struct calibration_file_contents *pars
 {
        if( strcmp( comedi_get_driver_name( dev ), parsed_file->driver_name ) )
        {
-               COMEDILIB_DEBUG( 3, "driver name does not match calibration file\n" );
+               COMEDILIB_DEBUG( 3, "driver name does not match '%s' from calibration file\n",
+                       parsed_file->driver_name );
                return -1;
        }
 
        if( strcmp( comedi_get_board_name( dev ), parsed_file->board_name ) )
        {
-               COMEDILIB_DEBUG( 3, "board name does not match calibration file\n" );
+               COMEDILIB_DEBUG( 3, "board name does not match '%s' from calibration file\n",
+                       parsed_file->board_name );
                return -1;
        }
 
index 65f73260ca01d83a5e48f51bb40f5b228b220968..ee60a7bbbf7482d342295638201acc19e6bb40f9 100644 (file)
     USA.
 */
 
+#include <string.h>
 #include "libinternal.h"
 #include "calib_yacc.h"
 
-YYLTYPE yylloc;
-char string_buf[ 100 ];
-char *string_buf_ptr;
-
 %}
 
 %x COMMENT
@@ -38,25 +35,20 @@ char *string_buf_ptr;
 
 %%
 
-<STRING,INITIAL>\n { yylloc.first_line++; }
+<STRING,INITIAL>\n { calib_llocp->first_line++; }
 
-"#" BEGIN(COMMENT);
-<COMMENT>\n { yylloc.first_line++; BEGIN(INITIAL); }
+"#" { BEGIN(COMMENT); }
+<COMMENT>\n { calib_llocp->first_line++; BEGIN(INITIAL); }
 <COMMENT>.
 
-\" { string_buf_ptr = string_buf; BEGIN(STRING); }
-<STRING>\" {
-               *string_buf_ptr = 0;
-               BEGIN(INITIAL);
-               calib_lvalp->sval = string_buf;
-               return ( T_STRING );
-       }
-<STRING>[^\n\"]+ {
-               char *yptr = yytext;
-
-               while ( *yptr && ( string_buf_ptr - string_buf ) < sizeof( string_buf ) - 1 )
-                       *string_buf_ptr++ = *yptr++;
-       }
+\" { BEGIN(STRING); }
+<STRING>[^\"]*\" {
+       if( strlen( yytext ) > 0 )
+               yytext[ strlen( yytext ) - 1 ] = 0;
+       calib_lvalp->sval = yytext;
+       BEGIN(INITIAL);
+       return ( T_STRING );
+}
 
 driver_name    { return ( T_DRIVER_NAME ); }
 board_name     { return ( T_BOARD_NAME ); }
index b42f1141125c88e4c0715365fcb6478caf18f806..ef235b97febf34812fc61ea47ed5a4da5c9d234a 100644 (file)
@@ -37,7 +37,6 @@ typedef struct
        int cal_index;
 } calib_yyparse_private_t;
 
-FILE *calib_yyin;
 YY_DECL;
 
 static inline calib_yyparse_private_t* priv( calib_yyparse_private_t *parse_arg)
@@ -200,10 +199,10 @@ extern struct calibration_file_contents* parse_calibration_file( FILE *file )
 {
        calib_yyparse_private_t priv;
 
-       calib_yyin = file;
        priv.parsed_file = alloc_calib_parse();
        if( priv.parsed_file == NULL ) return priv.parsed_file;
        priv.cal_index = 0;
+       calib_yyrestart( file );
        if( calib_yyparse( &priv ) )
        {
                cleanup_calibration_parse( priv.parsed_file );
index 6b1dffc29172659987b384da49881c649d647afa..224d5e11465a800dd5d4d4fd9bae379104f2b461 100644 (file)
@@ -186,6 +186,7 @@ struct calibration_file_contents
 #define YY_DECL int calib_yylex( YYSTYPE *calib_lvalp, YYLTYPE *calib_llocp )
 void calib_yyerror( char *s );
 int calib_yyparse( void *parse_arg );
+void calib_yyrestart( FILE *input );
 struct calibration_file_contents* parse_calibration_file( FILE *file );
 void cleanup_calibration_parse( struct calibration_file_contents *parsed_file );