summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2023-09-07 11:17:33 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2023-09-07 11:17:33 +0000
commit6ecbd15d395be6ab383639ca273b56528bd76b9a (patch)
tree92b73f7f05e4344a2e6198b318acf640fe18a6d9 /usr.bin/vi
parent59ecf77f4e3b4277213ad092759674958fe72f62 (diff)
Treat consecutive paragraph indicators as different paragraphs
Consecutive empty lines count toward the same state, so there're 2x states (to get in and out). ^L and .PP are counted as text, hitting those in the text should be treated as getting out of a paragraph and then getting in. From Walter Alejandro Iglesias and Zhihao Yuan in nvi2 ok bluhm@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/vi/v_paragraph.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/vi/vi/v_paragraph.c b/usr.bin/vi/vi/v_paragraph.c
index 23efd73904f..77422b080cc 100644
--- a/usr.bin/vi/vi/v_paragraph.c
+++ b/usr.bin/vi/vi/v_paragraph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_paragraph.c,v 1.9 2017/04/18 01:45:35 deraadt Exp $ */
+/* $OpenBSD: v_paragraph.c,v 1.10 2023/09/07 11:17:32 tobhe Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -41,15 +41,20 @@
if (p[0] == '\014') { \
if (!--cnt) \
goto found; \
+ if (pstate == P_INTEXT && !--cnt) \
+ goto found; \
continue; \
} \
if (p[0] != '.' || len < 2) \
continue; \
for (lp = VIP(sp)->ps; *lp != '\0'; lp += 2) \
if (lp[0] == p[1] && \
- ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) && \
- !--cnt) \
- goto found; \
+ (lp[1] == ' ' && len == 2 || lp[1] == p[2])) { \
+ if (!--cnt) \
+ goto found; \
+ if (pstate == P_INTEXT && !--cnt) \
+ goto found; \
+ } \
}
/*