Re: [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Apr 17, 2012, 08:12 UTC
- Message-ID
- <CABPQNSbnGKFW=Lf0nnLEOAZf4iOGsmfiMqoioitH3Ps6ZWV7FA@mail.gmail.com>
- In-Reply-To
- <1334580603-11577-2-git-send-email-pclouds@gmail.com>
2012/4/16 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
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");<snip>
> + ret += fprintf(fp, "\n");
Apart from Jonathan's comment, isn't [f]printf a big hammer for this? Wouldn't putchar / fputc be a tad more light-weight (and perhaps clearer)?