[PATCHv2 05/20] diff.c: emit_line_0 can handle no color setting
- From
Stefan Beller <sbeller@google.com>
- Date
- May 17, 2017, 02:58 UTC
- Message-ID
- <20170517025857.32320-6-sbeller@google.com>
- In-Reply-To
- <20170517025857.32320-1-sbeller@google.com>
In later patches we may pass lines that are not colored to the central function emit_line_0, so we need to emit the color only when it is non-NULL.
We could have chosen to pass "" instead of NULL, but that would be more work.
Signed-off-by: Stefan Beller <sbeller@google.com> --- diff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c index 73e55b0c10..6c1886d495 100644 --- a/diff.c +++ b/diff.c @@ -532,11 +532,13 @@ static void emit_line_0(struct diff_options *o, const char *set, const char *res len--; if (len || sign) { - fputs(set, file); + if (set) + fputs(set, file); if (sign) fputc(sign, file); fwrite(line, len, 1, file); - fputs(reset, file); + if (reset) + fputs(reset, file); } if (has_trailing_carriage_return) fputc('\r', file);
-- 2.13.0.18.g7d86cc8ba0