]> granicus.if.org Git - graphviz/commitdiff
simplify strdup_and_subst_obj0 with agxbprint
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Sep 2020 16:58:18 +0000 (09:58 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 17 Sep 2020 04:08:23 +0000 (21:08 -0700)
lib/common/labels.c

index e2d666ea3a354ce3dd08995f271b3c24b2d9926e..7339590b072b6b83c02424a3f3c7d163ac8828de 100644 (file)
@@ -355,14 +355,11 @@ static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash)
                if (isEdge) {
                    agxbput(&buf, t_str);
                    if (has_tp) {
-                       agxbputc(&buf, ':');
-                       agxbput(&buf, tp_str);
+                       agxbprint(&buf, ":%s", tp_str);
                    }
-                   agxbput(&buf, e_str);
-                   agxbput(&buf, h_str);
+                   agxbprint(&buf, "%s%s", e_str, h_str);
                    if (has_hp) {
-                       agxbputc(&buf, ':');
-                       agxbput(&buf, hp_str);
+                       agxbprint(&buf, ":%s", hp_str);
                    }
                }
                break;
@@ -382,8 +379,7 @@ static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash)
                }
                /* Fall through */
            default:  /* leave other escape sequences unmodified, e.g. \n \l \r */
-               agxbputc(&buf, '\\');
-               agxbputc(&buf, c);
+               agxbprint(&buf, "\\%c", c);
                break;
            }
        } else {