Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 171374 | Differences between
and this patch

Collapse All | Expand All

(-)qgrep.c (-2 / +16 lines)
Lines 48-53 Link Here
48
	char buf0[BUFSIZ];
48
	char buf0[BUFSIZ];
49
	int reflags = REG_NOSUB;
49
	int reflags = REG_NOSUB;
50
	char invert_match = 0;
50
	char invert_match = 0;
51
	regex_t preg;
51
52
52
	typedef char *(*FUNC) (char *, char *);
53
	typedef char *(*FUNC) (char *, char *);
53
	FUNC strfunc = (FUNC) strstr;
54
	FUNC strfunc = (FUNC) strstr;
Lines 75-80 Link Here
75
	if (argc == optind)
76
	if (argc == optind)
76
		qgrep_usage(EXIT_FAILURE);
77
		qgrep_usage(EXIT_FAILURE);
77
78
79
	if (do_regex) {
80
		int ret;
81
		if ((ret = regcomp(&preg, argv[optind], reflags))) {
82
			char err[256];
83
			if (regerror(ret, &preg, err, sizeof(err)))
84
				errf("regcomp failed: %s", err);
85
			else
86
				err("regcomp failed");
87
		}
88
	}
89
78
	if (!do_eclass) {
90
	if (!do_eclass) {
79
		initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
91
		initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
80
		if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
92
		if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
Lines 118-130 Link Here
118
					if (do_regex == 0) {
130
					if (do_regex == 0) {
119
						if (( (FUNC *) (strfunc) (buf0, argv[optind])) == NULL) continue;
131
						if (( (FUNC *) (strfunc) (buf0, argv[optind])) == NULL) continue;
120
					} else {
132
					} else {
121
						if ((rematch(argv[optind], buf0, reflags)) != 0) continue;
133
						if (regexec(&preg, buf0, 0, NULL, 0) != 0) continue;
122
					}
134
					}
123
				} else {
135
				} else {
124
					if (do_regex == 0) {
136
					if (do_regex == 0) {
125
						if (( (FUNC *) (strfunc) (buf0, argv[optind])) != NULL) continue;
137
						if (( (FUNC *) (strfunc) (buf0, argv[optind])) != NULL) continue;
126
					} else {
138
					} else {
127
						if ((rematch(argv[optind], buf0, reflags)) == 0) continue;
139
						if (regexec(&preg, buf0, 0, NULL, 0) == 0) continue;
128
					}
140
					}
129
				}
141
				}
130
142
Lines 149-154 Link Here
149
		closedir(eclass_dir);
161
		closedir(eclass_dir);
150
	else
162
	else
151
		fclose(fp);
163
		fclose(fp);
164
	if (do_regex)
165
		regfree(&preg);
152
	return EXIT_SUCCESS;
166
	return EXIT_SUCCESS;
153
}
167
}
154
168

Return to bug 171374