From 39efb5a3e215903e934d8d1c1b92c78f8b90e7ab Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 9 Jun 2021 14:38:20 -0400 Subject: Use seprintf for reserialize --- client.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index a4ecb25..a1750bc 100644 --- a/client.c +++ b/client.c @@ -284,25 +284,20 @@ static const char *synthLabel(struct Client *client) { static void reserialize( char *buf, size_t cap, const char *origin, const struct Message *msg ) { - size_t len = 0; + char *ptr = buf, *end = &buf[cap]; if (msg->tags) { - len += snprintf(&buf[len], cap - len, "@%s ", msg->tags); - if (len >= cap) return; + ptr = seprintf(ptr, end, "@%s ", msg->tags); } - if (!origin) origin = msg->origin; - if (origin) { - len += snprintf(&buf[len], cap - len, ":%s ", origin); - if (len >= cap) return; + if (origin || msg->origin) { + ptr = seprintf(ptr, end, ":%s ", (origin ? origin : msg->origin)); } - len += snprintf(&buf[len], cap - len, "%s", msg->cmd); - if (len >= cap) return; + ptr = seprintf(ptr, end, "%s", msg->cmd); for (size_t i = 0; i < ParamCap && msg->params[i]; ++i) { if (i + 1 == ParamCap || !msg->params[i + 1]) { - len += snprintf(&buf[len], cap - len, " :%s", msg->params[i]); + ptr = seprintf(ptr, end, " :%s", msg->params[i]); } else { - len += snprintf(&buf[len], cap - len, " %s", msg->params[i]); + ptr = seprintf(ptr, end, " %s", msg->params[i]); } - if (len >= cap) return; } } -- cgit 1.4.1 ype='hidden' name='id' value='3968224ad89128d743d92c5b121479d6dd67b6c5'/>
path: root/etc/Go-Mono-Italic.ttf (unfollow)
Commit message (Expand)Author
2021-01-19Prefer tag matches not preceded by [[:alnum:]]June McEnroe
2021-01-19Escape \ and / in mtags search patternsJune McEnroe
2021-01-20Use mtags in source-filterJune McEnroe
2021-01-19Add mtags to generate tags for make and mdocJune McEnroe
2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe
2021-01-19Don't use a pager if reading standard inputJune McEnroe
2021-01-19Support BSD make syntax and match *.amJune McEnroe
2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe
2021-01-18Allow matching lexers using first input lineJune McEnroe