[Toybox] [PATCH] xregcomp: add the specific regex we couldn't parse to the error message.

Rob Landley rob at landley.net
Sat Nov 7 00:27:59 PST 2020


On 11/6/20 12:34 PM, enh via Toybox wrote:
> 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.

Always up for better error reporting. (I'll argue about the definition of
"better" sometimes, of course. :)

> 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.

I note that I just implemented (most of, +() and friends are still stubs because
$DAYJOB) a fnmatch() implementation, and could probably do regex if provoked. :)

I was leaving this to libc because I could, and it worked, but Rich has proved
reluctant to fix regex stuff in musl at least twice now...

> 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.)

Got a bug report, handled the bug report. :)

And tests/grep.test has tests for because I struggled with getting that behavior
to match at the time.

(I thought I'd blogged about it, but both my 2015 and 2016 blogs cut off halfway
through the year as I fell behind and didn't post them, and the copies I have on
this laptop are the ones that went up. I hope I still have the files I didn't
edit and post somewhere, but they're not with me in tokyo. I remember I was
working out the proper behavior with my laptop on a bus having taken the slighly
wrong route back from the airport, and having a half-hour layover at some ACC
campus before the bus continued on. According to git annotate the empty regex
test was checked in november 2015, so that would be one of my early flights back
from tokyo. Alas nothing obvious in my twitter from that time... other than a
new TODO item that if I ever get my twitter account back I need to reply to
https://twitter.com/MitchBenn/status/685481547567378432 with a picture of Tilda
Swinton as the 13th Dave.)

Rob



More information about the Toybox mailing list