From: Matthew Fernandez Date: Sat, 17 Dec 2022 19:57:39 +0000 (-0800) Subject: cgraph: simplify error handling to let 'agxbprint' do string clamping X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=787a2aa6e0ee5e427a6f64a775083cc486afcc43;p=graphviz cgraph: simplify error handling to let 'agxbprint' do string clamping --- diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 20fbd36ae..8f61aacaa 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -233,21 +233,15 @@ void aagerror(const char *str) else switch (YYSTATE) { case qstring: { agxbprint(&xb, " scanning a quoted string (missing endquote? longer than %d?)", YY_BUF_SIZE); - size_t len = agxblen(&Sbuf); - if (len > 0) { - if (len > 80) - len = 80; - agxbprint(&xb, "\nString starting:\"%.*s", (int)len, agxbuse(&Sbuf)); + if (agxblen(&Sbuf) > 0) { + agxbprint(&xb, "\nString starting:\"%.80s", agxbuse(&Sbuf)); } break; } case hstring: { agxbprint(&xb, " scanning a HTML string (missing '>'? bad nesting? longer than %d?)", YY_BUF_SIZE); - size_t len = agxblen(&Sbuf); - if (len > 0) { - if (len > 80) - len = 80; - agxbprint(&xb, "\nString starting:<%.*s", (int)len, agxbuse(&Sbuf)); + if (agxblen(&Sbuf) > 0) { + agxbprint(&xb, "\nString starting:<%.80s", agxbuse(&Sbuf)); } break; }