aboutsummaryrefslogtreecommitdiff
path: root/toys/net
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-24 16:12:34 -0700
committerRob Landley <rob@landley.net>2019-07-29 06:14:55 -0500
commite4dd5350882fde0cc82741e9b424037f35887f96 (patch)
tree4339470ca9d6ef9089f73356c5d10f5edf41af9b /toys/net
parent71bdf7a5ac09e4b52265b782623071b1cc6d32d7 (diff)
downloadtoybox-e4dd5350882fde0cc82741e9b424037f35887f96.tar.gz
grep: fake GNU behavior for non-POSIX empty regex.
POSIX says there's no such thing as an empty regular expression. The grammar excludes the possibility: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html BSD agrees with POSIX, and Android and macOS' BSD-based implementations reject the empty regular expression. GNU apparently disagrees. Luckily, BSD does accept the empty *sub* expression `()`, despite their error message for REG_EMPTY being "empty (sub)expression". This is presumably a bug, except there's explicit code to support it that is at least 26 years old: https://github.com/freebsd/freebsd/blame/master/lib/libc/regex/regcomp.c#L383 This workaround also works fine with glibc. If we want GNU behavior, I'm struggling to come up with another way to fake it. If we want POSIX behavior, we could easily just add a check to reject "" on glibc. Also switch to xregcomp().
Diffstat (limited to 'toys/net')
0 files changed, 0 insertions, 0 deletions