sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 038dffaa5050cc0179340dabbe3a3a10c4cd61ef
parent 60ef169a18d52cfc09636ad5c92dfbb7d98588b0
Author: izabera <izaberina@gmail.com>
Date:   Sun, 14 Feb 2016 13:43:53 +0100

fix problems in sed

s/x/y/w file          <- chomp whitespace
s/x/y/1p              <- don't ignore first char after number
s[x[y[                <- [ is a valid delim

Diffstat:
Msed.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sed.c b/sed.c @@ -553,8 +553,8 @@ find_delim(char *s, Rune delim, int do_brackets) else if (state == BRACKETS_INSIDE && r == ']' ) { state = OUTSIDE ; } else if (state == OUTSIDE && escape ) { escape = 0 ; } else if (state == OUTSIDE && r == '\\' ) { escape = 1 ; } - else if (state == OUTSIDE && do_brackets && r == '[' ) { state = BRACKETS_OPENING; } else if (state == OUTSIDE && r == delim) return s; + else if (state == OUTSIDE && do_brackets && r == '[' ) { state = BRACKETS_OPENING; } } return s; } @@ -892,6 +892,7 @@ get_s_arg(Cmd *c, char *s) for (; s < p; s++) { if (isdigit(*s)) { c->u.s.occurrence = stol(s, &s); + s--; /* for loop will advance pointer */ } else { switch (*s) { case 'g': c->u.s.occurrence = 0; break; @@ -899,7 +900,7 @@ get_s_arg(Cmd *c, char *s) case 'w': /* must be last flag, take everything up to newline/semicolon * s == p after this */ - s = get_w_arg(&buf, s); + s = get_w_arg(&buf, chomp(s+1)); c->u.s.file = buf.u.file; break; }