ed

simple ed
git clone git://git.2f30.org/ed
Log | Files | Refs | LICENSE

commit f718cb55dbe87958c85185e9721b11e004026ce1
parent d07cc6e6353a8a76e5fcf9e7a81e757d165bf383
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 10 Dec 2015 22:16:31 +0100

Protect RE delimiter insied of brackets

When a delimiter appears inside of brackets it is not
considered like delimiter, but an element of the
character sequence.

Diffstat:
Med.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ed.c b/ed.c @@ -276,22 +276,27 @@ compile(int delim) { static char regerrbuf[BUFSIZ]; char *bp, buff[REGEXSIZE]; - int c ,ret; + int c ,ret, bracket = 0; if (!isgraph(delim)) error("invalid pattern delimiter"); for (bp = buff; bp < &buff[BUFSIZ-1]; *bp++ = c) { - if ((c = input()) == delim) + if ((c = input()) == delim && !bracket) break; if (c == '\n' || c == EOF) { back(c); break; } + if (c == '\\') { if (bp == &buff[BUFSIZ-2]) break; *bp++ = c; c = input(); + } else if (c == '[') { + bracket = 1; + } else if (c == ']') { + bracket = 0; } } if (bp == buff) {