From 26ef841b19c9c329d33e9342c76f1a1a2e6c3bb5 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Mon, 23 Aug 2021 18:41:36 -0400 Subject: diff(1)-Add-color-support.patch: Fix formating --- diff-1-Add-color-support.patch | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/diff-1-Add-color-support.patch b/diff-1-Add-color-support.patch index 39d9451..72d90e7 100644 --- a/diff-1-Add-color-support.patch +++ b/diff-1-Add-color-support.patch @@ -1,4 +1,4 @@ -From 873c33e92f8a379c3f318f264b2f138658003530 Mon Sep 17 00:00:00 2001 +From 979b5ddf0d0c6436c160804a4cdd78e9da050e71 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Fri, 28 May 2021 15:21:45 -0400 Subject: [PATCH] diff(1): Add --color support @@ -7,8 +7,8 @@ Subject: [PATCH] diff(1): Add --color support usr.bin/diff/diff.1 | 17 ++++++++++ usr.bin/diff/diff.c | 70 +++++++++++++++++++++++++++++++++++++++++- usr.bin/diff/diff.h | 3 +- - usr.bin/diff/diffreg.c | 16 ++++++++++ - 4 files changed, 104 insertions(+), 2 deletions(-) + usr.bin/diff/diffreg.c | 18 ++++++++++- + 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1 index e0a790f6efb..50fd43902d5 100644 @@ -224,16 +224,16 @@ index b5536bd7bf7..5eccce51210 100644 extern struct excludes *excludes_list; extern regex_t ignore_re; diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c -index 651ec88df90..5f1b0d5ad94 100644 +index 651ec88df90..17aa2748ca4 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1183,13 +1183,23 @@ change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d, } } if (diff_format == D_SIDEBYSIDE) { -+ if (color && (a>b)) ++ if (color == 1 && (a > b)) + printf("\033[%sm", add_code); -+ else if (color && (c>d)) ++ else if (color == 1 && (c > d)) + printf("\033[%sm", del_code); if (a > b) { print_space(0, hw + padding , *pflags); @@ -241,12 +241,13 @@ index 651ec88df90..5f1b0d5ad94 100644 nc = fetch(ixold, a, b, f1, '\0', 1, *pflags); print_space(nc, hw - nc + padding, *pflags); } -+ if (color && (a>b)) +- printf("%c", (a>b)? '>' : ((c>d)? '<' : '|')); ++ if (color == 1 && (a > b)) + printf("\033[%sm", add_code); -+ else if (color && (c>d)) ++ else if (color == 1 && (c > d)) + printf("\033[%sm", del_code); - printf("%c", (a>b)? '>' : ((c>d)? '<' : '|')); -+ if (color && (c>d)) ++ printf("%c", (a > b) ? '>' : ((c > d) ? '<' : '|')); ++ if (color == 1 && (c > d)) + printf("\33[m"); print_space(hw + padding + 1 , padding, *pflags); fetch(ixnew, c, d, f2, '\0', 0, *pflags); @@ -255,9 +256,9 @@ index 651ec88df90..5f1b0d5ad94 100644 nc = hw; if ((diff_format != D_IFDEF && diff_format != D_GFORMAT) && ch != '\0') { -+ if (color && (ch == '>' || ch == '+')) ++ if (color == 1 && (ch == '>' || ch == '+')) + printf("\033[%sm", add_code); -+ else if (color && (ch == '<' || ch == '-')) ++ else if (color == 1 && (ch == '<' || ch == '-')) + printf("\033[%sm", del_code); printf("%c", ch); if (Tflag && (diff_format == D_NORMAL || @@ -266,7 +267,7 @@ index 651ec88df90..5f1b0d5ad94 100644 } } } -+ if (color) ++ if (color == 1) + printf("\33[m"); return col; } -- cgit v1.2.3-56-ge451