Re: [PATCH 04/26] diff.c: introduce emit_diff_symbol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stefan Beller <sbeller@xxxxxxxxxx> writes:

> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
> ---
>  diff.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 2f9722b382..89466018e5 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -559,6 +559,24 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset
>  	emit_line_0(o, set, reset, line[0], line+1, len-1);
>  }
>  
> +enum diff_symbol {
> +	DIFF_SYMBOL_SEPARATOR,

Drop the last comma from enum?

> +static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
> +			     const char *line, int len)
> +{
> +	switch (s) {
> +	case DIFF_SYMBOL_SEPARATOR:
> +		fprintf(o->file, "%s%c",
> +			diff_line_prefix(o),
> +			o->line_termination);
> +		break;

As the first patch in the "diff-symbol" subseries of this topic,
this change must seriously be justified.  Why is it so important
that a printing of an empty line must be moved to a helper function,
which later will gain ability to show other kind of lines?

> +	default:
> +		die("BUG: unknown diff symbol");
> +	}
> +}
> +
>  static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
>  {
>  	if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
> @@ -4833,9 +4851,7 @@ void diff_flush(struct diff_options *options)
>  
>  	if (output_format & DIFF_FORMAT_PATCH) {
>  		if (separator) {
> -			fprintf(options->file, "%s%c",
> -				diff_line_prefix(options),
> -				options->line_termination);
> +			emit_diff_symbol(options, DIFF_SYMBOL_SEPARATOR, NULL, 0);
>  			if (options->stat_sep) {
>  				/* attach patch instead of inline */
>  				fputs(options->stat_sep, options->file);



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux