Re: [PATCH 06/19] diff: add emit_line_fmt
- From
- Brandon Williams <bmwill@google.com>
- Date
- May 15, 2017, 19:31 UTC
- Message-ID
- <20170515193124.GC79147@google.com>
- In-Reply-To
- <20170514040117.25865-7-sbeller@google.com>
On 05/13, Stefan Beller wrote:
Show 39 quoted lines
> In the following patches we'll convert all printing functions to use
> the emit_line_* family of functions.
>
> Many of the printing functions to be converted are formatted. So offer
> a formatted function in the emit_line function family as well.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> diff.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/diff.c b/diff.c
> index 48f0fb98dc..aef159a919 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -552,6 +552,20 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset
> emit_line_0(o, set, reset, 0, line, len);
> }
>
> +static void emit_line_fmt(struct diff_options *o,
> + const char *set, const char *reset,
> + const char *fmt, ...)
> +{
> + struct strbuf sb = STRBUF_INIT;
> + va_list ap;
> + va_start(ap, fmt);
> + strbuf_vaddf(&sb, fmt, ap);
> + va_end(ap);
> +
> + emit_line(o, set, reset, sb.buf, sb.len);
> + strbuf_release(&sb);
> +}
> +
> static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
> {
> if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
> --
> 2.13.0.18.g183880de0a
> Since this is a new function, and it is marked static, this patch shouldn't compile or the compiler should throw a warning or something.
-- Brandon Williams