aboutsummaryrefslogtreecommitdiffstats
path: root/ex/ex_subst.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-10-01 04:25:54 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-10-01 04:25:54 +0000
commitb4ed613595432ece6802d09bfabad18e09aa26f3 (patch)
treebd2db6b09b756624c1b2babdd12ea05a9dffcdaf /ex/ex_subst.c
parent7cef6c685d23e4dcdf3f64b0b2ea92151e652db6 (diff)
downloadsrc-vendor/nvi.tar.gz
src-vendor/nvi.zip
Import nvi 2.2.0-05ed8b9vendor/nvi/2.2.0-05ed8b9vendor/nvi
This snapshot just brings a bunch of fixes in particular a fix for vi -w PR: 241985 Reported by: fernape
Notes
Notes: svn path=/vendor/nvi/dist/; revision=366307 svn path=/vendor/nvi/2.2.0-05ed8b9/; revision=366308; tag=vendor/nvi/2.2.0-05ed8b9
Diffstat (limited to 'ex/ex_subst.c')
-rw-r--r--ex/ex_subst.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/ex/ex_subst.c b/ex/ex_subst.c
index d32d583f6a3b..bf03e4417e91 100644
--- a/ex/ex_subst.c
+++ b/ex/ex_subst.c
@@ -115,11 +115,12 @@ subagain: return (ex_subagain(sp, cmdp));
*t = '\0';
break;
}
- if (p[0] == '\\')
+ if (p[0] == '\\') {
if (p[1] == delim)
++p;
else if (p[1] == '\\')
*t++ = *p++;
+ }
*t++ = *p++;
}
@@ -296,7 +297,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
* when the replacement is done. Don't change it unless you're *damned*
* confident.
*/
-#define NEEDNEWLINE(sp) { \
+#define NEEDNEWLINE(sp) do { \
if (sp->newl_len == sp->newl_cnt) { \
sp->newl_len += 25; \
REALLOC(sp, sp->newl, size_t *, \
@@ -306,9 +307,9 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
return (1); \
} \
} \
-}
+} while (0)
-#define BUILD(sp, l, len) { \
+#define BUILD(sp, l, len) do { \
if (lbclen + (len) > lblen) { \
lblen = p2roundup(MAX(lbclen + (len), 256)); \
REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \
@@ -319,9 +320,9 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
} \
MEMCPY(lb + lbclen, l, len); \
lbclen += len; \
-}
+} while (0)
-#define NEEDSP(sp, len, pnt) { \
+#define NEEDSP(sp, len, pnt) do { \
if (lbclen + (len) > lblen) { \
lblen = p2roundup(MAX(lbclen + (len), 256)); \
REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \
@@ -331,7 +332,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
} \
pnt = lb + lbclen; \
} \
-}
+} while (0)
static int
s(SCR *sp, EXCMD *cmdp, CHAR_T *s, regex_t *re, u_int flags)
@@ -584,7 +585,7 @@ nextmatch: match[0].rm_so = 0;
empty_ok = 1;
if (len == 0)
goto endmatch;
- BUILD(sp, s + offset, 1)
+ BUILD(sp, s + offset, 1);
++offset;
--len;
goto nextmatch;
@@ -710,7 +711,7 @@ skip: offset += match[0].rm_eo;
/* Copy the rest of the line. */
if (len)
- BUILD(sp, s + offset, len)
+ BUILD(sp, s + offset, len);
/* Set the new offset. */
offset = saved_offset;
@@ -736,7 +737,7 @@ skip: offset += match[0].rm_eo;
goto err;
if (db_get(sp, lno, DBG_FATAL, &s, &llen))
goto err;
- ADD_SPACE_RETW(sp, bp, blen, llen)
+ ADD_SPACE_RETW(sp, bp, blen, llen);
MEMCPY(bp, s, llen);
s = bp;
len = llen - offset;
@@ -779,7 +780,7 @@ endmatch: if (!linechanged)
/* Copy any remaining bytes into the build buffer. */
if (len)
- BUILD(sp, s + offset, len)
+ BUILD(sp, s + offset, len);
/* Store inserted lines, adjusting the build buffer. */
last = 0;
@@ -1333,7 +1334,7 @@ re_sub(
* Otherwise, since this is the lowest level of replacement, discard
* all escaping characters. This (hopefully) matches historic practice.
*/
-#define OUTCH(ch, nltrans) { \
+#define OUTCH(ch, nltrans) do { \
ARG_CHAR_T __ch = (ch); \
e_key_t __value = KEY_VAL(sp, __ch); \
if (nltrans && (__value == K_CR || __value == K_NL)) { \
@@ -1362,7 +1363,7 @@ re_sub(
NEEDSP(sp, 1, p); \
*p++ = __ch; \
++lbclen; \
-}
+} while (0)
conv = C_NOTSET;
for (rp = sp->repl, rpl = sp->repl_len, p = lb + lbclen; rpl--;) {
switch (ch = *rp++) {