diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index e2215d1..f41049d 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -16,6 +16,7 @@ %{ #include #include +#include #include #define GRAPH_EOF_TOKEN '@' /* lex class must be defined below */ /* this is a workaround for linux flex */ @@ -192,13 +193,22 @@ ID ({NAME}|{NUMBER}) %% void yyerror(char *str) { + unsigned char xbuf[BUFSIZ]; char buf[BUFSIZ]; - if (InputFile) - sprintf(buf,"%s:%d: %s in line %d near '%s'\n",InputFile, line_num, - str,line_num,yytext); - else - sprintf(buf," %s in line %d near '%s'\n", str,line_num,yytext); - agerr(AGWARN,buf); + agxbuf xb; + + agxbinit(&xb, BUFSIZ, xbuf); + if (InputFile) { + agxbput (&xb, InputFile); + agxbput (&xb, ": "); + } + agxbput (&xb, str); + sprintf(buf," in line %d near '", line_num); + agxbput (&xb, buf); + agxbput (&xb, yytext); + agxbput (&xb,"'\n"); + agerr(AGWARN,agxbuse(&xb)); + agxbfree(&xb); } /* must be here to see flex's macro defns */ void aglexeof() { unput(GRAPH_EOF_TOKEN); }