Lines 10-16
Link Here
|
10 |
|
10 |
|
11 |
#ifdef APPLET_qgrep |
11 |
#ifdef APPLET_qgrep |
12 |
|
12 |
|
13 |
#define QGREP_FLAGS "IiHceE" COMMON_FLAGS |
13 |
#define QGREP_FLAGS "IiHceEs" COMMON_FLAGS |
14 |
static struct option const qgrep_long_opts[] = { |
14 |
static struct option const qgrep_long_opts[] = { |
15 |
{"invert-match", no_argument, NULL, 'I'}, |
15 |
{"invert-match", no_argument, NULL, 'I'}, |
16 |
{"ignore-case", no_argument, NULL, 'i'}, |
16 |
{"ignore-case", no_argument, NULL, 'i'}, |
Lines 18-23
Link Here
|
18 |
{"count", no_argument, NULL, 'c'}, |
18 |
{"count", no_argument, NULL, 'c'}, |
19 |
{"regexp", no_argument, NULL, 'e'}, |
19 |
{"regexp", no_argument, NULL, 'e'}, |
20 |
{"eclass", no_argument, NULL, 'E'}, |
20 |
{"eclass", no_argument, NULL, 'E'}, |
|
|
21 |
{"skip-comments", no_argument, NULL, 's'}, |
21 |
COMMON_LONG_OPTS |
22 |
COMMON_LONG_OPTS |
22 |
}; |
23 |
}; |
23 |
static const char *qgrep_opts_help[] = { |
24 |
static const char *qgrep_opts_help[] = { |
Lines 27-31
Link Here
|
27 |
"Only print a count of matching lines per FILE", |
28 |
"Only print a count of matching lines per FILE", |
28 |
"Use PATTERN as a regular expression", |
29 |
"Use PATTERN as a regular expression", |
29 |
"Search in eclasses instead of ebuilds", |
30 |
"Search in eclasses instead of ebuilds", |
|
|
31 |
"Skip comments lines", |
30 |
COMMON_OPTS_HELP |
32 |
COMMON_OPTS_HELP |
31 |
}; |
33 |
}; |
Lines 38-44
Link Here
|
38 |
int count = 0; |
40 |
int count = 0; |
39 |
char *p; |
41 |
char *p; |
40 |
char do_count, do_regex, do_eclass; |
42 |
char do_count, do_regex, do_eclass; |
41 |
char show_filename; |
43 |
char show_filename, skip_comments; |
42 |
FILE *fp = NULL; |
44 |
FILE *fp = NULL; |
43 |
DIR *eclass_dir = NULL; |
45 |
DIR *eclass_dir = NULL; |
44 |
struct dirent *dentry; |
46 |
struct dirent *dentry; |
Lines 54-60
Link Here
|
54 |
DBG("argc=%d argv[0]=%s argv[1]=%s", |
56 |
DBG("argc=%d argv[0]=%s argv[1]=%s", |
55 |
argc, argv[0], argc > 1 ? argv[1] : "NULL?"); |
57 |
argc, argv[0], argc > 1 ? argv[1] : "NULL?"); |
56 |
|
58 |
|
57 |
do_count = do_regex = do_eclass = show_filename = 0; |
59 |
do_count = do_regex = do_eclass = show_filename = skip_comments = 0; |
58 |
|
60 |
|
59 |
while ((i = GETOPT_LONG(QGREP, qgrep, "")) != -1) { |
61 |
while ((i = GETOPT_LONG(QGREP, qgrep, "")) != -1) { |
60 |
switch (i) { |
62 |
switch (i) { |
Lines 67-72
Link Here
|
67 |
case 'e': do_regex = 1; break; |
69 |
case 'e': do_regex = 1; break; |
68 |
case 'E': do_eclass = 1; break; |
70 |
case 'E': do_eclass = 1; break; |
69 |
case 'H': show_filename = 1; break; |
71 |
case 'H': show_filename = 1; break; |
|
|
72 |
case 's': skip_comments = 1; break; |
70 |
COMMON_GETOPTS_CASES(qgrep) |
73 |
COMMON_GETOPTS_CASES(qgrep) |
71 |
} |
74 |
} |
72 |
} |
75 |
} |
Lines 107-112
Link Here
|
107 |
if ((p = strrchr(buf0, '\r')) != NULL) |
110 |
if ((p = strrchr(buf0, '\r')) != NULL) |
108 |
*p = 0; |
111 |
*p = 0; |
109 |
|
112 |
|
|
|
113 |
if (skip_comments) { |
114 |
p = buf0; |
115 |
while (*p == ' ' || *p == '\t') p++; |
116 |
if (*p == '#') continue; |
117 |
} |
118 |
|
110 |
if (!invert_match) { |
119 |
if (!invert_match) { |
111 |
if (do_regex == 0) { |
120 |
if (do_regex == 0) { |
112 |
if (( (FUNC *) (strfunc) (buf0, argv[optind])) == NULL) continue; |
121 |
if (( (FUNC *) (strfunc) (buf0, argv[optind])) == NULL) continue; |