summary refs log tree commit diff
path: root/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'handle.c')
-rw-r--r--handle.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/handle.c b/handle.c
index c602c23..7fba7f2 100644
--- a/handle.c
+++ b/handle.c
@@ -152,8 +152,10 @@ static void handle366(char *prefix, char *params) {
 	ircFmt("WHO %s\r\n", chan);
 }
 
-static char whoBuf[4096];
-static size_t whoLen;
+static struct {
+	char buf[4096];
+	size_t len;
+} who;
 
 static void handle352(char *prefix, char *params) {
 	(void)prefix;
@@ -163,21 +165,23 @@ static void handle352(char *prefix, char *params) {
 	shift(&params);
 	shift(&params);
 	char *nick = shift(&params);
-	whoLen += snprintf(
-		&whoBuf[whoLen], sizeof(whoBuf) - whoLen,
+	size_t cap = sizeof(who.buf) - who.len;
+	int len = snprintf(
+		&who.buf[who.len], cap,
 		"%s\3%d%s\3",
-		(whoLen ? ", " : ""), color(user), nick
+		(who.len ? ", " : ""), color(user), nick
 	);
+	if ((size_t)len < cap) who.len += len;
 }
 
 static void handle315(char *prefix, char *params) {
 	(void)prefix;
 	shift(&params);
 	char *chan = shift(&params);
-	whoLen = 0;
+	who.len = 0;
 	uiFmt(
 		L"In \3%d%s\3 are %s",
-		color(chan), chan, whoBuf
+		color(chan), chan, who.buf
 	);
 }
 
9bf474235bc9a6dcb068439&follow=1'>Add c11.pdfJune McEnroe 2019-07-27Move pdf script to MakefileJune McEnroe 2019-07-27Update macOS neovim to 0.3.8June McEnroe 2019-07-27Rewrite port makefiles consistentlyJune McEnroe 2019-07-27Rewrite Makefile once more with more organizationJune McEnroe 2019-07-27Reference png.h in bin.7June McEnroe 2019-07-27Revert "Use scheme to style HTMLs"June McEnroe 2019-07-27Remove scheme text linkJune McEnroe 2019-07-26Update Dark.terminalJune McEnroe 2019-07-26Lighten dark whiteJune McEnroe 2019-07-25Add png.3 man pageJune McEnroe 2019-07-25Use scheme to style HTMLsJune McEnroe 2019-07-25Don't match comments in strings in makeJune McEnroe 2019-07-25Generate index.html with links from bin.7June McEnroe 2019-07-24Warn when date has changedJune McEnroe 2019-07-24Add whenJune McEnroe 2019-07-24Remove histedit from bitJune McEnroe