From 9bba069e63e36bcad6658c8028afa2f142d3a0f5 Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 16 Jun 2026 22:59:03 +0000 Subject: [PATCH] Make the behavior of the '(' command match the ')' command. Previously, the ')' command required a sentence to end with two blanks, but '(' only required a single space. Historic vi (and the documentation) requires two spaces in both directions. Based on a diff from Walter Alejandro Iglesias. --- usr.bin/vi/vi/v_sentence.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.bin/vi/vi/v_sentence.c b/usr.bin/vi/vi/v_sentence.c index 86136bf3721..9ce4df531d4 100644 --- a/usr.bin/vi/vi/v_sentence.c +++ b/usr.bin/vi/vi/v_sentence.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_sentence.c,v 1.12 2026/06/16 02:15:14 millert Exp $ */ +/* $OpenBSD: v_sentence.c,v 1.13 2026/06/16 22:59:03 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -219,7 +219,7 @@ v_sentenceb(SCR *sp, VICMD *vp) recno_t slno; size_t len, scno; u_long cnt; - int last; + int last, next; /* * !!! @@ -263,7 +263,7 @@ v_sentenceb(SCR *sp, VICMD *vp) break; } - for (last = 0;;) { + for (last = 0, next = '\0';;) { if (cs_prev(sp, &cs)) return (1); if (cs.cs_flags == CS_SOF) /* SOF is a movement sink. */ @@ -346,7 +346,12 @@ ret: slno = cs.cs_lno; cs.cs_flags == CS_EOL || isblank(cs.cs_ch) || cs.cs_ch == ')' || cs.cs_ch == ']' || cs.cs_ch == '"' || cs.cs_ch == '\'' ? 1 : 0; + + /* A sentence ends with two spaces. */ + if (cs.cs_ch == ' ' && next != ' ') + last = 0; } + next = cs.cs_ch; } okret: vp->m_stop.lno = cs.cs_lno;