ed

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

commit 7796b6f7af5ae303f17d67ea073fc541c27f6da7
parent 13aeb0226d445fbf9e821699ae8ab67fd624489f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 13 Dec 2015 11:33:14 +0100

Add support for & in substitution

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

diff --git a/ed.c b/ed.c @@ -881,10 +881,21 @@ addpost(char **s, size_t *cap, size_t *siz) static void addsub(char **s, size_t *cap, size_t *siz) { - char *p, c; - - for (p = rhs; c = *p; ++p) - *s = addchar(c, *s, cap, siz); + char *end, *q, *p, c; + + for (p = rhs; c = *p; ++p) { + switch (c) { + case '&': + q = lastmatch + matchs[0].rm_so; + end = lastmatch + matchs[0].rm_eo; + while (q < end) + *s = addchar(*q++, *s, cap, siz); + break; + default: + *s = addchar(c, *s, cap, siz); + break; + } + } } static void