[Toybox] [PATCH] sed: fix substitution of empty capturing groups.

enh enh at google.com
Tue Feb 12 16:35:36 PST 2019


The test for \N where N was larger than the number of capturing groups
in the regular expression was incorrect, and firing for cases such as
matching __(ARM_)?NR_([a-z]*) against __NR_read, where the first group is
empty (because it failed to match) but the second group did match "read".

Use regex_t's re_nsub for the error check, and treat rm_so == -1 as a
signal to just copy nothing into the result.

(Found trying to build minijail in AOSP.)
---
 tests/sed.test   | 11 +++++++++++
 toys/posix/sed.c | 10 +++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-sed-fix-substitution-of-empty-capturing-groups.patch
Type: text/x-patch
Size: 2976 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190212/0cde0445/attachment-0002.bin>


More information about the Toybox mailing list