From ba524ed8045ea0e14664a64790fee53dd72a4541 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 16 Feb 2020 19:12:19 -0500 Subject: Replace a lot of snprintf with a catf implementation --- ui.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'ui.c') diff --git a/ui.c b/ui.c index c39e6c3..aaa7b49 100644 --- a/ui.c +++ b/ui.c @@ -428,15 +428,15 @@ static void statusUpdate(void) { const struct Window *window = windows.ptrs[windows.show]; snprintf(title, sizeof(title), "%s %s", network.name, idNames[window->id]); if (window->mark && window->unreadWarm) { - snprintf( - &title[strlen(title)], sizeof(title) - strlen(title), - " (%d%s)", window->unreadWarm, (window->heat > Warm ? "!" : "") + catf( + title, sizeof(title), " (%d%s)", + window->unreadWarm, (window->heat > Warm ? "!" : "") ); } if (otherUnread) { - snprintf( - &title[strlen(title)], sizeof(title) - strlen(title), - " (+%d%s)", otherUnread, (otherHeat > Warm ? "!" : "") + catf( + title, sizeof(title), " (+%d%s)", + otherUnread, (otherHeat > Warm ? "!" : "") ); } } @@ -560,14 +560,13 @@ static void notify(uint id, const char *str) { struct Util util = uiNotifyUtil; utilPush(&util, idNames[id]); - size_t len = 0; char buf[1024] = ""; - while (*str && len < sizeof(buf)) { - size_t run; + while (*str) { + size_t len; struct Style style = Reset; - styleParse(&style, &str, &run); - len += snprintf(&buf[len], sizeof(buf) - len, "%.*s", (int)run, str); - str += run; + styleParse(&style, &str, &len); + catf(buf, sizeof(buf), "%.*s", (int)len, str); + str += len; } utilPush(&util, buf); -- cgit 1.4.0