Re: [PATCH 02/10] Add three convenient format printing functions with \n automatically appended
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Apr 23, 2012, 16:15 UTC
- Message-ID
- <20120423161536.GE4832@burratino>
- In-Reply-To
- <1335184230-8870-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
> --- a/strbuf.c > +++ b/strbuf.c > @@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
[...]
Show 9 quoted lines
> +int printf_ln(const char *fmt, ...)
> +{
> + int ret;
> + va_list ap;
> + va_start(ap, fmt);
> + ret = vprintf(fmt, ap);
> + va_end(ap);
> + if (ret >= 0)
> + ret += printf("\n");Missed a spot. I'd do
if (ret < 0 || putchar('\n') == EOF)
return -1;
return ret + 1;And likewise, for the fprintf version:
if (ret < 0 || putc('\n', fp) == EOF)
return -1;
return ret + 1;Hope that helps, Jonathan