Fix two bugs in cmpp: an unmatched right bracket in cfunc.mod

causes an infinite parsing loop (mod_yacc.y) and XSPICE macros
are replaced in string literals (mod_lex.l).
This commit is contained in:
Giles Atkinson 2023-09-12 08:18:19 +01:00 committed by Holger Vogt
parent dbc5042263
commit 62471ecede
2 changed files with 8 additions and 11 deletions

View File

@ -89,6 +89,8 @@ Z [0-9A-Za-z_]
} while (ch != '\n');
}
\"(\\.|[^"\\])*\" {return TOK_IDENTIFIER;} /* Literal string. */
ARGS {return TOK_ARGS;}
INIT {return TOK_INIT;}
CALLBACK {return TOK_CALLBACK;}

View File

@ -31,20 +31,13 @@ SUMMARY
INTERFACES
mod_yyparse() - Function 'yyparse()' is generated automatically
by UNIX 'yacc' utility and then converted to
'mod_yyparse()' by UNIX 'sed' utility under
direction of Makefile.
by UNIX 'yacc' utility. All yy* global names
are converted to mod_yy* by #define.
REFERENCED FILES
mod_lex.l
NON-STANDARD FEATURES
Names of functions generated by 'yacc' are translated by 'sed'
under direction of the Makefile to prevent collisions with
functions generated from ifs_yacc.y.
============================================================================*/
@ -388,8 +381,8 @@ mod_file : /* empty */
c_code : /* empty */
| c_code c_char
| c_code macro
/*| TOK_RPAREN {yyerror ("Unmatched )"); YYERROR;}
| TOK_RBRACKET {yyerror ("Unmatched ]"); YYERROR;}*/
| TOK_RPAREN {yyerror ("Unmatched )"); YYERROR;}
| TOK_RBRACKET {yyerror ("Unmatched ]"); YYERROR;}
;
buffered_c_code : {init_buffer();} buffered_c_code2
@ -416,10 +409,12 @@ buffered_c_char : TOK_IDENTIFIER {append (mod_yytext);}
c_char : TOK_IDENTIFIER {fputs (mod_yytext, mod_yyout);}
| TOK_MISC_C {fputs (mod_yytext, mod_yyout);}
| TOK_COMMA {fputs (mod_yytext, mod_yyout);}
| TOK_LBRACKET TOK_RBRACKET {fputs ("[]", mod_yyout);}
| TOK_LBRACKET
{putc ('[', mod_yyout);}
c_code TOK_RBRACKET
{putc (']', mod_yyout);}
| TOK_LPAREN TOK_RPAREN {fputs ("()", mod_yyout);}
| TOK_LPAREN
{putc ('(', mod_yyout);}
c_code TOK_RPAREN