Browse Source

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).
pre-master-46
Giles Atkinson 3 years ago
committed by Holger Vogt
parent
commit
62471ecede
  1. 2
      src/xspice/cmpp/mod_lex.l
  2. 17
      src/xspice/cmpp/mod_yacc.y

2
src/xspice/cmpp/mod_lex.l

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

17
src/xspice/cmpp/mod_yacc.y

@ -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

Loading…
Cancel
Save