From d9b601e05630bc472c2f061d6d73b8a1ed415f90 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 15 Sep 2019 15:31:40 -0500 Subject: The ! changes I meant to check in last time were applied ot the wrong dir. (oops.) --- toys/posix/sed.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/posix/sed.c b/toys/posix/sed.c index d958ab70..1935417d 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -40,7 +40,7 @@ config SED apply only to the specified line(s). Commands without an address apply to every line. Addresses are of the form: - [ADDRESS[,ADDRESS]]COMMAND + [ADDRESS[,ADDRESS]][!]COMMAND The ADDRESS may be a decimal line number (starting at 1), a /regular expression/ within a pair of forward slashes, or the character "$" which @@ -69,6 +69,8 @@ config SED Each COMMAND starts with a single character. The following commands take no arguments: + ! Run this command when the test _didn't_ match. + { Start a new command block, continuing until a corresponding "}". Command blocks may nest. If the block has an address, commands within the block are only run for lines within the block's address range. @@ -821,11 +823,12 @@ static void parse_pattern(char **pline, long len) while (isspace(*line)) line++; if (!*line) break; - while (*line == '!') { + if (*line == '!') { command->not = 1; line++; } while (isspace(*line)) line++; + if (!*line) break; c = command->c = *(line++); if (strchr("}:", c) && i) break; -- cgit v1.2.3