From 6ecbd15d395be6ab383639ca273b56528bd76b9a Mon Sep 17 00:00:00 2001 From: Tobias Heider Date: Thu, 7 Sep 2023 11:17:33 +0000 Subject: 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@ --- usr.bin/vi/vi/v_paragraph.c | 13 +++++++++---- 1 file 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; \ + } \ } /* -- cgit v1.2.3