From: Wolfgang Jenkner Date: Thu, 22 May 2008 16:33:54 +0200 Subject: Fix how keywords are picked up. Origin: upstream, https://repo.or.cz/nvi.git/commit/7ff00d30a4434354797effaa3d10504497586358 The way v_curword built up keywords starting with a non-word character was incompatible with historical tagstring search and POSIX. --- vi/vi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vi/vi.c b/vi/vi.c index a464304..47fccf2 100644 --- a/vi/vi.c +++ b/vi/vi.c @@ -1058,7 +1058,7 @@ v_dtoh(SCR *sp) /* * v_curword -- - * Get the word (or non-word) the cursor is on. + * Get the word (tagstring, actually) the cursor is on. * * PUBLIC: int v_curword __P((SCR *)); */ @@ -1067,7 +1067,7 @@ v_curword(SCR *sp) { VI_PRIVATE *vip; size_t beg, end, len; - int moved, state; + int moved; CHAR_T *p; if (db_get(sp, sp->lno, DBG_FATAL, &p, &len)) @@ -1089,7 +1089,7 @@ v_curword(SCR *sp) * follow the same rule. */ for (moved = 0, - beg = sp->cno; beg < len && isspace(p[beg]); moved = 1, ++beg); + beg = sp->cno; beg < len && ISSPACE(p[beg]); moved = 1, ++beg); if (beg >= len) { msgq(sp, M_BERR, "212|Cursor not in a word"); return (1); @@ -1099,9 +1099,14 @@ v_curword(SCR *sp) (void)vs_refresh(sp, 0); } - /* Find the end of the word. */ - for (state = inword(p[beg]), - end = beg; ++end < len && state == inword(p[end]);); + /* + * Find the end of the word. + * + * !!! + * Historically, vi accepted any non-blank as initial character + * when building up a tagstring. Required by IEEE 1003.1-2001. + */ + for (end = beg; ++end < len && inword(p[end]);); vip = VIP(sp); vip->klen = len = end - beg;