diff options
author | C. McEnroe | 2020-02-16 19:12:19 -0500 |
---|---|---|
committer | C. McEnroe | 2020-02-16 19:12:19 -0500 |
commit | ba524ed8045ea0e14664a64790fee53dd72a4541 (patch) | |
tree | 609ceb1caa887dabad7e7088722d5bf279b7873a /ui.c | |
parent | 3885dd52316283e4fc55a76898eb718990673d7a (diff) |
Replace a lot of snprintf with a catf implementation
Diffstat (limited to 'ui.c')
-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); |