Skip to content

Commit

Permalink
Incorrect line count in case of an error in msc input
Browse files Browse the repository at this point in the history
The variables to store line number etc. are static variables and should be reset on each invocation of the lex msc parser.
  • Loading branch information
albert-github committed Nov 20, 2020
1 parent 4211ec2 commit a51a6d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions libmscgen/mscgen_language.y
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Msc MscParse(FILE *in)

yyin = in;

lex_resetparser();
/* Parse, and check that no errors are found */
if(yyparse((void *)&m) != 0)
{
Expand Down
1 change: 1 addition & 0 deletions libmscgen/mscgen_lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Boolean lex_getutf8(void);
unsigned long lex_getlinenum(void);
char *lex_getline(void);
void lex_destroy(void);
void lex_resetparser(void);

#endif /* MSCGEN_LEXER_H */

Expand Down
7 changes: 7 additions & 0 deletions libmscgen/mscgen_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,12 @@ Boolean lex_getutf8(void)
return lex_utf8;
}

void lex_resetparser()
{
lex_linenum = 1;
lex_line = NULL;
lex_utf8 = FALSE;
}

#include "mscgen_lexer.l.h"
/* END OF FILE */

0 comments on commit a51a6d4

Please sign in to comment.