diff options
author | Rob Landley <rob@landley.net> | 2019-05-06 13:16:24 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-05-06 13:16:24 -0500 |
commit | 48162c4ee3fb013c09cecea52c6403a33526f172 (patch) | |
tree | 26df11e4431a09f43784886fcc6199f2ec681b8a /lib/portability.h | |
parent | eb318d5b03223a8f2c5641ee45f9b28647bd3f47 (diff) | |
download | toybox-48162c4ee3fb013c09cecea52c6403a33526f172.tar.gz |
Greatly simplify and speed up regexec0() using REG_STARTEND.
This is a 15 year old freebsd extension (presumably thus also available on
MacOS) that glibc adopted in 2004, uClibc adopted in 2005, and bionic
supports. The only thing that DOESN'T support it is musl, once again
because its maintainer explicitly decided not to
(https://www.openwall.com/lists/musl/2013/01/15/26), so add an #ifdef
to let musl stay uniquely broken. (It'll stop at first NUL, everything
else can match NULs).
Finally fixes "s/x/y/g on a megabyte line of x's takes forever" issue.
Diffstat (limited to 'lib/portability.h')
-rw-r--r-- | lib/portability.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/portability.h b/lib/portability.h index 96458266..ccb1b1c5 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -6,6 +6,9 @@ // For musl #define _ALL_SOURCE +#ifndef REG_STARTEND +#define REG_STARTEND 0 +#endif #ifdef __APPLE__ // macOS 10.13 doesn't have the POSIX 2008 direct access to timespec in |