Mercurial > hg > toybox
changeset 1724:81d8a7b20ce9 draft
sed depends on -r to be rightmost flag to simplify the REG_EXTENDED test.
(If a flag is 1, you can multiply it by the value you want and get that value
else zero without a branch or conditional assignment.) So move -E one to the
left so FLAG_r is 1 again, and add a [+Er] suffix instead of testing
FLAG_r | FLAG_E in the users.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 06 Mar 2015 16:50:54 -0600 |
parents | 11d767f3fbb1 |
children | b2b2d214727a |
files | toys/posix/sed.c |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/posix/sed.c Fri Mar 06 15:12:52 2015 -0600 +++ b/toys/posix/sed.c Fri Mar 06 16:50:54 2015 -0600 @@ -7,7 +7,7 @@ * TODO: lines > 2G could signed int wrap length counters. Not just getline() * but N and s/// -USE_SED(NEWTOY(sed, "(version)e*f*inrE", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE)) +USE_SED(NEWTOY(sed, "(version)e*f*inEr[+Er]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE)) config SED bool "sed" @@ -804,7 +804,7 @@ if (!(s = unescape_delimited_string(&line, 0, 1))) goto brand; if (!*s) corwin->rmatch[i] = 0; else { - xregcomp((void *)reg, s, (toys.optflags & (FLAG_r | FLAG_E))*REG_EXTENDED); + xregcomp((void *)reg, s, (toys.optflags & FLAG_r)*REG_EXTENDED); corwin->rmatch[i] = reg-toybuf; reg += sizeof(regex_t); } @@ -898,7 +898,7 @@ // allocating the space was done by extend_string() above if (!*TT.remember) corwin->arg1 = 0; else xregcomp((void *)(corwin->arg1 + (char *)corwin), TT.remember, - ((toys.optflags & (FLAG_r | FLAG_E))*REG_EXTENDED)|((corwin->sflags&1)*REG_ICASE)); + ((toys.optflags & FLAG_r)*REG_EXTENDED)|((corwin->sflags&1)*REG_ICASE)); free(TT.remember); TT.remember = 0; if (*line == 'w') {