Fix sed -z P with test.

This commit is contained in:
Rob Landley 2022-09-13 08:29:28 -05:00
parent 5147183a21
commit f2f35fe829
2 changed files with 2 additions and 1 deletions

View File

@ -179,6 +179,7 @@ testcmd '-z' '-z "s/\n/-/g"' "a-b-c" "" "a\nb\nc"
testcmd '-z N' '-z N' 'one\0two\0' '' 'one\0two\0'
testcmd 'p noeol' '-z p' 'one\0one' '' 'one'
testcmd '-z N noeol' '-z N' 'one\0two' '' 'one\0two'
testcmd '-z S' "-z 'N;P'" 'one\0one\0two' '' 'one\0two'
# toybox handling of empty capturing groups broke minjail. Check that we
# correctly replace an empty capturing group with the empty string:

View File

@ -408,7 +408,7 @@ static void sed_line(char **pline, long plen)
// Pending append goes out right after N
goto done;
} else if (c=='p' || c=='P') {
char *l = (c=='P') ? strchr(line, '\n') : 0;
char *l = (c=='P') ? strchr(line, TT.delim) : 0;
if (emit(line, l ? l-line : len, eol)) break;
} else if (c=='q' || c=='Q') {