Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 466030
Collapse All | Expand All

(-)nvi-1.81.6/common/common.h (-1 / +1 lines)
Lines 57-63 Link Here
57
typedef struct _win		WIN;
57
typedef struct _win		WIN;
58
58
59
/* Autoindent state. */
59
/* Autoindent state. */
60
typedef enum { C_NOTSET, C_CARATSET, C_NOCHANGE, C_ZEROSET } carat_t;
60
typedef enum { C_NOTSET, C_CARATSET, C_ZEROSET } carat_t;
61
61
62
/* Busy message types. */
62
/* Busy message types. */
63
typedef enum { BUSY_ON = 1, BUSY_OFF, BUSY_UPDATE } busy_t;
63
typedef enum { BUSY_ON = 1, BUSY_OFF, BUSY_UPDATE } busy_t;
(-)nvi-1.81.6/common/conv.c (-2 / +2 lines)
Lines 89-95 Link Here
89
default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, 
89
default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, 
90
		size_t *tolen, CHAR_T **dst, char *enc)
90
		size_t *tolen, CHAR_T **dst, char *enc)
91
{
91
{
92
    int i = 0, j;
92
    size_t i = 0, j;
93
    CHAR_T **tostr = (CHAR_T **)&cw->bp1;
93
    CHAR_T **tostr = (CHAR_T **)&cw->bp1;
94
    size_t  *blen = &cw->blen1;
94
    size_t  *blen = &cw->blen1;
95
    mbstate_t mbs;
95
    mbstate_t mbs;
Lines 210-216 Link Here
210
default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, 
210
default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, 
211
		size_t *tolen, char **pdst, char *enc)
211
		size_t *tolen, char **pdst, char *enc)
212
{
212
{
213
    int i, j, offset = 0;
213
    size_t i, j, offset = 0;
214
    char **tostr = (char **)&cw->bp1;
214
    char **tostr = (char **)&cw->bp1;
215
    size_t  *blen = &cw->blen1;
215
    size_t  *blen = &cw->blen1;
216
    mbstate_t mbs;
216
    mbstate_t mbs;
(-)nvi-1.81.6/common/cut.c (-21 / +21 lines)
Lines 101-115 Link Here
101
			copy_one = 1;
101
			copy_one = 1;
102
			cb_rotate(sp);
102
			cb_rotate(sp);
103
		}
103
		}
104
		if ((append = isupper(name)) == 1) {
104
		if ((append = isupper(name))) {
105
			if (!copy_one)
105
			if (!copy_one)
106
				copy_def = 1;
106
				copy_def = 1;
107
			name = tolower(name);
107
			name = TOLOWER(name);
108
		}
108
		}
109
namecb:		CBNAME(sp, cbp, name);
109
namecb:		CBNAME(sp, cbp, name);
110
	} else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
110
	} else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
111
	    (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
111
	    (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
112
		name = '1';
112
		name = L('1');
113
		cb_rotate(sp);
113
		cb_rotate(sp);
114
		goto namecb;
114
		goto namecb;
115
	} else
115
	} else
Lines 163-169 Link Here
163
	sp->wp->dcbp = cbp;	/* Repoint the default buffer on each pass. */
163
	sp->wp->dcbp = cbp;	/* Repoint the default buffer on each pass. */
164
164
165
	if (copy_one) {		/* Copy into numeric buffer 1. */
165
	if (copy_one) {		/* Copy into numeric buffer 1. */
166
		name = '1';
166
		name = L('1');
167
		CBNAME(sp, cbp, name);
167
		CBNAME(sp, cbp, name);
168
		copy_one = 0;
168
		copy_one = 0;
169
		goto copyloop;
169
		goto copyloop;
Lines 194-224 Link Here
194
	del_cbp = NULL;
194
	del_cbp = NULL;
195
	for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next)
195
	for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next)
196
		switch(cbp->name) {
196
		switch(cbp->name) {
197
		case '1':
197
		case L('1'):
198
			cbp->name = '2';
198
			cbp->name = L('2');
199
			break;
199
			break;
200
		case '2':
200
		case L('2'):
201
			cbp->name = '3';
201
			cbp->name = L('3');
202
			break;
202
			break;
203
		case '3':
203
		case L('3'):
204
			cbp->name = '4';
204
			cbp->name = L('4');
205
			break;
205
			break;
206
		case '4':
206
		case L('4'):
207
			cbp->name = '5';
207
			cbp->name = L('5');
208
			break;
208
			break;
209
		case '5':
209
		case L('5'):
210
			cbp->name = '6';
210
			cbp->name = L('6');
211
			break;
211
			break;
212
		case '6':
212
		case L('6'):
213
			cbp->name = '7';
213
			cbp->name = L('7');
214
			break;
214
			break;
215
		case '7':
215
		case L('7'):
216
			cbp->name = '8';
216
			cbp->name = L('8');
217
			break;
217
			break;
218
		case '8':
218
		case L('8'):
219
			cbp->name = '9';
219
			cbp->name = L('9');
220
			break;
220
			break;
221
		case '9':
221
		case L('9'):
222
			del_cbp = cbp;
222
			del_cbp = cbp;
223
			break;
223
			break;
224
		}
224
		}
(-)nvi-1.81.6/common/cut.h (-1 / +1 lines)
Lines 65-71 Link Here
65
 */
65
 */
66
#define	CBNAME(sp, cbp, nch) {						\
66
#define	CBNAME(sp, cbp, nch) {						\
67
	CHAR_T L__name;							\
67
	CHAR_T L__name;							\
68
	L__name = isupper(nch) ? tolower(nch) : (nch);			\
68
	L__name = ISUPPER(nch) ? TOLOWER(nch) : (nch);			\
69
	for (cbp = sp->wp->cutq.lh_first;				\
69
	for (cbp = sp->wp->cutq.lh_first;				\
70
	    cbp != NULL; cbp = cbp->q.le_next)				\
70
	    cbp != NULL; cbp = cbp->q.le_next)				\
71
		if (cbp->name == L__name)				\
71
		if (cbp->name == L__name)				\
(-)nvi-1.81.6/common/key.h (+4 lines)
Lines 51-56 Link Here
51
    iswalpha((ch))
51
    iswalpha((ch))
52
#define ISALNUM(ch) \
52
#define ISALNUM(ch) \
53
    iswalnum((ch))
53
    iswalnum((ch))
54
#define ISSPACE(ch) \
55
    iswspace((ch))
54
#define CHAR_WIDTH(sp, ch)  wcwidth(ch)
56
#define CHAR_WIDTH(sp, ch)  wcwidth(ch)
55
#define INTISWIDE(c)	(!!(c >> 8))	    /* XXX wrong name */
57
#define INTISWIDE(c)	(!!(c >> 8))	    /* XXX wrong name */
56
#define WS		"%ls"
58
#define WS		"%ls"
Lines 82-87 Link Here
82
    isalpha((ch))
84
    isalpha((ch))
83
#define ISALNUM(ch) \
85
#define ISALNUM(ch) \
84
    isalnum((ch))
86
    isalnum((ch))
87
#define ISSPACE(ch) \
88
    isspace((ch))
85
#define INTISWIDE(c)	    0
89
#define INTISWIDE(c)	    0
86
#define CHAR_WIDTH(sp, ch)  1
90
#define CHAR_WIDTH(sp, ch)  1
87
#define WS		"%s"
91
#define WS		"%s"
(-)nvi-1.81.6/common/multibyte.h (+12 lines)
Lines 12-23 Link Here
12
typedef	u_int		UCHAR_T;
12
typedef	u_int		UCHAR_T;
13
#define RCHAR_BIT	24
13
#define RCHAR_BIT	24
14
14
15
#define ISUPPER		iswupper
15
#define STRLEN		wcslen
16
#define STRLEN		wcslen
16
#define STRTOL		wcstol
17
#define STRTOL		wcstol
17
#define STRTOUL		wcstoul
18
#define STRTOUL		wcstoul
18
#define SPRINTF		swprintf
19
#define SPRINTF		swprintf
20
#define STRCHR		wcschr
19
#define STRCMP		wcscmp
21
#define STRCMP		wcscmp
20
#define STRPBRK		wcspbrk
22
#define STRPBRK		wcspbrk
23
#define TOLOWER		towlower
21
#define TOUPPER		towupper
24
#define TOUPPER		towupper
22
#define STRSET		wmemset
25
#define STRSET		wmemset
23
26
Lines 31-42 Link Here
31
typedef	u_char		UCHAR_T;
34
typedef	u_char		UCHAR_T;
32
#define RCHAR_BIT	CHAR_BIT
35
#define RCHAR_BIT	CHAR_BIT
33
36
37
#define ISUPPER		isupper
34
#define STRLEN		strlen
38
#define STRLEN		strlen
35
#define STRTOL		strtol
39
#define STRTOL		strtol
36
#define STRTOUL		strtoul
40
#define STRTOUL		strtoul
37
#define SPRINTF		snprintf
41
#define SPRINTF		snprintf
42
#define STRCHR		strchr
38
#define STRCMP		strcmp
43
#define STRCMP		strcmp
39
#define STRPBRK		strpbrk
44
#define STRPBRK		strpbrk
45
#define TOLOWER		tolower
40
#define TOUPPER		toupper
46
#define TOUPPER		toupper
41
#define STRSET		memset
47
#define STRSET		memset
42
48
Lines 48-53 Link Here
48
	memcmp(to, from, (n) * sizeof(*(to)))
54
	memcmp(to, from, (n) * sizeof(*(to)))
49
#define	MEMMOVE(p, t, len)	memmove(p, t, (len) * sizeof(*(p)))
55
#define	MEMMOVE(p, t, len)	memmove(p, t, (len) * sizeof(*(p)))
50
#define	MEMCPY(p, t, len)	memcpy(p, t, (len) * sizeof(*(p)))
56
#define	MEMCPY(p, t, len)	memcpy(p, t, (len) * sizeof(*(p)))
57
/*
58
 * Like MEMCPY but return a pointer to the end of the copied bytes.
59
 * Glibc has a function mempcpy with the same purpose.
60
 */
61
#define MEMPCPY(p, t, len) \
62
	((void *)((char *)MEMCPY(p, t, len) + (len) * sizeof(*(p))))
51
#define SIZE(w)		(sizeof(w)/sizeof(*w))
63
#define SIZE(w)		(sizeof(w)/sizeof(*w))
52
64
53
#endif
65
#endif
(-)nvi-1.81.6/common/recover.c (-1 / +1 lines)
Lines 565-571 Link Here
565
next:		(void)fclose(fp);
565
next:		(void)fclose(fp);
566
	}
566
	}
567
	if (found == 0)
567
	if (found == 0)
568
		(void)printf("vi: no files to recover.\n");
568
		(void)printf("%s: No files to recover\n", sp->gp->progname);
569
	(void)closedir(dirp);
569
	(void)closedir(dirp);
570
	return (0);
570
	return (0);
571
}
571
}
(-)nvi-1.81.6/common/search.c (-2 / +2 lines)
Lines 117-124 Link Here
117
117
118
	/* Compile the RE. */
118
	/* Compile the RE. */
119
	if (re_compile(sp, ptrn, plen, &sp->re, &sp->re_len, &sp->re_c,
119
	if (re_compile(sp, ptrn, plen, &sp->re, &sp->re_len, &sp->re_c,
120
	    SEARCH_CSEARCH | LF_ISSET(SEARCH_CSCOPE | SEARCH_IC |
120
	    SEARCH_CSEARCH | LF_ISSET(SEARCH_CSCOPE | SEARCH_EXTEND |
121
	    SEARCH_LITERAL | SEARCH_MSG | SEARCH_TAG)))
121
	    SEARCH_IC | SEARCH_LITERAL | SEARCH_MSG | SEARCH_TAG)))
122
		return (1);
122
		return (1);
123
123
124
	/* Set the search direction. */
124
	/* Set the search direction. */
(-)nvi-1.81.6/common/util.c (-1 / +1 lines)
Lines 92-98 Link Here
92
		return (0);
92
		return (0);
93
93
94
	for (cnt = off, p = &p[off],
94
	for (cnt = off, p = &p[off],
95
	    len -= off; len && isblank(*p); ++cnt, ++p, --len);
95
	    len -= off; len && ISBLANK(*p); ++cnt, ++p, --len);
96
96
97
	/* Set the return. */
97
	/* Set the return. */
98
	*cnop = len ? cnt : cnt - 1;
98
	*cnop = len ? cnt : cnt - 1;
(-)nvi-1.81.6/ex/ex_argv.c (-3 / +3 lines)
Lines 105-111 Link Here
105
	/* If it's empty, we're done. */
105
	/* If it's empty, we're done. */
106
	if (len != 0) {
106
	if (len != 0) {
107
		for (p = bp, t = bp + len; p < t; ++p)
107
		for (p = bp, t = bp + len; p < t; ++p)
108
			if (!isblank(*p))
108
			if (!ISBLANK(*p))
109
				break;
109
				break;
110
		if (p == t)
110
		if (p == t)
111
			goto ret;
111
			goto ret;
Lines 186-192 Link Here
186
					break;
186
					break;
187
		} else
187
		} else
188
			for (; n > 0; --n, ++p)
188
			for (; n > 0; --n, ++p)
189
				if (!isblank(*p) &&
189
				if (!ISBLANK(*p) &&
190
				    !isalnum(*p) && strchr(mp, *p) != NULL)
190
				    !isalnum(*p) && strchr(mp, *p) != NULL)
191
					break;
191
					break;
192
	}
192
	}
Lines 739-745 Link Here
739
		rval = SEXP_EXPANSION_ERR;
739
		rval = SEXP_EXPANSION_ERR;
740
740
741
	for (p = bp; len; ++p, --len)
741
	for (p = bp; len; ++p, --len)
742
		if (!isblank(*p))
742
		if (!ISBLANK(*p))
743
			break;
743
			break;
744
	if (len == 0)
744
	if (len == 0)
745
		rval = SEXP_EXPANSION_ERR;
745
		rval = SEXP_EXPANSION_ERR;
(-)nvi-1.81.6/ex/ex_display.c (-21 / +25 lines)
Lines 25-30 Link Here
25
#include "../common/common.h"
25
#include "../common/common.h"
26
#include "tag.h"
26
#include "tag.h"
27
27
28
static int	is_prefix __P((ARGS *, CHAR_T *));
28
static int	bdisplay __P((SCR *));
29
static int	bdisplay __P((SCR *));
29
static void	db __P((SCR *, CB *, u_char *));
30
static void	db __P((SCR *, CB *, u_char *));
30
31
Lines 38-70 Link Here
38
int
39
int
39
ex_display(SCR *sp, EXCMD *cmdp)
40
ex_display(SCR *sp, EXCMD *cmdp)
40
{
41
{
41
	switch (cmdp->argv[0]->bp[0]) {
42
	ARGS *arg;
42
	case 'b':
43
43
#undef	ARG
44
	arg = cmdp->argv[0];
44
#define	ARG	"buffers"
45
45
		if (cmdp->argv[0]->len >= sizeof(ARG) ||
46
	switch (arg->bp[0]) {
46
		    memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
47
	case L('b'):
48
		if (!is_prefix(arg, L("buffers")))
47
			break;
49
			break;
48
		return (bdisplay(sp));
50
		return (bdisplay(sp));
49
	case 'c':
51
	case L('c'):
50
#undef	ARG
52
		if (!is_prefix(arg, L("connections")))
51
#define	ARG	"connections"
52
		if (cmdp->argv[0]->len >= sizeof(ARG) ||
53
		    memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
54
			break;
53
			break;
55
		return (cscope_display(sp));
54
		return (cscope_display(sp));
56
	case 's':
55
	case L('s'):
57
#undef	ARG
56
		if (!is_prefix(arg, L("screens")))
58
#define	ARG	"screens"
59
		if (cmdp->argv[0]->len >= sizeof(ARG) ||
60
		    memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
61
			break;
57
			break;
62
		return (ex_sdisplay(sp));
58
		return (ex_sdisplay(sp));
63
	case 't':
59
	case L('t'):
64
#undef	ARG
60
		if (!is_prefix(arg, L("tags")))
65
#define	ARG	"tags"
66
		if (cmdp->argv[0]->len >= sizeof(ARG) ||
67
		    memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
68
			break;
61
			break;
69
		return (ex_tag_display(sp));
62
		return (ex_tag_display(sp));
70
	}
63
	}
Lines 73-78 Link Here
73
}
66
}
74
67
75
/*
68
/*
69
 * is_prefix --
70
 *
71
 *	Check that a command argument matches a prefix of a given string.
72
 */
73
static int
74
is_prefix(ARGS *arg, CHAR_T *str)
75
{
76
	return arg->len <= STRLEN(str) && !MEMCMP(arg->bp, str, arg->len);
77
}
78
79
/*
76
 * bdisplay --
80
 * bdisplay --
77
 *
81
 *
78
 *	Display buffers.
82
 *	Display buffers.
(-)nvi-1.81.6/ex/ex_join.c (-4 / +5 lines)
Lines 36-44 Link Here
36
{
36
{
37
	db_recno_t from, to;
37
	db_recno_t from, to;
38
	size_t blen, clen, len, tlen;
38
	size_t blen, clen, len, tlen;
39
	int echar, extra, first;
39
	int extra, first;
40
	CHAR_T *bp, *tbp;
40
	CHAR_T *bp, *tbp;
41
	CHAR_T *p;
41
	CHAR_T *p;
42
	CHAR_T echar;
42
43
43
	NEEDFILE(sp, cmdp);
44
	NEEDFILE(sp, cmdp);
44
45
Lines 103-110 Link Here
103
		 */
104
		 */
104
		extra = 0;
105
		extra = 0;
105
		if (!first && !FL_ISSET(cmdp->iflags, E_C_FORCE)) {
106
		if (!first && !FL_ISSET(cmdp->iflags, E_C_FORCE)) {
106
			if (isblank(echar))
107
			if (ISBLANK(echar))
107
				for (; len && isblank(*p); --len, ++p);
108
				for (; len && ISBLANK(*p); --len, ++p);
108
			else if (p[0] != ')') {
109
			else if (p[0] != ')') {
109
				if (strchr(".?!", echar)) {
110
				if (strchr(".?!", echar)) {
110
					*tbp++ = ' ';
111
					*tbp++ = ' ';
Lines 113-119 Link Here
113
				}
114
				}
114
				*tbp++ = ' ';
115
				*tbp++ = ' ';
115
				++clen;
116
				++clen;
116
				for (; len && isblank(*p); --len, ++p);
117
				for (; len && ISBLANK(*p); --len, ++p);
117
			}
118
			}
118
		}
119
		}
119
120
(-)nvi-1.81.6/ex/ex_perl.c (-1 / +1 lines)
Lines 51-57 Link Here
51
	if (cmdp->argc != 0)
51
	if (cmdp->argc != 0)
52
		for (p = cmdp->argv[0]->bp,
52
		for (p = cmdp->argv[0]->bp,
53
		    len = cmdp->argv[0]->len; len > 0; --len, ++p)
53
		    len = cmdp->argv[0]->len; len > 0; --len, ++p)
54
			if (!isblank(*p))
54
			if (!ISBLANK(*p))
55
				break;
55
				break;
56
	if (cmdp->argc == 0 || len == 0) {
56
	if (cmdp->argc == 0 || len == 0) {
57
		ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
57
		ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
(-)nvi-1.81.6/ex/ex_subst.c (-1 / +1 lines)
Lines 71-77 Link Here
71
		goto subagain;
71
		goto subagain;
72
	for (p = cmdp->argv[0]->bp,
72
	for (p = cmdp->argv[0]->bp,
73
	    len = cmdp->argv[0]->len; len > 0; --len, ++p) {
73
	    len = cmdp->argv[0]->len; len > 0; --len, ++p) {
74
		if (!isblank(*p))
74
		if (!ISBLANK(*p))
75
			break;
75
			break;
76
	}
76
	}
77
	if (len == 0)
77
	if (len == 0)
(-)nvi-1.81.6/ex/ex_txt.c (-4 / +7 lines)
Lines 62-67 Link Here
62
	carat_t carat_st;
62
	carat_t carat_st;
63
	size_t cnt;
63
	size_t cnt;
64
	int rval;
64
	int rval;
65
	int nochange;
65
66
66
	rval = 0;
67
	rval = 0;
67
68
Lines 110-116 Link Here
110
		txt_prompt(sp, tp, prompt, flags);
111
		txt_prompt(sp, tp, prompt, flags);
111
	}
112
	}
112
113
113
	for (carat_st = C_NOTSET;;) {
114
	for (carat_st = C_NOTSET, nochange = 0;;) {
114
		if (v_event_get(sp, &ev, 0, 0))
115
		if (v_event_get(sp, &ev, 0, 0))
115
			goto err;
116
			goto err;
116
117
Lines 206-212 Link Here
206
			 * erased.
207
			 * erased.
207
			 */
208
			 */
208
			if (LF_ISSET(TXT_AUTOINDENT)) {
209
			if (LF_ISSET(TXT_AUTOINDENT)) {
209
				if (carat_st == C_NOCHANGE) {
210
				if (nochange) {
211
					nochange = 0;
210
					if (v_txt_auto(sp,
212
					if (v_txt_auto(sp,
211
					    OOBLNO, &ait, ait.ai, ntp))
213
					    OOBLNO, &ait, ait.ai, ntp))
212
						goto err;
214
						goto err;
Lines 244-250 Link Here
244
			 */
246
			 */
245
			if (LF_ISSET(TXT_CNTRLD)) {
247
			if (LF_ISSET(TXT_CNTRLD)) {
246
				for (cnt = 0; cnt < tp->len; ++cnt)
248
				for (cnt = 0; cnt < tp->len; ++cnt)
247
					if (!isblank(tp->lb[cnt]))
249
					if (!ISBLANK(tp->lb[cnt]))
248
						break;
250
						break;
249
				if (cnt == tp->len) {
251
				if (cnt == tp->len) {
250
					tp->len = 1;
252
					tp->len = 1;
Lines 293-299 Link Here
293
				MEMCPYW(ait.lb, tp->lb, tp->ai);
295
				MEMCPYW(ait.lb, tp->lb, tp->ai);
294
				ait.ai = ait.len = tp->ai;
296
				ait.ai = ait.len = tp->ai;
295
297
296
				carat_st = C_NOCHANGE;
298
				carat_st = C_NOTSET;
299
				nochange = 1;
297
				goto leftmargin;
300
				goto leftmargin;
298
			case C_ZEROSET:			/* 0^D */
301
			case C_ZEROSET:			/* 0^D */
299
				if (tp->len > tp->ai + 1)
302
				if (tp->len > tp->ai + 1)
(-)nvi-1.81.6/ex/ex_write.c (-3 / +3 lines)
Lines 142-148 Link Here
142
142
143
	/* Skip any leading whitespace. */
143
	/* Skip any leading whitespace. */
144
	if (cmdp->argc != 0)
144
	if (cmdp->argc != 0)
145
		for (p = cmdp->argv[0]->bp; *p != '\0' && isblank(*p); ++p);
145
		for (p = cmdp->argv[0]->bp; *p != '\0' && ISBLANK(*p); ++p);
146
146
147
	/* If "write !" it's a pipe to a utility. */
147
	/* If "write !" it's a pipe to a utility. */
148
	if (cmdp->argc != 0 && cmd == WRITE && *p == '!') {
148
	if (cmdp->argc != 0 && cmd == WRITE && *p == '!') {
Lines 153-159 Link Here
153
		}
153
		}
154
154
155
		/* Expand the argument. */
155
		/* Expand the argument. */
156
		for (++p; *p && isblank(*p); ++p);
156
		for (++p; *p && ISBLANK(*p); ++p);
157
		if (*p == '\0') {
157
		if (*p == '\0') {
158
			ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
158
			ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
159
			return (1);
159
			return (1);
Lines 194-200 Link Here
194
		LF_SET(FS_APPEND);
194
		LF_SET(FS_APPEND);
195
195
196
		/* Skip ">>" and whitespace. */
196
		/* Skip ">>" and whitespace. */
197
		for (p += 2; *p && isblank(*p); ++p);
197
		for (p += 2; *p && ISBLANK(*p); ++p);
198
	}
198
	}
199
199
200
	/* If no other arguments, just write the file back. */
200
	/* If no other arguments, just write the file back. */
(-)nvi-1.81.6/regex/regcomp.c (-1 / +1 lines)
Lines 818-824 Link Here
818
		NEXT();
818
		NEXT();
819
	len = p->next - sp;
819
	len = p->next - sp;
820
	for (cp = cclasses; cp->name != NULL; cp++)
820
	for (cp = cclasses; cp->name != NULL; cp++)
821
		if (STRLEN(cp->name) == len && MEMCMP(cp->name, sp, len))
821
		if (STRLEN(cp->name) == len && !MEMCMP(cp->name, sp, len))
822
			break;
822
			break;
823
	if (cp->name == NULL) {
823
	if (cp->name == NULL) {
824
		/* oops, didn't find it */
824
		/* oops, didn't find it */
(-)nvi-1.81.6/vi/getc.c (-4 / +4 lines)
Lines 121-132 Link Here
121
int
121
int
122
cs_fspace(SCR *sp, VCS *csp)
122
cs_fspace(SCR *sp, VCS *csp)
123
{
123
{
124
	if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
124
	if (csp->cs_flags != 0 || !ISBLANK(csp->cs_ch))
125
		return (0);
125
		return (0);
126
	for (;;) {
126
	for (;;) {
127
		if (cs_next(sp, csp))
127
		if (cs_next(sp, csp))
128
			return (1);
128
			return (1);
129
		if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
129
		if (csp->cs_flags != 0 || !ISBLANK(csp->cs_ch))
130
			break;
130
			break;
131
	}
131
	}
132
	return (0);
132
	return (0);
Lines 145-151 Link Here
145
		if (cs_next(sp, csp))
145
		if (cs_next(sp, csp))
146
			return (1);
146
			return (1);
147
		if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
147
		if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
148
		    csp->cs_flags == 0 && isblank(csp->cs_ch))
148
		    csp->cs_flags == 0 && ISBLANK(csp->cs_ch))
149
			continue;
149
			continue;
150
		break;
150
		break;
151
	}
151
	}
Lines 214-220 Link Here
214
		if (cs_prev(sp, csp))
214
		if (cs_prev(sp, csp))
215
			return (1);
215
			return (1);
216
		if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
216
		if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
217
		    csp->cs_flags == 0 && isblank(csp->cs_ch))
217
		    csp->cs_flags == 0 && ISBLANK(csp->cs_ch))
218
			continue;
218
			continue;
219
		break;
219
		break;
220
	}
220
	}
(-)nvi-1.81.6/vi/vi.c (-9 / +14 lines)
Lines 1050-1056 Link Here
1050
1050
1051
/*
1051
/*
1052
 * v_curword --
1052
 * v_curword --
1053
 *	Get the word (or non-word) the cursor is on.
1053
 *	Get the word (tagstring, actually) the cursor is on.
1054
 *
1054
 *
1055
 * PUBLIC: int v_curword __P((SCR *));
1055
 * PUBLIC: int v_curword __P((SCR *));
1056
 */
1056
 */
Lines 1059-1065 Link Here
1059
{
1059
{
1060
	VI_PRIVATE *vip;
1060
	VI_PRIVATE *vip;
1061
	size_t beg, end, len;
1061
	size_t beg, end, len;
1062
	int moved, state;
1062
	int moved;
1063
	CHAR_T *p;
1063
	CHAR_T *p;
1064
1064
1065
	if (db_get(sp, sp->lno, DBG_FATAL, &p, &len))
1065
	if (db_get(sp, sp->lno, DBG_FATAL, &p, &len))
Lines 1081-1087 Link Here
1081
	 * follow the same rule.
1081
	 * follow the same rule.
1082
	 */
1082
	 */
1083
	for (moved = 0,
1083
	for (moved = 0,
1084
	    beg = sp->cno; beg < len && isspace(p[beg]); moved = 1, ++beg);
1084
	    beg = sp->cno; beg < len && ISSPACE(p[beg]); moved = 1, ++beg);
1085
	if (beg >= len) {
1085
	if (beg >= len) {
1086
		msgq(sp, M_BERR, "212|Cursor not in a word");
1086
		msgq(sp, M_BERR, "212|Cursor not in a word");
1087
		return (1);
1087
		return (1);
Lines 1091-1105 Link Here
1091
		(void)vs_refresh(sp, 0);
1091
		(void)vs_refresh(sp, 0);
1092
	}
1092
	}
1093
1093
1094
	/* Find the end of the word. */
1094
	/*
1095
	for (state = inword(p[beg]),
1095
	 * Find the end of the word.
1096
	    end = beg; ++end < len && state == inword(p[end]););
1096
	 *
1097
	 * !!!
1098
	 * Historically, vi accepted any non-blank as initial character
1099
	 * when building up a tagstring.  Required by IEEE 1003.1-2001.
1100
	 */
1101
	for (end = beg; ++end < len && inword(p[end]););
1097
1102
1098
	vip = VIP(sp);
1103
	vip = VIP(sp);
1099
	len = (end - beg);
1104
	vip->klen = len = end - beg;
1100
	BINC_RETW(sp, vip->keyw, vip->klen, len+1);
1105
	BINC_RETW(sp, vip->keyw, vip->keywlen, len+1);
1101
	MEMMOVEW(vip->keyw, p + beg, len);
1106
	MEMMOVEW(vip->keyw, p + beg, len);
1102
	vip->keyw[len] = '\0';				/* XXX */
1107
	vip->keyw[len] = L('\0');				/* XXX */
1103
	return (0);
1108
	return (0);
1104
}
1109
}
1105
1110
(-)nvi-1.81.6/vi/v_increment.c (-28 / +27 lines)
Lines 28-44 Link Here
28
#include "../common/common.h"
28
#include "../common/common.h"
29
#include "vi.h"
29
#include "vi.h"
30
30
31
static char * const fmt[] = {
31
static CHAR_T * const fmt[] = {
32
#define	DEC	0
32
#define	DEC	0
33
	"%ld",
33
	L("%ld"),
34
#define	SDEC	1
34
#define	SDEC	1
35
	"%+ld",
35
	L("%+ld"),
36
#define	HEXC	2
36
#define	HEXC	2
37
	"0X%0*lX",
37
	L("0X%0*lX"),
38
#define	HEXL	3
38
#define	HEXL	3
39
	"0x%0*lx",
39
	L("0x%0*lx"),
40
#define	OCTAL	4
40
#define	OCTAL	4
41
	"%#0*lo",
41
	L("%#0*lo"),
42
};
42
};
43
43
44
static void inc_err __P((SCR *, enum nresult));
44
static void inc_err __P((SCR *, enum nresult));
Lines 57-69 Link Here
57
	long change, ltmp, lval;
57
	long change, ltmp, lval;
58
	size_t beg, blen, end, len, nlen, wlen;
58
	size_t beg, blen, end, len, nlen, wlen;
59
	int base, isempty, rval;
59
	int base, isempty, rval;
60
	char *ntype, nbuf[100];
60
	CHAR_T *bp, *p, *t, *ntype, nbuf[100];
61
	CHAR_T *bp, *p, *t;
62
61
63
	/* Validate the operator. */
62
	/* Validate the operator. */
64
	if (vp->character == '#')
63
	if (vp->character == L('#'))
65
		vp->character = '+';
64
		vp->character = L('+');
66
	if (vp->character != '+' && vp->character != '-') {
65
	if (vp->character != L('+') && vp->character != L('-')) {
67
		v_emsg(sp, vp->kp->usage, VIM_USAGE);
66
		v_emsg(sp, vp->kp->usage, VIM_USAGE);
68
		return (1);
67
		return (1);
69
	}
68
	}
Lines 90-96 Link Here
90
	 * implies moving the cursor to its beginning, if we moved, refresh
89
	 * implies moving the cursor to its beginning, if we moved, refresh
91
	 * now.
90
	 * now.
92
	 */
91
	 */
93
	for (beg = vp->m_start.cno; beg < len && isspace(p[beg]); ++beg);
92
	for (beg = vp->m_start.cno; beg < len && ISSPACE(p[beg]); ++beg);
94
	if (beg >= len)
93
	if (beg >= len)
95
		goto nonum;
94
		goto nonum;
96
	if (beg != vp->m_start.cno) {
95
	if (beg != vp->m_start.cno) {
Lines 99-107 Link Here
99
	}
98
	}
100
99
101
#undef	ishex
100
#undef	ishex
102
#define	ishex(c)	(isdigit(c) || strchr("abcdefABCDEF", c))
101
#define	ishex(c)	(ISDIGIT(c) || STRCHR(L("abcdefABCDEF"), c))
103
#undef	isoctal
102
#undef	isoctal
104
#define	isoctal(c)	(isdigit(c) && (c) != '8' && (c) != '9')
103
#define	isoctal(c)	(ISDIGIT(c) && (c) != L('8') && (c) != L('9'))
105
104
106
	/*
105
	/*
107
	 * Look for 0[Xx], or leading + or - signs, guess at the base.
106
	 * Look for 0[Xx], or leading + or - signs, guess at the base.
Lines 110-139 Link Here
110
	 * the number.
109
	 * the number.
111
	 */
110
	 */
112
	wlen = len - beg;
111
	wlen = len - beg;
113
	if (p[beg] == '0' && wlen > 2 &&
112
	if (p[beg] == L('0') && wlen > 2 &&
114
	    (p[beg + 1] == 'X' || p[beg + 1] == 'x')) {
113
	    (p[beg + 1] == L('X') || p[beg + 1] == L('x'))) {
115
		base = 16;
114
		base = 16;
116
		end = beg + 2;
115
		end = beg + 2;
117
		if (!ishex(p[end]))
116
		if (!ishex(p[end]))
118
			goto decimal;
117
			goto decimal;
119
		ntype = p[beg + 1] == 'X' ? fmt[HEXC] : fmt[HEXL];
118
		ntype = p[beg + 1] == L('X') ? fmt[HEXC] : fmt[HEXL];
120
	} else if (p[beg] == '0' && wlen > 1) {
119
	} else if (p[beg] == L('0') && wlen > 1) {
121
		base = 8;
120
		base = 8;
122
		end = beg + 1;
121
		end = beg + 1;
123
		if (!isoctal(p[end]))
122
		if (!isoctal(p[end]))
124
			goto decimal;
123
			goto decimal;
125
		ntype = fmt[OCTAL];
124
		ntype = fmt[OCTAL];
126
	} else if (wlen >= 1 && (p[beg] == '+' || p[beg] == '-')) {
125
	} else if (wlen >= 1 && (p[beg] == L('+') || p[beg] == L('-'))) {
127
		base = 10;
126
		base = 10;
128
		end = beg + 1;
127
		end = beg + 1;
129
		ntype = fmt[SDEC];
128
		ntype = fmt[SDEC];
130
		if (!isdigit(p[end]))
129
		if (!ISDIGIT(p[end]))
131
			goto nonum;
130
			goto nonum;
132
	} else {
131
	} else {
133
decimal:	base = 10;
132
decimal:	base = 10;
134
		end = beg;
133
		end = beg;
135
		ntype = fmt[DEC];
134
		ntype = fmt[DEC];
136
		if (!isdigit(p[end])) {
135
		if (!ISDIGIT(p[end])) {
137
nonum:			msgq(sp, M_ERR, "181|Cursor not in a number");
136
nonum:			msgq(sp, M_ERR, "181|Cursor not in a number");
138
			return (1);
137
			return (1);
139
		}
138
		}
Lines 145-158 Link Here
145
		case 8:
144
		case 8:
146
			if (isoctal(p[end]))
145
			if (isoctal(p[end]))
147
				continue;
146
				continue;
148
			if (p[end] == '8' || p[end] == '9') {
147
			if (p[end] == L('8') || p[end] == L('9')) {
149
				base = 10;
148
				base = 10;
150
				ntype = fmt[DEC];
149
				ntype = fmt[DEC];
151
				continue;
150
				continue;
152
			}
151
			}
153
			break;
152
			break;
154
		case 10:
153
		case 10:
155
			if (isdigit(p[end]))
154
			if (ISDIGIT(p[end]))
156
				continue;
155
				continue;
157
			break;
156
			break;
158
		case 16:
157
		case 16:
Lines 177-183 Link Here
177
	GET_SPACE_RETW(sp, bp, blen, len + 50);
176
	GET_SPACE_RETW(sp, bp, blen, len + 50);
178
	if (end == len) {
177
	if (end == len) {
179
		MEMMOVEW(bp, &p[beg], wlen);
178
		MEMMOVEW(bp, &p[beg], wlen);
180
		bp[wlen] = '\0';
179
		bp[wlen] = L('\0');
181
		t = bp;
180
		t = bp;
182
	} else
181
	} else
183
		t = &p[beg];
182
		t = &p[beg];
Lines 189-195 Link Here
189
	if (base == 10) {
188
	if (base == 10) {
190
		if ((nret = nget_slong(sp, &lval, t, NULL, 10)) != NUM_OK)
189
		if ((nret = nget_slong(sp, &lval, t, NULL, 10)) != NUM_OK)
191
			goto err;
190
			goto err;
192
		ltmp = vp->character == '-' ? -change : change;
191
		ltmp = vp->character == L('-') ? -change : change;
193
		if (lval > 0 && ltmp > 0 && !NPFITS(LONG_MAX, lval, ltmp)) {
192
		if (lval > 0 && ltmp > 0 && !NPFITS(LONG_MAX, lval, ltmp)) {
194
			nret = NUM_OVER;
193
			nret = NUM_OVER;
195
			goto err;
194
			goto err;
Lines 202-212 Link Here
202
		/* If we cross 0, signed numbers lose their sign. */
201
		/* If we cross 0, signed numbers lose their sign. */
203
		if (lval == 0 && ntype == fmt[SDEC])
202
		if (lval == 0 && ntype == fmt[SDEC])
204
			ntype = fmt[DEC];
203
			ntype = fmt[DEC];
205
		nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval);
204
		nlen = SPRINTF(nbuf, SIZE(nbuf), ntype, lval);
206
	} else {
205
	} else {
207
		if ((nret = nget_uslong(sp, &ulval, t, NULL, base)) != NUM_OK)
206
		if ((nret = nget_uslong(sp, &ulval, t, NULL, base)) != NUM_OK)
208
			goto err;
207
			goto err;
209
		if (vp->character == '+') {
208
		if (vp->character == L('+')) {
210
			if (!NPFITS(ULONG_MAX, ulval, change)) {
209
			if (!NPFITS(ULONG_MAX, ulval, change)) {
211
				nret = NUM_OVER;
210
				nret = NUM_OVER;
212
				goto err;
211
				goto err;
Lines 224-230 Link Here
224
		if (base == 16)
223
		if (base == 16)
225
			wlen -= 2;
224
			wlen -= 2;
226
225
227
		nlen = snprintf(nbuf, sizeof(nbuf), ntype, wlen, ulval);
226
		nlen = SPRINTF(nbuf, SIZE(nbuf), ntype, wlen, ulval);
228
	}
227
	}
229
228
230
	/* Build the new line. */
229
	/* Build the new line. */
(-)nvi-1.81.6/vi/v_match.c (-1 / +1 lines)
Lines 161-167 Link Here
161
	if (db_get(sp, mp->lno, DBG_FATAL, &p, &len))
161
	if (db_get(sp, mp->lno, DBG_FATAL, &p, &len))
162
		return (1);
162
		return (1);
163
	for (p += mp->cno + 1, len -= mp->cno; --len; ++p)
163
	for (p += mp->cno + 1, len -= mp->cno; --len; ++p)
164
		if (!isblank(*p))
164
		if (!ISBLANK(*p))
165
			return (0);
165
			return (0);
166
	F_SET(vp, VM_LMODE);
166
	F_SET(vp, VM_LMODE);
167
	return (0);
167
	return (0);
(-)nvi-1.81.6/vi/v_replace.c (-1 / +1 lines)
Lines 172-178 Link Here
172
		p += vp->m_start.cno + cnt;
172
		p += vp->m_start.cno + cnt;
173
		len -= vp->m_start.cno + cnt;
173
		len -= vp->m_start.cno + cnt;
174
		if (len != 0 && O_ISSET(sp, O_AUTOINDENT))
174
		if (len != 0 && O_ISSET(sp, O_AUTOINDENT))
175
			for (; len && isblank(*p); --len, ++p);
175
			for (; len && ISBLANK(*p); --len, ++p);
176
176
177
		if ((tp = text_init(sp, p, len, len)) == NULL)
177
		if ((tp = text_init(sp, p, len, len)) == NULL)
178
			goto err_ret;
178
			goto err_ret;
(-)nvi-1.81.6/vi/v_search.c (-8 / +51 lines)
Lines 313-318 Link Here
313
}
313
}
314
314
315
/*
315
/*
316
 * is_especial --
317
 *	Test if the character is special in an extended RE.
318
 */
319
static int
320
is_especial(CHAR_T c)
321
{
322
	/*
323
	 * !!!
324
	 * Right-brace is not an ERE special according to IEEE 1003.1-2001.
325
	 * Right-parenthesis is a special character (so quoting doesn't hurt),
326
	 * though it has no special meaning in this context, viz. at the
327
	 * beginning of the string.  So we need not quote it.  Then again,
328
	 * see the BUGS section in regex/re_format.7.
329
	 * The tilde is vi-specific, of course.
330
	 */
331
	return (STRCHR(L(".[\\()*+?{|^$~"), c) && c);
332
}
333
334
/*
335
 * Rear delimiter for word search when the keyword ends in
336
 * (i.e., consists of) a non-word character.  See v_searchw below.
337
 */
338
#define RE_NWSTOP	L("([^[:alnum:]_]|$)")
339
#define RE_NWSTOP_LEN	(SIZE(RE_NWSTOP) - 1)
340
341
/*
316
 * v_searchw -- [count]^A
342
 * v_searchw -- [count]^A
317
 *	Search for the word under the cursor.
343
 *	Search for the word under the cursor.
318
 *
344
 *
Lines 321-339 Link Here
321
int
347
int
322
v_searchw(SCR *sp, VICMD *vp)
348
v_searchw(SCR *sp, VICMD *vp)
323
{
349
{
324
	size_t blen, len;
350
	size_t blen;
351
	/* An upper bound for the SIZE of the RE under construction. */
352
	size_t len = VIP(sp)->klen + MAX(RE_WSTART_LEN, 1)
353
	    + MAX(RE_WSTOP_LEN, RE_NWSTOP_LEN);
325
	int rval;
354
	int rval;
326
	CHAR_T *bp, *p;
355
	CHAR_T *bp, *p;
327
356
328
	len = VIP(sp)->klen + RE_WSTART_LEN + RE_WSTOP_LEN;
329
	GET_SPACE_RETW(sp, bp, blen, len);
357
	GET_SPACE_RETW(sp, bp, blen, len);
330
	MEMCPY(bp, RE_WSTART, RE_WSTART_LEN); 
358
	p = bp;
331
	p = bp + RE_WSTART_LEN;
359
332
	MEMCPY(p, VIP(sp)->keyw, VIP(sp)->klen);
360
	/* Only the first character can be non-word, see v_curword. */
333
	p += VIP(sp)->klen;
361
	if (inword(VIP(sp)->keyw[0]))
334
	MEMCPY(p, RE_WSTOP, RE_WSTOP_LEN); 
362
		p = MEMPCPY(p, RE_WSTART, RE_WSTART_LEN);
363
	else if (is_especial(VIP(sp)->keyw[0]))
364
		p = MEMPCPY(p, L("\\"), 1);
365
366
	p = MEMPCPY(p, VIP(sp)->keyw, VIP(sp)->klen);
367
368
	if (inword(p[-1]))
369
		p = MEMPCPY(p, RE_WSTOP, RE_WSTOP_LEN);
370
	else
371
		/*
372
		 * The keyword is a single non-word character.
373
		 * We want it to stay the same when typing ^A several times
374
		 * in a row, just the way the other cases behave.
375
		 */
376
		p = MEMPCPY(p, RE_NWSTOP, RE_NWSTOP_LEN);
335
377
336
	rval = v_search(sp, vp, bp, len, SEARCH_SET, FORWARD);
378
	len = p - bp;
379
	rval = v_search(sp, vp, bp, len, SEARCH_SET | SEARCH_EXTEND, FORWARD);
337
380
338
	FREE_SPACEW(sp, bp, blen);
381
	FREE_SPACEW(sp, bp, blen);
339
	return (rval);
382
	return (rval);
(-)nvi-1.81.6/vi/v_sentence.c (-7 / +7 lines)
Lines 72-78 Link Here
72
	 * This may not handle "  .  " correctly, but it's real unclear
72
	 * This may not handle "  .  " correctly, but it's real unclear
73
	 * what correctly means in that case.
73
	 * what correctly means in that case.
74
	 */
74
	 */
75
	if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) {
75
	if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && ISBLANK(cs.cs_ch)) {
76
		if (cs_fblank(sp, &cs))
76
		if (cs_fblank(sp, &cs))
77
			return (1);
77
			return (1);
78
		if (--cnt == 0) {
78
		if (--cnt == 0) {
Lines 93-99 Link Here
93
				if (cs_next(sp, &cs))
93
				if (cs_next(sp, &cs))
94
					return (1);
94
					return (1);
95
				if (cs.cs_flags == 0 &&
95
				if (cs.cs_flags == 0 &&
96
				    isblank(cs.cs_ch) && cs_fblank(sp, &cs))
96
				    ISBLANK(cs.cs_ch) && cs_fblank(sp, &cs))
97
					return (1);
97
					return (1);
98
				goto okret;
98
				goto okret;
99
			}
99
			}
Lines 233-243 Link Here
233
			if (cs.cs_flags != CS_EOL)
233
			if (cs.cs_flags != CS_EOL)
234
				break;
234
				break;
235
		}
235
		}
236
	} else if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
236
	} else if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
237
		for (;;) {
237
		for (;;) {
238
			if (cs_prev(sp, &cs))
238
			if (cs_prev(sp, &cs))
239
				return (1);
239
				return (1);
240
			if (cs.cs_flags != 0 || isblank(cs.cs_ch))
240
			if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
241
				break;
241
				break;
242
		}
242
		}
243
243
Lines 280-286 Link Here
280
			} while (!cs.cs_flags &&
280
			} while (!cs.cs_flags &&
281
			    (cs.cs_ch == ')' || cs.cs_ch == ']' ||
281
			    (cs.cs_ch == ')' || cs.cs_ch == ']' ||
282
			    cs.cs_ch == '"' || cs.cs_ch == '\''));
282
			    cs.cs_ch == '"' || cs.cs_ch == '\''));
283
			if ((cs.cs_flags || isblank(cs.cs_ch)) &&
283
			if ((cs.cs_flags || ISBLANK(cs.cs_ch)) &&
284
			    cs_fblank(sp, &cs))
284
			    cs_fblank(sp, &cs))
285
				return (1);
285
				return (1);
286
286
Lines 303-309 Link Here
303
					return (1);
303
					return (1);
304
				if (cs.cs_flags == CS_EOL)
304
				if (cs.cs_flags == CS_EOL)
305
					continue;
305
					continue;
306
				if (cs.cs_flags == 0 && isblank(cs.cs_ch))
306
				if (cs.cs_flags == 0 && ISBLANK(cs.cs_ch))
307
					continue;
307
					continue;
308
				break;
308
				break;
309
			}
309
			}
Lines 321-327 Link Here
321
			break;
321
			break;
322
		default:
322
		default:
323
			last =
323
			last =
324
			    cs.cs_flags == CS_EOL || isblank(cs.cs_ch) ||
324
			    cs.cs_flags == CS_EOL || ISBLANK(cs.cs_ch) ||
325
			    cs.cs_ch == ')' || cs.cs_ch == ']' ||
325
			    cs.cs_ch == ')' || cs.cs_ch == ']' ||
326
			    cs.cs_ch == '"' || cs.cs_ch == '\'' ? 1 : 0;
326
			    cs.cs_ch == '"' || cs.cs_ch == '\'' ? 1 : 0;
327
		}
327
		}
(-)nvi-1.81.6/vi/vs_smap.c (+10 lines)
Lines 224-229 Link Here
224
top:			HMAP->lno = lno;
224
top:			HMAP->lno = lno;
225
			HMAP->coff = 0;
225
			HMAP->coff = 0;
226
			HMAP->soff = 1;
226
			HMAP->soff = 1;
227
		} else {
228
			/*
229
			 * If number of lines HMAP->lno (top line) spans
230
			 * changed due to, say reformatting, and now is
231
			 * fewer than HMAP->soff, reset so the line is
232
			 * redrawn at the top of the screen.
233
			 */
234
			cnt = vs_screens(sp, HMAP->lno, NULL);
235
			if (cnt < HMAP->soff)
236
				HMAP->soff = 1;
227
		}
237
		}
228
		/* If we fail, just punt. */
238
		/* If we fail, just punt. */
229
		for (p = HMAP, cnt = sp->t_rows; --cnt; ++p)
239
		for (p = HMAP, cnt = sp->t_rows; --cnt; ++p)
(-)nvi-1.81.6/vi/v_txt.c (-19 / +23 lines)
Lines 275-280 Link Here
275
	int showmatch;		/* Showmatch set on this character. */
275
	int showmatch;		/* Showmatch set on this character. */
276
	int wm_set, wm_skip;	/* Wrapmargin happened, blank skip flags. */
276
	int wm_set, wm_skip;	/* Wrapmargin happened, blank skip flags. */
277
	int max, tmp;
277
	int max, tmp;
278
	int nochange;
278
	CHAR_T *p;
279
	CHAR_T *p;
279
280
280
	gp = sp->gp;
281
	gp = sp->gp;
Lines 458-463 Link Here
458
	/* Other text input mode setup. */
459
	/* Other text input mode setup. */
459
	quote = Q_NOTSET;
460
	quote = Q_NOTSET;
460
	carat = C_NOTSET;
461
	carat = C_NOTSET;
462
	nochange = 0;
461
	FL_INIT(is_flags,
463
	FL_INIT(is_flags,
462
	    LF_ISSET(TXT_SEARCHINCR) ? IS_RESTART | IS_RUNNING : 0);
464
	    LF_ISSET(TXT_SEARCHINCR) ? IS_RESTART | IS_RUNNING : 0);
463
	filec_redraw = hexcnt = showmatch = 0;
465
	filec_redraw = hexcnt = showmatch = 0;
Lines 748-763 Link Here
748
		owrite = tp->owrite;
750
		owrite = tp->owrite;
749
		insert = tp->insert;
751
		insert = tp->insert;
750
		if (LF_ISSET(TXT_REPLACE) && owrite != 0) {
752
		if (LF_ISSET(TXT_REPLACE) && owrite != 0) {
751
			for (p = tp->lb + tp->cno; owrite > 0 && isblank(*p);
753
			for (p = tp->lb + tp->cno; owrite > 0 && ISBLANK(*p);
752
			    ++p, --owrite, ++tp->R_erase);
754
			    ++p, --owrite, ++tp->R_erase);
753
			if (owrite == 0)
755
			if (owrite == 0)
754
				for (; insert > 0 && isblank(*p);
756
				for (; insert > 0 && ISBLANK(*p);
755
				    ++p, ++tp->R_erase, --insert);
757
				    ++p, ++tp->R_erase, --insert);
756
		} else {
758
		} else {
757
			p = tp->lb + tp->cno + owrite;
759
			p = tp->lb + tp->cno + owrite;
758
			if (O_ISSET(sp, O_AUTOINDENT))
760
			if (O_ISSET(sp, O_AUTOINDENT))
759
				for (; insert > 0 &&
761
				for (; insert > 0 &&
760
				    isblank(*p); ++p, --insert);
762
				    ISBLANK(*p); ++p, --insert);
761
			owrite = 0;
763
			owrite = 0;
762
		}
764
		}
763
765
Lines 785-791 Link Here
785
		 * characters may have been erased.
787
		 * characters may have been erased.
786
		 */
788
		 */
787
		if (LF_ISSET(TXT_AUTOINDENT)) {
789
		if (LF_ISSET(TXT_AUTOINDENT)) {
788
			if (carat == C_NOCHANGE) {
790
			if (nochange) {
791
				nochange = 0;
789
				if (v_txt_auto(sp, OOBLNO, &ait, ait.ai, ntp))
792
				if (v_txt_auto(sp, OOBLNO, &ait, ait.ai, ntp))
790
					goto err;
793
					goto err;
791
				FREE_SPACEW(sp, ait.lb, ait.lb_len);
794
				FREE_SPACEW(sp, ait.lb, ait.lb_len);
Lines 958-964 Link Here
958
			MEMMOVEW(ait.lb, tp->lb, tp->ai);
961
			MEMMOVEW(ait.lb, tp->lb, tp->ai);
959
			ait.ai = ait.len = tp->ai;
962
			ait.ai = ait.len = tp->ai;
960
963
961
			carat = C_NOCHANGE;
964
			carat = C_NOTSET;
965
			nochange = 1;
962
			goto leftmargin;
966
			goto leftmargin;
963
		case C_ZEROSET:		/* 0^D */
967
		case C_ZEROSET:		/* 0^D */
964
			if (tp->ai == 0 || tp->cno > tp->ai + tp->offset + 1)
968
			if (tp->ai == 0 || tp->cno > tp->ai + tp->offset + 1)
Lines 1075-1081 Link Here
1075
		}
1079
		}
1076
1080
1077
		/* Skip over trailing space characters. */
1081
		/* Skip over trailing space characters. */
1078
		while (tp->cno > max && isblank(tp->lb[tp->cno - 1])) {
1082
		while (tp->cno > max && ISBLANK(tp->lb[tp->cno - 1])) {
1079
			--tp->cno;
1083
			--tp->cno;
1080
			++tp->owrite;
1084
			++tp->owrite;
1081
		}
1085
		}
Lines 1108-1114 Link Here
1108
				++tp->owrite;
1112
				++tp->owrite;
1109
				if (FL_ISSET(is_flags, IS_RUNNING))
1113
				if (FL_ISSET(is_flags, IS_RUNNING))
1110
					tp->lb[tp->cno] = ' ';
1114
					tp->lb[tp->cno] = ' ';
1111
				if (isblank(tp->lb[tp->cno - 1]))
1115
				if (ISBLANK(tp->lb[tp->cno - 1]))
1112
					break;
1116
					break;
1113
			}
1117
			}
1114
		else {
1118
		else {
Lines 1117-1123 Link Here
1117
				++tp->owrite;
1121
				++tp->owrite;
1118
				if (FL_ISSET(is_flags, IS_RUNNING))
1122
				if (FL_ISSET(is_flags, IS_RUNNING))
1119
					tp->lb[tp->cno] = ' ';
1123
					tp->lb[tp->cno] = ' ';
1120
				if (isblank(tp->lb[tp->cno - 1]))
1124
				if (ISBLANK(tp->lb[tp->cno - 1]))
1121
					break;
1125
					break;
1122
			}
1126
			}
1123
			if (tp->cno > max)
1127
			if (tp->cno > max)
Lines 1128-1134 Link Here
1128
				if (FL_ISSET(is_flags, IS_RUNNING))
1132
				if (FL_ISSET(is_flags, IS_RUNNING))
1129
					tp->lb[tp->cno] = ' ';
1133
					tp->lb[tp->cno] = ' ';
1130
				if (tmp != inword(tp->lb[tp->cno - 1])
1134
				if (tmp != inword(tp->lb[tp->cno - 1])
1131
				    || isblank(tp->lb[tp->cno - 1]))
1135
				    || ISBLANK(tp->lb[tp->cno - 1]))
1132
					break;
1136
					break;
1133
			}
1137
			}
1134
		}
1138
		}
Lines 1287-1293 Link Here
1287
					goto resolve;
1291
					goto resolve;
1288
				}
1292
				}
1289
			}
1293
			}
1290
			if (isblank(evp->e_c) && UNMAP_TST)
1294
			if (ISBLANK(evp->e_c) && UNMAP_TST)
1291
				txt_unmap(sp, tp, &ec_flags);
1295
				txt_unmap(sp, tp, &ec_flags);
1292
		}
1296
		}
1293
		if (abb != AB_NOTSET)
1297
		if (abb != AB_NOTSET)
Lines 1337-1343 Link Here
1337
				if (txt_margin(sp, tp, &wmt, &tmp, flags))
1341
				if (txt_margin(sp, tp, &wmt, &tmp, flags))
1338
					goto err;
1342
					goto err;
1339
				if (tmp) {
1343
				if (tmp) {
1340
					if (isblank(evp->e_c))
1344
					if (ISBLANK(evp->e_c))
1341
						wm_skip = 1;
1345
						wm_skip = 1;
1342
					wm_set = 1;
1346
					wm_set = 1;
1343
					goto k_cr;
1347
					goto k_cr;
Lines 1503-1509 Link Here
1503
	off = tp->cno - 1;			/* Previous character. */
1507
	off = tp->cno - 1;			/* Previous character. */
1504
	p = tp->lb + off;
1508
	p = tp->lb + off;
1505
	len = 1;				/* One character test. */
1509
	len = 1;				/* One character test. */
1506
	if (off == tp->offset || isblank(p[-1]))
1510
	if (off == tp->offset || ISBLANK(p[-1]))
1507
		goto search;
1511
		goto search;
1508
	if (inword(p[-1]))			/* Move backward to change. */
1512
	if (inword(p[-1]))			/* Move backward to change. */
1509
		for (;;) {
1513
		for (;;) {
Lines 1515-1521 Link Here
1515
		for (;;) {
1519
		for (;;) {
1516
			--off; --p; ++len;
1520
			--off; --p; ++len;
1517
			if (off == tp->offset ||
1521
			if (off == tp->offset ||
1518
			    inword(p[-1]) || isblank(p[-1]))
1522
			    inword(p[-1]) || ISBLANK(p[-1]))
1519
				break;
1523
				break;
1520
		}
1524
		}
1521
1525
Lines 1639-1645 Link Here
1639
1643
1640
	/* Find the beginning of this "word". */
1644
	/* Find the beginning of this "word". */
1641
	for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) {
1645
	for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) {
1642
		if (isblank(*p)) {
1646
		if (ISBLANK(*p)) {
1643
			++p;
1647
			++p;
1644
			break;
1648
			break;
1645
		}
1649
		}
Lines 1706-1712 Link Here
1706
1710
1707
	/* Figure out the last <blank> screen column. */
1711
	/* Figure out the last <blank> screen column. */
1708
	for (p = tp->lb, scno = 0, len = tp->len,
1712
	for (p = tp->lb, scno = 0, len = tp->len,
1709
	    spaces = tab_after_sp = 0; len-- && isblank(*p); ++p)
1713
	    spaces = tab_after_sp = 0; len-- && ISBLANK(*p); ++p)
1710
		if (*p == '\t') {
1714
		if (*p == '\t') {
1711
			if (spaces)
1715
			if (spaces)
1712
				tab_after_sp = 1;
1716
				tab_after_sp = 1;
Lines 1781-1787 Link Here
1781
1785
1782
	/* Count whitespace characters. */
1786
	/* Count whitespace characters. */
1783
	for (p = t; len > 0; ++p, --len)
1787
	for (p = t; len > 0; ++p, --len)
1784
		if (!isblank(*p))
1788
		if (!ISBLANK(*p))
1785
			break;
1789
			break;
1786
1790
1787
	/* Set count, check for no indentation. */
1791
	/* Set count, check for no indentation. */
Lines 2008-2014 Link Here
2008
	} else
2012
	} else
2009
retry:		for (len = 0,
2013
retry:		for (len = 0,
2010
		    off = tp->cno - 1, p = tp->lb + off;; --off, --p) {
2014
		    off = tp->cno - 1, p = tp->lb + off;; --off, --p) {
2011
			if (isblank(*p)) {
2015
			if (ISBLANK(*p)) {
2012
				++p;
2016
				++p;
2013
				break;
2017
				break;
2014
			}
2018
			}
Lines 2783-2789 Link Here
2783
2787
2784
	/* Find the nearest previous blank. */
2788
	/* Find the nearest previous blank. */
2785
	for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) {
2789
	for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) {
2786
		if (isblank(*p)) {
2790
		if (ISBLANK(*p)) {
2787
			wp = p + 1;
2791
			wp = p + 1;
2788
			break;
2792
			break;
2789
		}
2793
		}
Lines 2835-2841 Link Here
2835
	 * Delete any trailing whitespace from the current line.
2839
	 * Delete any trailing whitespace from the current line.
2836
	 */
2840
	 */
2837
	for (;; --p, --off) {
2841
	for (;; --p, --off) {
2838
		if (!isblank(*p))
2842
		if (!ISBLANK(*p))
2839
			break;
2843
			break;
2840
		--tp->cno;
2844
		--tp->cno;
2841
		--tp->len;
2845
		--tp->len;
(-)nvi-1.81.6/vi/v_util.c (-1 / +1 lines)
Lines 123-129 Link Here
123
v_isempty(CHAR_T *p, size_t len)
123
v_isempty(CHAR_T *p, size_t len)
124
{
124
{
125
	for (; len--; ++p)
125
	for (; len--; ++p)
126
		if (!isblank(*p))
126
		if (!ISBLANK(*p))
127
			return (0);
127
			return (0);
128
	return (1);
128
	return (1);
129
}
129
}
(-)nvi-1.81.6/vi/v_word.c (-14 / +14 lines)
Lines 118-124 Link Here
118
	 *	counts as a single word move.  If it's a motion command,
118
	 *	counts as a single word move.  If it's a motion command,
119
	 *	don't move off the end of the line.
119
	 *	don't move off the end of the line.
120
	 */
120
	 */
121
	if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) {
121
	if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && ISBLANK(cs.cs_ch)) {
122
		if (ISMOTION(vp) && cs.cs_flags != CS_EMP && cnt == 1) {
122
		if (ISMOTION(vp) && cs.cs_flags != CS_EMP && cnt == 1) {
123
			if (ISCMD(vp->rkp, 'c'))
123
			if (ISCMD(vp->rkp, 'c'))
124
				return (0);
124
				return (0);
Lines 146-152 Link Here
146
					return (1);
146
					return (1);
147
				if (cs.cs_flags == CS_EOF)
147
				if (cs.cs_flags == CS_EOF)
148
					goto ret;
148
					goto ret;
149
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
149
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
150
					break;
150
					break;
151
			}
151
			}
152
			/*
152
			/*
Lines 178-184 Link Here
178
					return (1);
178
					return (1);
179
				if (cs.cs_flags == CS_EOF)
179
				if (cs.cs_flags == CS_EOF)
180
					goto ret;
180
					goto ret;
181
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
181
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
182
					break;
182
					break;
183
				if (state == INWORD) {
183
				if (state == INWORD) {
184
					if (!inword(cs.cs_ch))
184
					if (!inword(cs.cs_ch))
Lines 197-203 Link Here
197
			}
197
			}
198
198
199
			/* Eat whitespace characters. */
199
			/* Eat whitespace characters. */
200
			if (cs.cs_flags != 0 || isblank(cs.cs_ch))
200
			if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
201
				if (cs_fblank(sp, &cs))
201
				if (cs_fblank(sp, &cs))
202
					return (1);
202
					return (1);
203
			if (cs.cs_flags == CS_EOF)
203
			if (cs.cs_flags == CS_EOF)
Lines 277-286 Link Here
277
	 * it.  (This doesn't count as a word move.)  Stay at the character
277
	 * it.  (This doesn't count as a word move.)  Stay at the character
278
	 * past the current one, it sets word "state" for the 'e' command.
278
	 * past the current one, it sets word "state" for the 'e' command.
279
	 */
279
	 */
280
	if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
280
	if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch)) {
281
		if (cs_next(sp, &cs))
281
		if (cs_next(sp, &cs))
282
			return (1);
282
			return (1);
283
		if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
283
		if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
284
			goto start;
284
			goto start;
285
	}
285
	}
286
	if (cs_fblank(sp, &cs))
286
	if (cs_fblank(sp, &cs))
Lines 299-305 Link Here
299
					return (1);
299
					return (1);
300
				if (cs.cs_flags == CS_EOF)
300
				if (cs.cs_flags == CS_EOF)
301
					goto ret;
301
					goto ret;
302
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
302
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
303
					break;
303
					break;
304
			}
304
			}
305
			/*
305
			/*
Lines 328-334 Link Here
328
					return (1);
328
					return (1);
329
				if (cs.cs_flags == CS_EOF)
329
				if (cs.cs_flags == CS_EOF)
330
					goto ret;
330
					goto ret;
331
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
331
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
332
					break;
332
					break;
333
				if (state == INWORD) {
333
				if (state == INWORD) {
334
					if (!inword(cs.cs_ch))
334
					if (!inword(cs.cs_ch))
Lines 345-351 Link Here
345
			}
345
			}
346
346
347
			/* Eat whitespace characters. */
347
			/* Eat whitespace characters. */
348
			if (cs.cs_flags != 0 || isblank(cs.cs_ch))
348
			if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
349
				if (cs_fblank(sp, &cs))
349
				if (cs_fblank(sp, &cs))
350
					return (1);
350
					return (1);
351
			if (cs.cs_flags == CS_EOF)
351
			if (cs.cs_flags == CS_EOF)
Lines 424-433 Link Here
424
	 * character before the current one, it sets word "state" for the
424
	 * character before the current one, it sets word "state" for the
425
	 * 'b' command.
425
	 * 'b' command.
426
	 */
426
	 */
427
	if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
427
	if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch)) {
428
		if (cs_prev(sp, &cs))
428
		if (cs_prev(sp, &cs))
429
			return (1);
429
			return (1);
430
		if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
430
		if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
431
			goto start;
431
			goto start;
432
	}
432
	}
433
	if (cs_bblank(sp, &cs))
433
	if (cs_bblank(sp, &cs))
Lines 446-452 Link Here
446
					return (1);
446
					return (1);
447
				if (cs.cs_flags == CS_SOF)
447
				if (cs.cs_flags == CS_SOF)
448
					goto ret;
448
					goto ret;
449
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
449
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
450
					break;
450
					break;
451
			}
451
			}
452
			/*
452
			/*
Lines 475-481 Link Here
475
					return (1);
475
					return (1);
476
				if (cs.cs_flags == CS_SOF)
476
				if (cs.cs_flags == CS_SOF)
477
					goto ret;
477
					goto ret;
478
				if (cs.cs_flags != 0 || isblank(cs.cs_ch))
478
				if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
479
					break;
479
					break;
480
				if (state == INWORD) {
480
				if (state == INWORD) {
481
					if (!inword(cs.cs_ch))
481
					if (!inword(cs.cs_ch))
Lines 492-498 Link Here
492
			}
492
			}
493
493
494
			/* Eat whitespace characters. */
494
			/* Eat whitespace characters. */
495
			if (cs.cs_flags != 0 || isblank(cs.cs_ch))
495
			if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
496
				if (cs_bblank(sp, &cs))
496
				if (cs_bblank(sp, &cs))
497
					return (1);
497
					return (1);
498
			if (cs.cs_flags == CS_SOF)
498
			if (cs.cs_flags == CS_SOF)

Return to bug 466030