{
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;
}
USA.
*/
+#include <string.h>
#include "libinternal.h"
#include "calib_yacc.h"
-YYLTYPE yylloc;
-char string_buf[ 100 ];
-char *string_buf_ptr;
-
%}
%x COMMENT
%%
-<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 ); }
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)
{
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 );
#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 );