Skip to content

Commit 22c1f52

Browse files
committed
bin/xbps-query: actually report regex errors
1 parent 77fc4b4 commit 22c1f52

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

bin/xbps-query/ownedby.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,13 @@ ownedby(struct xbps_handle *xhp, const char *pat, bool repo, bool regex)
192192

193193
if (regex) {
194194
ffd.rematch = true;
195-
if (regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB|REG_ICASE) != 0)
195+
rv = regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB|REG_ICASE);
196+
if (rv != 0) {
197+
char errbuf[256];
198+
regerror(rv, &ffd.regex, errbuf, sizeof(errbuf));
199+
fprintf(stderr, "Failed to compile pattern: %s\n", errbuf);
196200
return EINVAL;
201+
}
197202
}
198203
if (repo)
199204
rv = xbps_rpool_foreach(xhp, repo_ownedby_cb, &ffd);

bin/xbps-query/search.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,15 @@ search(struct xbps_handle *xhp, bool repo_mode, const char *pat, const char *pro
225225

226226
sd.regex = regex;
227227
if (regex) {
228-
if (regcomp(&sd.regexp, pat, REG_EXTENDED|REG_NOSUB|REG_ICASE) != 0)
229-
return errno;
228+
rv = regcomp(&sd.regexp, pat, REG_EXTENDED|REG_NOSUB|REG_ICASE);
229+
if (rv != 0) {
230+
char errbuf[256];
231+
regerror(rv, &sd.regexp, errbuf, sizeof(errbuf));
232+
fprintf(stderr, "Failed to compile pattern: %s\n", errbuf);
233+
return EINVAL;
234+
}
230235
}
236+
231237
sd.repo_mode = repo_mode;
232238
sd.pat = pat;
233239
sd.prop = prop;

0 commit comments

Comments
 (0)