diff options
author | June McEnroe <june@causal.agency> | 2020-02-16 19:12:19 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-16 19:12:19 -0500 |
commit | ba524ed8045ea0e14664a64790fee53dd72a4541 (patch) | |
tree | 609ceb1caa887dabad7e7088722d5bf279b7873a /ui.c | |
parent | Add 379 to WHOIS responses (diff) | |
download | catgirl-ba524ed8045ea0e14664a64790fee53dd72a4541.tar.gz catgirl-ba524ed8045ea0e14664a64790fee53dd72a4541.zip |
Replace a lot of snprintf with a catf implementation
Diffstat (limited to '')
-rw-r--r-- | ui.c | 23 |
1 files changed, 11 insertions, 12 deletions
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); |