From: Emden R. Gansner Date: Thu, 24 Jul 2014 20:58:28 +0000 (-0400) Subject: Add more context to scanning error messages X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~195 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc6f1e04533b459d521f39ad854e8cae13dc28fb;p=graphviz Add more context to scanning error messages --- diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index f6edf7576..684a66b38 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -76,10 +76,12 @@ static void addstr(char *src) { static void endstr(void) { yylval.str = (char*)agstrdup(Ag_G_global,Sbuf); + *Sbuf = 0; } static void endstr_html(void) { yylval.str = (char*)agstrdup_html(Ag_G_global,Sbuf); + *Sbuf = 0; } static void @@ -232,10 +234,24 @@ void yyerror(char *str) case qstring : sprintf(buf, " scanning a quoted string (missing endquote? longer than %d?)", YY_BUF_SIZE); agxbput (&xb, buf); + if (*Sbuf) { + int len = strlen(Sbuf); + agxbput (&xb, "\nString starting:\""); + if (len > 80) + Sbuf[80] = '\0'; + agxbput (&xb, Sbuf); + } break; case hstring : sprintf(buf, " scanning a HTML string (missing '>'? bad nesting? longer than %d?)", YY_BUF_SIZE); agxbput (&xb, buf); + if (*Sbuf) { + int len = strlen(Sbuf); + agxbput (&xb, "\nString starting:<"); + if (len > 80) + Sbuf[80] = '\0'; + agxbput (&xb, Sbuf); + } break; case comment : sprintf(buf, " scanning a /*...*/ comment (missing '*/? longer than %d?)", YY_BUF_SIZE);