tex: zero-length matches and EOL - neatvi - [fork] simple vi-type editor with U… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit d820629569cdd2fcf7db0a9844e06963c02d5ff6 | |
parent fb4a84a4c678277646bd1873f1d75abd6b527ab7 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Fri, 23 Feb 2018 08:59:05 +0330 | |
ex: zero-length matches and EOL | |
Diffstat: | |
M ex.c | 6 +++--- | |
1 file changed, 3 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/ex.c b/ex.c | |
t@@ -719,10 +719,10 @@ static int ec_substitute(char *ec) | |
sbuf_mem(r, ln, offs[0]); | |
replace(r, rep, ln, offs); | |
ln += offs[1]; | |
- if (offs[1] <= 0) | |
- sbuf_chr(r, (unsigned char) *ln++); | |
- if (!strchr(s, 'g')) | |
+ if (!*ln || !strchr(s, 'g')) | |
break; | |
+ if (offs[1] <= 0) /* zero-length match */ | |
+ sbuf_chr(r, (unsigned char) *ln++); | |
} | |
sbuf_str(r, ln); | |
lbuf_edit(xb, sbuf_buf(r), i, i + 1); |