From: Matthew Fernandez <matthew.fernandez@gmail.com>
Date: Sun, 9 Aug 2020 18:57:31 +0000 (-0700)
Subject: avoid use of a temporary buffer when constructing an error message
X-Git-Tag: 2.46.0~20^2^2~122^2~1
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a90ab75da320c5822ac7fd2a9d880161a48a5fc0;p=graphviz

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.
---

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;