From: Matthew Fernandez Date: Sun, 6 Sep 2020 16:47:46 +0000 (-0700) Subject: simplify aagerror with agxbprint X-Git-Tag: 2.46.0~20^2^2~77^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c39e5851add33bd71893b6deaf8d6ed1ea14b5a;p=graphviz simplify aagerror with agxbprint --- diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 8a261f02c..c918396c4 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -234,48 +234,37 @@ ID ({NAME}|{NUMBER}) void aagerror(char *str) { unsigned char xbuf[BUFSIZ]; - char buf[BUFSIZ]; agxbuf xb; agxbinit(&xb, BUFSIZ, xbuf); if (InputFile) { - agxbput (&xb, InputFile); - agxbput (&xb, ": "); + agxbprint (&xb, "%s: ", InputFile); } - agxbput (&xb, str); - sprintf(buf," in line %d", line_num); - agxbput (&xb, buf); + agxbprint (&xb, "%s in line %d", str, line_num); if (*aagtext) { - agxbput(&xb," near '"); - agxbput (&xb, aagtext); - agxbputc (&xb, '\''); + agxbprint(&xb, " near '%s'", aagtext); } else switch (YYSTATE) { case qstring : - sprintf(buf, " scanning a quoted string (missing endquote? longer than %d?)", YY_BUF_SIZE); - agxbput (&xb, buf); + agxbprint(&xb, " scanning a quoted string (missing endquote? longer than %d?)", YY_BUF_SIZE); if (*Sbuf) { size_t len = strlen(Sbuf); - agxbput (&xb, "\nString starting:\""); if (len > 80) Sbuf[80] = '\0'; - agxbput (&xb, Sbuf); + agxbprint (&xb, "\nString starting:\"%s", Sbuf); } break; case hstring : - sprintf(buf, " scanning a HTML string (missing '>'? bad nesting? longer than %d?)", YY_BUF_SIZE); - agxbput (&xb, buf); + agxbprint(&xb, " scanning a HTML string (missing '>'? bad nesting? longer than %d?)", YY_BUF_SIZE); if (*Sbuf) { size_t len = strlen(Sbuf); - agxbput (&xb, "\nString starting:<"); if (len > 80) Sbuf[80] = '\0'; - agxbput (&xb, Sbuf); + agxbprint (&xb, "\nString starting:<%s", Sbuf); } break; case comment : - sprintf(buf, " scanning a /*...*/ comment (missing '*/? longer than %d?)", YY_BUF_SIZE); - agxbput (&xb, buf); + agxbprint(&xb, " scanning a /*...*/ comment (missing '*/? longer than %d?)", YY_BUF_SIZE); break; } agxbputc (&xb, '\n');