From 00037cf803846502df4f8a35d4248df5e95471ae Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 16 Mar 2015 22:33:11 +1030 Subject: [PATCH] Change return type of strbuf_sprintf() --- strbuf.c | 10 +++++----- strbuf.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/strbuf.c b/strbuf.c index 23efa133..66557f90 100644 --- a/strbuf.c +++ b/strbuf.c @@ -101,16 +101,16 @@ strbuf strbuf_putc(strbuf sb, char ch) return sb; } -int strbuf_sprintf(strbuf sb, const char *fmt, ...) +strbuf strbuf_sprintf(strbuf sb, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - int n = strbuf_vsprintf(sb, fmt, ap); + strbuf_vsprintf(sb, fmt, ap); va_end(ap); - return n; + return sb; } -int strbuf_vsprintf(strbuf sb, const char *fmt, va_list ap) +strbuf strbuf_vsprintf(strbuf sb, const char *fmt, va_list ap) { int n; if (sb->start && !sb->end) { @@ -126,7 +126,7 @@ int strbuf_vsprintf(strbuf sb, const char *fmt, va_list ap) } if (n != -1) sb->current += n; - return n; + return sb; } char *strbuf_substr(const_strbuf sb, int offset) diff --git a/strbuf.h b/strbuf.h index ff8f27ec..2966310b 100644 --- a/strbuf.h +++ b/strbuf.h @@ -353,7 +353,7 @@ strbuf strbuf_putc(strbuf sb, char ch); /** Append the results of sprintf(fmt,...) to the string buffer, truncating if - * necessary to avoid buffer overrun. Return sprintf()'s return value. + * necessary to avoid buffer overrun. Return a pointer to the strbuf. * * This is equivalent to char tmp[...]; sprintf(tmp, fmt, ...); strbuf_puts(tmp); * assuming that tmp[] is large enough to contain the entire string produced by @@ -361,8 +361,8 @@ strbuf strbuf_putc(strbuf sb, char ch); * * @author Andrew Bettison */ -int strbuf_sprintf(strbuf sb, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int strbuf_vsprintf(strbuf sb, const char *fmt, va_list ap); +strbuf strbuf_sprintf(strbuf sb, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +strbuf strbuf_vsprintf(strbuf sb, const char *fmt, va_list ap); /** Return a pointer to the current nul-terminated string in the strbuf.