From a90ab75da320c5822ac7fd2a9d880161a48a5fc0 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 9 Aug 2020 11:57:31 -0700 Subject: [PATCH] avoid use of a temporary buffer when constructing an error message agerr() supports printf-style arguments, so it was not necessary to manually build the error string in a temporary buffer. --- lib/cgraph/scan.l | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 37660455b..dee062982 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -148,9 +148,6 @@ static int twoDots(void) static int chkNum(void) { unsigned char c = (unsigned char)yytext[yyleng-1]; /* last character */ if ((!isdigit(c) && (c != '.')) || ((c == '.') && twoDots())) { /* c is letter */ - unsigned char xbuf[BUFSIZ]; - char buf[BUFSIZ]; - agxbuf xb; char* fname; if (InputFile) @@ -158,17 +155,9 @@ static int chkNum(void) { else fname = "input"; - agxbinit(&xb, BUFSIZ, xbuf); - - agxbput(&xb,"syntax ambiguity - badly delimited number '"); - agxbput(&xb,yytext); - sprintf(buf,"' in line %d of ", line_num); - agxbput(&xb,buf); - agxbput(&xb,fname); - agxbput(&xb, " splits into two tokens\n"); - agerr(AGWARN, "%s", agxbuse(&xb)); + agerr(AGWARN, "syntax ambiguity - badly delimited number '%s' in line %d of " + "%s splits into two tokens\n", yytext, line_num, fname); - agxbfree(&xb); return 1; } else return 0; -- 2.40.0