diff --git a/DESCRIPTION b/DESCRIPTION index 84171ca..5cb3576 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: parseLatex Type: Package Title: Parse 'LaTeX' Code -Version: 0.4.2 +Version: 0.4.3 Authors@R: c( person( "Duncan", "Murdoch", diff --git a/NEWS.md b/NEWS.md index b969d65..44ba426 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ -# parseLatex 0.4.2 +# parseLatex 0.4.3 * Improved support for syntax of `\let` and `\def`. +* Fixed error in C code as requested by CRAN. # parseLatex 0.4.1 diff --git a/src/gramLatex.tab.c b/src/gramLatex.tab.c index 7f731ee..1c792b3 100644 --- a/src/gramLatex.tab.c +++ b/src/gramLatex.tab.c @@ -3158,11 +3158,17 @@ static void yyerror(const char *s) if (!strncmp(s, yyunexpected, sizeof yyunexpected -1)) { int i, translated = FALSE; + + /* Make local copy so we can modify it */ + char s1[PARSE_ERROR_SIZE + 1]; + strncpy(s1, s, PARSE_ERROR_SIZE); + s1[PARSE_ERROR_SIZE] = 0; + /* Edit the error message */ - expecting = strstr(s + sizeof yyunexpected -1, yyexpecting); + expecting = strstr(s1 + sizeof yyunexpected -1, yyexpecting); if (expecting) *expecting = '\0'; for (i = 0; yytname_translations[i]; i += 2) { - if (!strcmp(s + sizeof yyunexpected - 1, yytname_translations[i])) { + if (!strcmp(s1 + sizeof yyunexpected - 1, yytname_translations[i])) { if (yychar < 256 || yychar == END_OF_INPUT) snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yyshortunexpected), @@ -3182,11 +3188,11 @@ static void yyerror(const char *s) if (yychar < 256 || yychar == END_OF_INPUT) snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yyshortunexpected), - s + sizeof yyunexpected - 1); + s1 + sizeof yyunexpected - 1); else snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yylongunexpected), - s + sizeof yyunexpected - 1, CHAR(STRING_ELT(yylval, 0))); + s1 + sizeof yyunexpected - 1, CHAR(STRING_ELT(yylval, 0))); } if (expecting) { translated = FALSE; diff --git a/src/parser/gramLatex.y b/src/parser/gramLatex.y index 3924ce7..f183679 100644 --- a/src/parser/gramLatex.y +++ b/src/parser/gramLatex.y @@ -1069,11 +1069,17 @@ static void yyerror(const char *s) if (!strncmp(s, yyunexpected, sizeof yyunexpected -1)) { int i, translated = FALSE; + + /* Make local copy so we can modify it */ + char s1[PARSE_ERROR_SIZE + 1]; + strncpy(s1, s, PARSE_ERROR_SIZE); + s1[PARSE_ERROR_SIZE] = 0; + /* Edit the error message */ - expecting = strstr(s + sizeof yyunexpected -1, yyexpecting); + expecting = strstr(s1 + sizeof yyunexpected -1, yyexpecting); if (expecting) *expecting = '\0'; for (i = 0; yytname_translations[i]; i += 2) { - if (!strcmp(s + sizeof yyunexpected - 1, yytname_translations[i])) { + if (!strcmp(s1 + sizeof yyunexpected - 1, yytname_translations[i])) { if (yychar < 256 || yychar == END_OF_INPUT) snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yyshortunexpected), @@ -1093,11 +1099,11 @@ static void yyerror(const char *s) if (yychar < 256 || yychar == END_OF_INPUT) snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yyshortunexpected), - s + sizeof yyunexpected - 1); + s1 + sizeof yyunexpected - 1); else snprintf(ParseErrorMsg, PARSE_ERROR_SIZE, _(yylongunexpected), - s + sizeof yyunexpected - 1, CHAR(STRING_ELT(yylval, 0))); + s1 + sizeof yyunexpected - 1, CHAR(STRING_ELT(yylval, 0))); } if (expecting) { translated = FALSE;