ed

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

commit 2ddf19b7be2f1f680c52341017f6d83d56ae106a
parent 03b9f92b5de90422f33b29c45629a3932e31a7b0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 10 Dec 2015 19:53:46 +0100

Add delimeter parameter to compile()

This new parameter admits any graph character,
and it allows to follow the same criteria for
all the regular expressions, not only in the case
of 's' commands.

Diffstat:
Med.c | 22++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/ed.c b/ed.c @@ -262,15 +262,18 @@ setscratch() } static void -compile() +compile(int delim) { static char regerrbuf[BUFSIZ]; - char *bp, delim, buff[REGEXSIZE]; + char *bp, buff[REGEXSIZE]; int c ,ret; - delim = input(); + if (!isgraph(delim)) + error("invalid pattern delimiter"); for (bp = buff; bp < &buff[BUFSIZ-1]; *bp++ = c) { - if ((c = input()) == delim || c == '\n' || c == EOF) { + if ((c = input()) == delim) + break; + if (c == '\n' || c == EOF) { back(c); break; } @@ -307,7 +310,7 @@ match(int way) i = curln; do { - i = (way == '/') ? nextln(i) : prevln(i); + i = (way == '?') ? prevln(i) : nextln(i); if (!regexec(pattern, gettxt(i), 0, NULL, 0)) return i; } while (i != curln); @@ -368,8 +371,7 @@ linenum(int *line) break; case '?': case '/': - back(c); - compile(); + compile(c); ln = match(c); break; case '-': @@ -949,7 +951,7 @@ save_last_cmd: static int chkglobal(void) { - int c, nmatch, i; + int delim, c, nmatch, i; uflag = 1; skipblank(); @@ -970,8 +972,8 @@ chkglobal(void) return 0; } deflines(nextln(0), lastln); - compile(); - input(); /* skip trailing '/' */ + delim = input(); + compile(delim); for (i = line1; i <= line2; i++) setglobal(i, nmatch);