Change return type of strbuf_sprintf()

This commit is contained in:
Andrew Bettison 2015-03-16 22:33:11 +10:30
parent c9131f43a2
commit 00037cf803
2 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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 <andrew@servalproject.com>
*/
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.