Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 113699 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-06_take_additional_args_as_a_search_restriction.patch
qgrep-06_take_additional_args_as_a_search_restriction.patch (text/plain), 3.83 KB, created by
TGL
on 2007-03-18 19:58:00 UTC
(
hide
)
Description:
qgrep-06_take_additional_args_as_a_search_restriction.patch
Filename:
MIME Type:
Creator:
TGL
Created:
2007-03-18 19:58:00 UTC
Size:
3.83 KB
patch
obsolete
>--- qgrep.c.05 2007-03-18 17:01:10.000000000 +0100 >+++ qgrep.c 2007-03-18 19:12:19.000000000 +0100 >@@ -44,6 +44,35 @@ > static const char qgrep_rcsid[] = "$Id: qgrep.c,v 1.17 2007/03/17 20:53:23 solar Exp $"; > #define qgrep_usage(ret) usage(ret, QGREP_FLAGS, qgrep_long_opts, qgrep_opts_help, lookup_applet_idx("qgrep")) > >+char qgrep_name_match(const char*, const int, depend_atom**); >+char qgrep_name_match(const char* name, const int argc, depend_atom** argv) >+{ >+ depend_atom* atom; >+ int i; >+ >+ if ((atom = atom_explode(name)) == NULL) >+ return 0; >+ >+ for (i = 0; i < argc; i++) { >+ if (argv[i] == NULL) >+ continue; >+ if (atom->CATEGORY && argv[i]->CATEGORY && *(argv[i]->CATEGORY) >+ && strcmp(atom->CATEGORY, argv[i]->CATEGORY)) >+ continue; >+ if (atom->PN && argv[i]->PN && *(argv[i]->PN) >+ && strcmp(atom->PN, argv[i]->PN)) >+ continue; >+ if (atom->PVR && argv[i]->PVR && *(argv[i]->PVR) >+ && strcmp(atom->PVR, argv[i]->PVR)) >+ continue; >+ atom_implode(atom); >+ return 1; >+ } >+ >+ atom_implode(atom); >+ return 0; >+} >+ > int qgrep_main(int argc, char **argv) > { > int i; >@@ -61,6 +90,7 @@ > char invert_match = 0; > regex_t preg, skip_preg; > char *skip_pattern = NULL; >+ depend_atom** include_atoms = NULL; > > typedef char *(*FUNC) (char *, char *); > FUNC strfunc = (FUNC) strstr; >@@ -100,6 +130,13 @@ > if (do_list) > do_count = 0; > >+ if (argc > (optind + 1)) { >+ include_atoms = xcalloc(sizeof(depend_atom*), (argc - optind - 1)); >+ for (i = (optind + 1); i < argc; i++) >+ if ((include_atoms[i - optind - 1] = atom_explode(argv[i])) == NULL) >+ warnf("%s: invalid atom, will be ignored", argv[i]); >+ } >+ > if (do_regex) { > int ret; > char err[256]; >@@ -138,33 +175,46 @@ > continue; > if (strcmp(p, ".eclass")) > continue; >- } else if ((p = strchr(ebuild, '\n')) != NULL) >- *p = 0; >+ if (show_name || (include_atoms != NULL)) { >+ /* cut ".eclass" */ >+ *p = '\0'; >+ /* and skip "eclass/" */ >+ snprintf(name, sizeof(name), "%s", ebuild + 7); >+ /* restore the filepath */ >+ *p = '.'; >+ } >+ } else { >+ if ((p = strchr(ebuild, '\n')) != NULL) >+ *p = '\0'; >+ if (show_name || (include_atoms != NULL)) { >+ /* cut ".ebuild" */ >+ if (p == NULL) >+ p = ebuild + strlen(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+1)); >+ /* restore the filepath */ >+ *p = '/'; >+ *(p + strlen(p)) = '.'; >+ ebuild[strlen(ebuild)] = '/'; >+ } >+ } >+ >+ if (include_atoms != NULL) >+ if (!qgrep_name_match(name, (argc - optind - 1), include_atoms)) >+ continue; >+ > 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) >@@ -227,6 +277,12 @@ > regfree(&preg); > if (do_regex && skip_pattern) > regfree(&skip_preg); >+ if (include_atoms != NULL) { >+ for (i = 0; i < (argc - optind - 1); i++) >+ if (include_atoms[i] != NULL) >+ atom_implode(include_atoms[i]); >+ free(include_atoms); >+ } > return EXIT_SUCCESS; > } >
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