]> granicus.if.org Git - graphviz/commitdiff
cgraph: simplify error handling to let 'agxbprint' do string clamping
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Dec 2022 19:57:39 +0000 (11:57 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 21 Dec 2022 02:54:30 +0000 (18:54 -0800)
lib/cgraph/scan.l

index 20fbd36ae2f603a85581b1209853fdc96fe5d2a5..8f61aacaa9f82913acd43051f70f47e9fa8b9118 100644 (file)
@@ -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;
        }