From 7ff00d30a4434354797effaa3d10504497586358 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Thu, 22 May 2008 16:33:54 +0200 Subject: [PATCH] Fix how keywords are picked up. 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 6b148b25..11900f85 100644 --- a/vi/vi.c +++ b/vi/vi.c @@ -1050,7 +1050,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 *)); */ @@ -1059,7 +1059,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)) @@ -1081,7 +1081,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); @@ -1091,9 +1091,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; -- 2.11.4.GIT