aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-11-06 10:25:37 -0800
committerRob Landley <rob@landley.net>2020-11-07 01:54:01 -0600
commite1a5111cbbfe18707fb26a65ed7af654f30a132c (patch)
tree7b2d9a38baa0230fbee47914e164f1f578e23677 /lib
parent90c4e155dd0acf79f4f725c9dcd985304824c156 (diff)
downloadtoybox-e1a5111cbbfe18707fb26a65ed7af654f30a132c.tar.gz
xregcomp: add the specific regex we couldn't parse to the error message.
This makes it more likely that you can actually debug something like "sed: bad regex: empty (sub)expression" or "sed: bad regex: parentheses not balanced" from a build failure log, where you don't necessarily know where the failure came from. This also seems like it might be useful generally, although GNU grep doesn't include this detail in its error messages, and busybox doesn't even seem to notice that regcomp() failed? (Realistically if the Android build team wants to move forward with "one true regex implementation", we're going to have to add some GNU-isms to the Android regex implementation. But we'd need to find them first! Note that the two examples given above are real examples from failed buildbot builds, but they occur early in the respective builds so there are likely many more to look at after these. Interestingly, the first of the two appears to be the more general case of something disallowed by POSIX that xregcomp() already has a workaround for.)
Diffstat (limited to 'lib')
-rw-r--r--lib/xwrap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index e75fa811..26fcb8df 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -938,7 +938,7 @@ void xregcomp(regex_t *preg, char *regex, int cflags)
if ((rc = regcomp(preg, regex, cflags))) {
regerror(rc, preg, libbuf, sizeof(libbuf));
- error_exit("bad regex: %s", libbuf);
+ error_exit("bad regex '%s': %s", regex, libbuf);
}
}