FreeBSD Bugzilla – Attachment 223725 Details for
Bug 254670
[patch] colorize filename in grep when -r and --color are given
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
grep patch
grep.patch (text/plain), 1.61 KB, created by
qorg
on 2021-03-31 07:57:05 UTC
(
hide
)
Description:
grep patch
Filename:
MIME Type:
Creator:
qorg
Created:
2021-03-31 07:57:05 UTC
Size:
1.61 KB
patch
obsolete
>diff -urN old/grep.c new/grep.c >--- old/grep.c 2021-03-31 07:32:11.406495000 +0000 >+++ new/grep.c 2021-03-31 07:34:43.308728000 +0000 >@@ -110,6 +110,7 @@ > bool nullflag; /* --null */ > char *label; /* --label */ > const char *color; /* --color */ >+const char *file_color; /* --color */ > int grepbehave = GREP_BASIC; /* -EFGP: type of the regex */ > int binbehave = BINFILE_BIN; /* -aIU: handling of binary files */ > int filebehave = FILE_STDIO; >@@ -582,8 +583,10 @@ > > term = getenv("TERM"); > if (isatty(STDOUT_FILENO) && term != NULL && >- strcasecmp(term, "dumb") != 0) >+ strcasecmp(term, "dumb") != 0) { > color = init_color("01;31"); >+ file_color = init_color("02;32"); >+ } > } else if (strcasecmp("always", optarg) == 0 || > strcasecmp("yes", optarg) == 0 || > strcasecmp("force", optarg) == 0) { >diff -urN old/grep.h new/grep.h >--- old/grep.h 2021-03-31 07:32:11.406994000 +0000 >+++ new/grep.h 2021-03-31 07:30:13.436572000 +0000 >@@ -126,6 +126,7 @@ > extern char fileeol; > extern char *label; > extern const char *color; >+extern const char *file_color; > extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave; > > extern bool file_err, matchall; >diff -urN old/util.c new/util.c >--- old/util.c 2021-03-31 07:32:11.407414000 +0000 >+++ new/util.c 2021-03-31 07:38:57.873229000 +0000 >@@ -714,7 +714,11 @@ > printsep = false; > if (!hflag) { > if (!nullflag) { >+ if (color) >+ fprintf(stdout, "\33[%sm\33[K", file_color); > fputs(line->file, stdout); >+ if (color) >+ fprintf(stdout, "\33[m\33[K"); > printsep = true; > } else { > printf("%s", line->file);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 254670
: 223725