tex: substitute's "g" option - neatvi - [fork] simple vi-type editor with UTF-8… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit dd8c8d2fd76f346bd04e372076310a59554ba5e3 | |
parent 0ef1f0ace31fa78cbfa79639ac5f719042c3c01b | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Sat, 6 Jun 2015 23:12:45 +0430 | |
ex: substitute's "g" option | |
Diffstat: | |
M ex.c | 15 +++++++++------ | |
1 file changed, 9 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/ex.c b/ex.c | |
t@@ -568,15 +568,18 @@ static int ec_substitute(char *ec) | |
return 1; | |
for (i = beg; i < end; i++) { | |
char *ln = lbuf_get(xb, i); | |
- if (rset_find(re, ln, LEN(offs) / 2, offs, 0)) { | |
- struct sbuf *r = sbuf_make(); | |
+ struct sbuf *r = sbuf_make(); | |
+ while (rset_find(re, ln, LEN(offs) / 2, offs, 0) >= 0) { | |
sbuf_mem(r, ln, offs[0]); | |
sbuf_str(r, rep); | |
- sbuf_str(r, ln + offs[1]); | |
- lbuf_put(xb, i, sbuf_buf(r)); | |
- lbuf_rm(xb, i + 1, i + 2); | |
- sbuf_free(r); | |
+ ln += offs[1]; | |
+ if (!strchr(s, 'g')) | |
+ break; | |
} | |
+ sbuf_str(r, ln); | |
+ lbuf_rm(xb, i, i + 1); | |
+ lbuf_put(xb, i, sbuf_buf(r)); | |
+ sbuf_free(r); | |
} | |
rset_free(re); | |
free(pat); |