Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 113697 Details for
Bug 171374
app-portage/portage-utils - Misc enhancements for qgrep
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
qgrep-04_add_a_--with-name_option.patch
qgrep-04_add_a_--with-name_option.patch (text/plain), 3.40 KB, created by
TGL
on 2007-03-18 19:56:33 UTC
(
hide
)
Description:
qgrep-04_add_a_--with-name_option.patch
Filename:
MIME Type:
Creator:
TGL
Created:
2007-03-18 19:56:33 UTC
Size:
3.40 KB
patch
obsolete
>--- qgrep.c.03 2007-03-18 15:44:23.000000000 +0100 >+++ qgrep.c 2007-03-18 16:39:07.000000000 +0100 >@@ -10,11 +10,12 @@ > > #ifdef APPLET_qgrep > >-#define QGREP_FLAGS "IiHclLeEsS:" COMMON_FLAGS >+#define QGREP_FLAGS "IiHNclLeEsS:" COMMON_FLAGS > static struct option const qgrep_long_opts[] = { > {"invert-match", no_argument, NULL, 'I'}, > {"ignore-case", no_argument, NULL, 'i'}, > {"with-filename", no_argument, NULL, 'H'}, >+ {"with-name", no_argument, NULL, 'N'}, > {"count", no_argument, NULL, 'c'}, > {"list", no_argument, NULL, 'l'}, > {"invert-list", no_argument, NULL, 'L'}, >@@ -28,6 +29,7 @@ > "Select non-matching lines", > "Ignore case distinctions", > "Print the filename for each match", >+ "Print the package or eclass name for each match", > "Only print a count of matching lines per FILE", > "Only print FILE names containing matches", > "Only print FILE names containing no match", >@@ -46,11 +48,12 @@ > int count = 0; > char *p; > char do_count, do_regex, do_eclass, do_list; >- char show_filename, skip_comments, invert_list; >+ char show_filename, skip_comments, invert_list, show_name; > FILE *fp = NULL; > DIR *eclass_dir = NULL; > struct dirent *dentry; > char ebuild[_Q_PATH_MAX]; >+ char name[_Q_PATH_MAX]; > char buf0[BUFSIZ]; > int reflags = REG_NOSUB; > char invert_match = 0; >@@ -64,7 +67,7 @@ > argc, argv[0], argc > 1 ? argv[1] : "NULL?"); > > do_count = do_regex = do_eclass = do_list = 0; >- show_filename = skip_comments = invert_list = 0; >+ show_filename = skip_comments = invert_list = show_name = 0; > > while ((i = GETOPT_LONG(QGREP, qgrep, "")) != -1) { > switch (i) { >@@ -79,6 +82,7 @@ > case 'e': do_regex = 1; break; > case 'E': do_eclass = 1; break; > case 'H': show_filename = 1; break; >+ case 'N': show_name = 1; break; > case 's': skip_comments = 1; break; > case 'S': skip_pattern = optarg; break; > COMMON_GETOPTS_CASES(qgrep) >@@ -133,6 +137,28 @@ > if ((newfp = fopen(ebuild, "r")) != NULL) { > unsigned int lineno = 0; > count = 0; >+ >+ if (show_name) { >+ if (do_eclass) { >+ /* cut ".eclass" */ >+ *p = '\0'; >+ /* and skip "eclass/" */ >+ snprintf(name, sizeof(name), "%s", ebuild + 7); >+ } else { >+ /* cut ".ebuild" */ >+ *(p-7) = '\0'; >+ /* cut "/foo/" from "cat/foo/foo-x.y" */ >+ if ((p = strchr(ebuild, '/')) == NULL) >+ continue; >+ *(p++) = '\0'; >+ /* find head of the ebuild basename */ >+ if ((p = strchr(p, '/')) == NULL) >+ continue; >+ /* find start of the pkg name */ >+ snprintf(name, sizeof(name), "%s/%s", ebuild, ++p); >+ } >+ } >+ > while ((fgets(buf0, sizeof(buf0), newfp)) != NULL) { > lineno++; > if ((p = strrchr(buf0, '\n')) != NULL) >@@ -170,8 +196,8 @@ > > count++; > if (do_count || do_list) continue; >- if (verbose || show_filename) { >- printf("%s:", ebuild); >+ if (verbose || show_filename || show_name) { >+ printf("%s:", (show_name ? name : ebuild)); > if (verbose > 1) printf("%d:", lineno); > printf(" "); > } >@@ -179,11 +205,12 @@ > } > fclose(newfp); > if (do_count && count) { >- if (verbose || show_filename) printf("%s:", ebuild); >+ if (verbose || show_filename || show_name) >+ printf("%s:", (show_name ? name : ebuild)); > printf("%d", count); > puts(""); > } else if (do_list && ((count && !invert_list) || (!count && invert_list))) >- printf("%s\n", ebuild); >+ printf("%s\n", (show_name ? name : ebuild)); > } > } > if (do_eclass)
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 171374
:
113690
|
113693
|
113695
| 113697 |
113698
|
113699
|
113701
|
114221
|
114222
|
114281
|
114282
|
114944