From dc6f1e04533b459d521f39ad854e8cae13dc28fb Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Thu, 24 Jul 2014 16:58:28 -0400 Subject: [PATCH] Add more context to scanning error messages --- lib/cgraph/scan.l | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); -- 2.50.1