make flex stuff as reentrant as i can

This commit is contained in:
Frank Mori Hess 2003-03-19 20:08:26 +00:00
parent 02062c63ac
commit 163c004ada
4 changed files with 18 additions and 24 deletions

View 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;
}

View file

@ -24,13 +24,10 @@
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 ); }

View 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 );

View 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 );