ed

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

commit 0b44f0720c8836ce86b98176edfff377de2d3959
parent 80a8c2d192e1c37ac792ce892eb63a8aea992959
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 12 Dec 2015 21:29:40 +0100

Add aditional parameter to match()

This parameter will be used in subs(),
where we want to substitue the nth ocurrence
of the regular expression.

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

diff --git a/ed.c b/ed.c @@ -26,6 +26,7 @@ struct hline { char *prompt = "*"; regex_t *pattern; +regmatch_t matchs[10]; char *lastre; int optverbose, optprompt, exstatus, optdiag = 1; @@ -318,9 +319,9 @@ compile(int delim) } static int -match(int num) +match(int num, int flags) { - return !regexec(pattern, gettxt(num), 0, NULL, 0); + return !regexec(pattern, gettxt(num), 10, matchs, flags); } static int @@ -331,7 +332,7 @@ search(int way) i = curln; do { i = (way == '?') ? prevln(i) : nextln(i); - if (match(i)) + if (match(i, 0)) return i; } while (i != curln); @@ -1148,7 +1149,7 @@ chkglobal(void) compile(delim); for (i = 1; i <= lastln; i = nextln(i)) { - v = i >= line1 && i <= line2 && match(i) == dir; + v = i >= line1 && i <= line2 && match(i, 0) == dir; setglobal(i, v); }