1. fix PR/44455, nonprintable character doesn't show hex-visual
under big endian. 2. ":set octal" with nonprintable character causes nbwcurses move error. 3. moving (big)words by wW/eE/bB can't handle non-ascii characters. 4. toggle uppercase/lowercase by ~ can't handle non-ascii characters. 5. don't feed CHAR_T(=wchar_t) to is* function directly. is* funcs with over UCHAR_MAX value may cause undefined behavior. some ctype implementation(such as FreeBSD) return unexpected result(same result as isw* func). 6. using non-ascii digit character with count/line number of ex/vi command may causes unexpeced result.
This commit is contained in:
parent
374ecd4b4c
commit
80356df9b8
4
dist/nvi/clib/mkstemp.c
vendored
4
dist/nvi/clib/mkstemp.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mkstemp.c,v 1.1.1.2 2008/05/18 14:29:38 aymeric Exp $ */
|
||||
/* $NetBSD: mkstemp.c,v 1.2 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
@ -119,7 +119,7 @@ _gettemp(char *path, register int *doopen)
|
||||
if (*trv == 'z')
|
||||
*trv++ = 'a';
|
||||
else {
|
||||
if (isdigit(*trv))
|
||||
if (isdigit((unsigned char)*trv))
|
||||
*trv = 'a';
|
||||
else
|
||||
++*trv;
|
||||
|
6
dist/nvi/common/cut.c
vendored
6
dist/nvi/common/cut.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cut.c,v 1.3 2009/12/23 12:44:21 mlelstv Exp $ */
|
||||
/* $NetBSD: cut.c,v 1.4 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -69,7 +69,7 @@ int
|
||||
cut(SCR *sp, CHAR_T *namep, MARK *fm, MARK *tm, int flags)
|
||||
{
|
||||
CB *cbp;
|
||||
CHAR_T name = '\0';
|
||||
ARG_CHAR_T name = '\0';
|
||||
db_recno_t lno;
|
||||
int append, copy_one, copy_def;
|
||||
|
||||
@ -97,7 +97,7 @@ cut(SCR *sp, CHAR_T *namep, MARK *fm, MARK *tm, int flags)
|
||||
*/
|
||||
append = copy_one = copy_def = 0;
|
||||
if (namep != NULL) {
|
||||
name = *namep;
|
||||
name = (UCHAR_T)*namep;
|
||||
if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
|
||||
(LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) {
|
||||
copy_one = 1;
|
||||
|
10
dist/nvi/common/cut.h
vendored
10
dist/nvi/common/cut.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cut.h,v 1.3 2009/12/23 12:44:21 mlelstv Exp $ */
|
||||
/* $NetBSD: cut.h,v 1.4 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -19,7 +19,7 @@ struct _cb {
|
||||
LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */
|
||||
TEXTH textq; /* Linked list of TEXT structures. */
|
||||
/* XXXX Needed ? Can non ascii-chars be cut buffer names ? */
|
||||
CHAR_T name; /* Cut buffer name. */
|
||||
ARG_CHAR_T name; /* Cut buffer name. */
|
||||
size_t len; /* Total length of cut text. */
|
||||
|
||||
#define CB_LMODE 0x01 /* Cut was in line mode. */
|
||||
@ -66,9 +66,9 @@ struct _text { /* Text: a linked list of lines. */
|
||||
* Translate upper-case buffer names to lower-case buffer names.
|
||||
*/
|
||||
#define CBNAME(sp, cbp, nch) { \
|
||||
CHAR_T L__name; \
|
||||
L__name = ISUPPER((unsigned char)nch) ? \
|
||||
TOLOWER((unsigned char)nch) : (nch); \
|
||||
ARG_CHAR_T L__name; \
|
||||
L__name = ISUPPER(nch) ? \
|
||||
TOLOWER(nch) : (nch); \
|
||||
for (cbp = sp->wp->cutq.lh_first; \
|
||||
cbp != NULL; cbp = cbp->q.le_next) \
|
||||
if (cbp->name == L__name) \
|
||||
|
4
dist/nvi/common/extern.h
vendored
4
dist/nvi/common/extern.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.3 2009/11/14 23:31:37 christos Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.4 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/* Do not edit: automatically built by build/distrib. */
|
||||
SCR *api_fscreen __P((int, char *));
|
||||
@ -66,7 +66,7 @@ int v_key_init __P((SCR *));
|
||||
void v_key_ilookup __P((SCR *));
|
||||
size_t v_key_len __P((SCR *, ARG_CHAR_T));
|
||||
u_char *v_key_name __P((SCR *, ARG_CHAR_T));
|
||||
int v_key_val __P((SCR *, ARG_CHAR_T));
|
||||
e_key_t v_key_val __P((SCR *, ARG_CHAR_T));
|
||||
int v_event_push __P((SCR *, EVENT *, const CHAR_T *, size_t, u_int));
|
||||
int v_event_get __P((SCR *, EVENT *, int, u_int32_t));
|
||||
void v_event_err __P((SCR *, EVENT *));
|
||||
|
23
dist/nvi/common/gs.h
vendored
23
dist/nvi/common/gs.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gs.h,v 1.4 2009/01/18 03:43:45 lukem Exp $ */
|
||||
/* $NetBSD: gs.h,v 1.5 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
@ -81,7 +81,7 @@ struct _gs {
|
||||
DB *msg; /* Message catalog DB. */
|
||||
MSGH msgq; /* User message list. */
|
||||
#define DEFAULT_NOPRINT '\1' /* Emergency non-printable character. */
|
||||
CHAR_T noprint; /* Cached, unprintable character. */
|
||||
int noprint; /* Cached, unprintable character. */
|
||||
|
||||
char *c_option; /* Ex initial, command-line command. */
|
||||
|
||||
@ -89,16 +89,16 @@ struct _gs {
|
||||
FILE *tracefp; /* Trace file pointer. */
|
||||
#endif
|
||||
|
||||
#define MAX_BIT_SEQ 128 /* Max + 1 fast check character. */
|
||||
#define MAX_BIT_SEQ 0x7f /* Max + 1 fast check character. */
|
||||
LIST_HEAD(_seqh, _seq) seqq; /* Linked list of maps, abbrevs. */
|
||||
bitstr_t bit_decl(seqb, MAX_BIT_SEQ);
|
||||
bitstr_t bit_decl(seqb, MAX_BIT_SEQ + 1);
|
||||
|
||||
#define MAX_FAST_KEY 254 /* Max fast check character.*/
|
||||
#define MAX_FAST_KEY 0xff /* Max fast check character.*/
|
||||
#define KEY_LEN(sp, ch) \
|
||||
((UCHAR_T)(ch) <= MAX_FAST_KEY ? \
|
||||
(((ch) & ~MAX_FAST_KEY) == 0 ? \
|
||||
sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch))
|
||||
#define KEY_NAME(sp, ch) \
|
||||
((UCHAR_T)(ch) <= MAX_FAST_KEY ? \
|
||||
(((ch) & ~MAX_FAST_KEY) == 0 ? \
|
||||
sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch))
|
||||
struct {
|
||||
u_char name[MAX_CHARACTER_COLUMNS + 1];
|
||||
@ -106,12 +106,9 @@ struct _gs {
|
||||
} cname[MAX_FAST_KEY + 1]; /* Fast lookup table. */
|
||||
|
||||
#define KEY_VAL(sp, ch) \
|
||||
((UCHAR_T)(ch) <= MAX_FAST_KEY ? \
|
||||
sp->gp->special_key[(UCHAR_T)ch] : \
|
||||
(UCHAR_T)(ch) > (UCHAR_T)sp->gp->max_special ? \
|
||||
K_NOTUSED : v_key_val(sp,ch))
|
||||
CHAR_T max_special; /* Max special character. */
|
||||
u_char /* Fast lookup table. */
|
||||
(((ch) & ~MAX_FAST_KEY) == 0 ? \
|
||||
sp->gp->special_key[(unsigned char)ch] : v_key_val(sp,ch))
|
||||
e_key_t /* Fast lookup table. */
|
||||
special_key[MAX_FAST_KEY + 1];
|
||||
|
||||
/* Flags. */
|
||||
|
64
dist/nvi/common/key.c
vendored
64
dist/nvi/common/key.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: key.c,v 1.5 2009/01/18 03:45:50 lukem Exp $ */
|
||||
/* $NetBSD: key.c,v 1.6 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -138,16 +138,12 @@ v_key_init(SCR *sp)
|
||||
qsort(keylist, nkeylist, sizeof(keylist[0]), v_key_cmp);
|
||||
|
||||
/* Initialize the fast lookup table. */
|
||||
for (gp->max_special = 0, kp = keylist, cnt = nkeylist; cnt--; ++kp) {
|
||||
if (gp->max_special < kp->ch)
|
||||
gp->max_special = kp->ch;
|
||||
if (kp->ch <= MAX_FAST_KEY)
|
||||
gp->special_key[kp->ch] = kp->value;
|
||||
}
|
||||
for (kp = keylist, cnt = nkeylist; cnt--; ++kp)
|
||||
gp->special_key[kp->ch] = kp->value;
|
||||
|
||||
/* Find a non-printable character to use as a message separator. */
|
||||
for (ch = 1; (unsigned)ch <= MAX_CHAR_T; ++ch)
|
||||
if (!ISPRINT(ch)) {
|
||||
for (ch = 1; ch <= UCHAR_MAX; ++ch)
|
||||
if (!isprint(ch)) {
|
||||
gp->noprint = ch;
|
||||
break;
|
||||
}
|
||||
@ -243,12 +239,13 @@ v_key_name(SCR *sp, ARG_CHAR_T ach)
|
||||
{
|
||||
static const char hexdigit[] = "0123456789abcdef";
|
||||
static const char octdigit[] = "01234567";
|
||||
CHAR_T ch, mask;
|
||||
size_t len;
|
||||
int cnt, shift;
|
||||
int ch;
|
||||
size_t len, i;
|
||||
const char *chp;
|
||||
|
||||
ch = ach;
|
||||
if (INTISWIDE(ach))
|
||||
goto vis;
|
||||
ch = (unsigned char)ach;
|
||||
|
||||
/* See if the character was explicitly declared printable or not. */
|
||||
if ((chp = O_STR(sp, O_PRINT)) != NULL)
|
||||
@ -279,38 +276,33 @@ v_key_name(SCR *sp, ARG_CHAR_T ach)
|
||||
* NB: There's an assumption here that all printable characters take
|
||||
* up a single column on the screen. This is not always correct.
|
||||
*/
|
||||
if (ISPRINT(ch)) {
|
||||
if (isprint(ch)) {
|
||||
pr: sp->cname[0] = ch;
|
||||
len = 1;
|
||||
goto done;
|
||||
}
|
||||
nopr: if (ISCNTRL(ch) && (ch < 0x20 || ch == 0x7f)) {
|
||||
nopr: if (iscntrl(ch) && (ch < 0x20 || ch == 0x7f)) {
|
||||
sp->cname[0] = '^';
|
||||
sp->cname[1] = ch == 0x7f ? '?' : '@' + ch;
|
||||
len = 2;
|
||||
} else if (O_ISSET(sp, O_OCTAL)) {
|
||||
#define BITS (sizeof(CHAR_T) * 8)
|
||||
#define SHIFT (BITS - BITS % 3)
|
||||
#define TOPMASK (BITS % 3 == 2 ? 3 : 1) << (BITS - BITS % 3)
|
||||
goto done;
|
||||
}
|
||||
vis: for (i = 1; i <= sizeof(CHAR_T); ++i)
|
||||
if ((ach >> i * CHAR_BIT) == 0)
|
||||
break;
|
||||
ch = (ach >> --i * CHAR_BIT) & UCHAR_MAX;
|
||||
if (O_ISSET(sp, O_OCTAL)) {
|
||||
sp->cname[0] = '\\';
|
||||
sp->cname[1] = octdigit[(ch & TOPMASK) >> SHIFT];
|
||||
shift = SHIFT - 3;
|
||||
for (len = 2, mask = 7 << (SHIFT - 3),
|
||||
cnt = BITS / 3; cnt-- > 0; mask >>= 3, shift -= 3)
|
||||
sp->cname[len++] = octdigit[(ch & mask) >> shift];
|
||||
sp->cname[1] = octdigit[(ch & 0300) >> 6];
|
||||
sp->cname[2] = octdigit[(ch & 070) >> 3];
|
||||
sp->cname[3] = octdigit[ ch & 07 ];
|
||||
} else {
|
||||
sp->cname[0] = '\\';
|
||||
sp->cname[1] = 'x';
|
||||
for (len = 2, chp = (char *)&ch,
|
||||
/* sizeof(CHAR_T) conflict with MAX_CHARACTER_COLUMNS
|
||||
* and code depends on big endian
|
||||
* and might not be needed in the long run
|
||||
*/
|
||||
cnt = /*sizeof(CHAR_T)*/1; cnt-- > 0; ++chp) {
|
||||
sp->cname[len++] = hexdigit[(*chp & 0xf0) >> 4];
|
||||
sp->cname[len++] = hexdigit[*chp & 0x0f];
|
||||
}
|
||||
sp->cname[2] = hexdigit[(ch & 0xf0) >> 4];
|
||||
sp->cname[3] = hexdigit[ ch & 0x0f ];
|
||||
}
|
||||
len = 4;
|
||||
done: sp->cname[sp->clen = len] = '\0';
|
||||
return (sp->cname);
|
||||
}
|
||||
@ -322,7 +314,7 @@ done: sp->cname[sp->clen = len] = '\0';
|
||||
*
|
||||
* PUBLIC: int v_key_val __P((SCR *, ARG_CHAR_T));
|
||||
*/
|
||||
int
|
||||
e_key_t
|
||||
v_key_val(SCR *sp, ARG_CHAR_T ch)
|
||||
{
|
||||
KEYLIST k, *kp;
|
||||
@ -628,8 +620,8 @@ newmap: evp = &wp->i_event[wp->i_next];
|
||||
*/
|
||||
if (istimeout || FL_ISSET(evp->e_flags, CH_NOMAP) ||
|
||||
!LF_ISSET(EC_MAPCOMMAND | EC_MAPINPUT) ||
|
||||
((UCHAR_T)evp->e_c < MAX_BIT_SEQ &&
|
||||
!bit_test(gp->seqb, (UCHAR_T)evp->e_c)))
|
||||
((evp->e_c & ~MAX_BIT_SEQ) == 0 &&
|
||||
!bit_test(gp->seqb, evp->e_c)))
|
||||
goto nomap;
|
||||
|
||||
/* Search the map. */
|
||||
|
63
dist/nvi/common/key.h
vendored
63
dist/nvi/common/key.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: key.h,v 1.1.1.2 2008/05/18 14:29:46 aymeric Exp $ */
|
||||
/* $NetBSD: key.h,v 1.2 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -13,20 +13,6 @@
|
||||
|
||||
#include "multibyte.h"
|
||||
|
||||
/*
|
||||
* Fundamental character types.
|
||||
*
|
||||
* CHAR_T An integral type that can hold any character.
|
||||
* ARG_CHAR_T The type of a CHAR_T when passed as an argument using
|
||||
* traditional promotion rules. It should also be able
|
||||
* to be compared against any CHAR_T for equality without
|
||||
* problems.
|
||||
* MAX_CHAR_T The maximum value of any character.
|
||||
*
|
||||
* If no integral type can hold a character, don't even try the port.
|
||||
*/
|
||||
typedef u_int ARG_CHAR_T;
|
||||
|
||||
#ifdef USE_WIDECHAR
|
||||
#define FILE2INT5(sp,buf,n,nlen,w,wlen) \
|
||||
sp->conv.file2int(sp, n, nlen, &buf, &wlen, &w)
|
||||
@ -41,23 +27,8 @@ typedef u_int ARG_CHAR_T;
|
||||
#define INPUT2INT5(sp,cw,n,nlen,w,wlen) \
|
||||
sp->conv.input2int(sp, n, nlen, &(cw), &wlen, &w)
|
||||
#define CONST
|
||||
#define ISCNTRL(ch) \
|
||||
iswcntrl((ch))
|
||||
#define ISDIGIT(ch) \
|
||||
iswdigit((ch))
|
||||
#define ISPRINT(ch) \
|
||||
iswprint((ch))
|
||||
#define ISBLANK(ch) \
|
||||
iswblank((ch))
|
||||
#define ISALPHA(ch) \
|
||||
iswalpha((ch))
|
||||
#define ISALNUM(ch) \
|
||||
iswalnum((ch))
|
||||
#define CHAR_WIDTH(sp, ch) wcwidth(ch)
|
||||
#define INTISWIDE(c) (!!(c >> 8)) /* XXX wrong name */
|
||||
#define WS "%ls"
|
||||
#define WVS "%*ls"
|
||||
#define WC "%lc"
|
||||
#else
|
||||
#define FILE2INT5(sp,buf,n,nlen,w,wlen) \
|
||||
(w = n, wlen = nlen, 0)
|
||||
@ -72,23 +43,8 @@ typedef u_int ARG_CHAR_T;
|
||||
#define INPUT2INT5(sp,buf,n,nlen,w,wlen) \
|
||||
(w = n, wlen = nlen, 0)
|
||||
#define CONST const
|
||||
#define ISCNTRL(ch) \
|
||||
iscntrl((ch))
|
||||
#define ISDIGIT(ch) \
|
||||
isdigit((ch))
|
||||
#define ISPRINT(ch) \
|
||||
isprint((ch))
|
||||
#define ISBLANK(ch) \
|
||||
isblank((ch))
|
||||
#define ISALPHA(ch) \
|
||||
isalpha((ch))
|
||||
#define ISALNUM(ch) \
|
||||
isalnum((ch))
|
||||
#define INTISWIDE(c) 0
|
||||
#define CHAR_WIDTH(sp, ch) 1
|
||||
#define WS "%s"
|
||||
#define WVS "%*s"
|
||||
#define WC "%c"
|
||||
#endif
|
||||
#define FILE2INT(sp,n,nlen,w,wlen) \
|
||||
FILE2INT5(sp,sp->wp->cw,n,nlen,w,wlen)
|
||||
@ -163,7 +119,7 @@ struct _event {
|
||||
#define CH_MAPPED 0x02 /* Character is from a map. */
|
||||
#define CH_NOMAP 0x04 /* Do not map the character. */
|
||||
#define CH_QUOTED 0x08 /* Character is already quoted. */
|
||||
CHAR_T e_c; /* Character. */
|
||||
ARG_CHAR_T e_c; /* Character. */
|
||||
e_key_t e_value; /* Key type. */
|
||||
|
||||
#define e_flags e_val1 /* Flags. */
|
||||
@ -188,7 +144,7 @@ struct _event {
|
||||
|
||||
typedef struct _keylist {
|
||||
e_key_t value; /* Special value. */
|
||||
CHAR_T ch; /* Key. */
|
||||
int ch; /* Key. */
|
||||
} KEYLIST;
|
||||
extern KEYLIST keylist[];
|
||||
|
||||
@ -198,19 +154,6 @@ extern KEYLIST keylist[];
|
||||
(KEYS_WAITING(sp) && \
|
||||
FL_ISSET((sp)->wp->i_event[(sp)->wp->i_next].e_flags, CH_MAPPED))
|
||||
|
||||
/*
|
||||
* Ex/vi commands are generally separated by whitespace characters. We
|
||||
* can't use the standard isspace(3) macro because it returns true for
|
||||
* characters like ^K in the ASCII character set. The 4.4BSD isblank(3)
|
||||
* macro does exactly what we want, but it's not portable yet.
|
||||
*
|
||||
* XXX
|
||||
* Note side effect, ch is evaluated multiple times.
|
||||
*/
|
||||
#ifndef isblank
|
||||
#define isblank(ch) ((ch) == ' ' || (ch) == '\t')
|
||||
#endif
|
||||
|
||||
/* The "standard" tab width, for displaying things to users. */
|
||||
#define STANDARD_TAB 6
|
||||
|
||||
|
10
dist/nvi/common/msg.c
vendored
10
dist/nvi/common/msg.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msg.c,v 1.3 2009/01/18 03:45:50 lukem Exp $ */
|
||||
/* $NetBSD: msg.c,v 1.4 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -76,7 +76,7 @@ msgq(sp, mt, fmt, va_alist)
|
||||
char *bp, *mp;
|
||||
va_list ap;
|
||||
#ifndef NL_ARGMAX
|
||||
CHAR_T ch;
|
||||
int ch;
|
||||
char *rbp, *s_rbp;
|
||||
const char *t, *u;
|
||||
size_t cnt1, cnt2, soff;
|
||||
@ -214,12 +214,12 @@ retry: FREE_SPACE(sp, bp, blen);
|
||||
if (*p == '\0')
|
||||
break;
|
||||
++p;
|
||||
if (!isdigit(*p)) {
|
||||
if (!isdigit((unsigned char)*p)) {
|
||||
if (*p == '%')
|
||||
++p;
|
||||
continue;
|
||||
}
|
||||
for (u = p; *++p != '\0' && isdigit(*p););
|
||||
for (u = p; *++p != '\0' && isdigit((unsigned char)*p););
|
||||
if (*p != '$')
|
||||
continue;
|
||||
|
||||
@ -234,7 +234,7 @@ retry: FREE_SPACE(sp, bp, blen);
|
||||
goto ret;
|
||||
|
||||
/* Up to, and including the conversion character. */
|
||||
for (u = p; (ch = *++p) != '\0';)
|
||||
for (u = p; (ch = (unsigned char)*++p) != '\0';)
|
||||
if (isalpha(ch) &&
|
||||
strchr("diouxXfeEgGcspn", ch) != NULL)
|
||||
break;
|
||||
|
73
dist/nvi/common/multibyte.h
vendored
73
dist/nvi/common/multibyte.h
vendored
@ -1,20 +1,45 @@
|
||||
/* $NetBSD: multibyte.h,v 1.5 2009/12/23 12:44:21 mlelstv Exp $ */
|
||||
/* $NetBSD: multibyte.h,v 1.6 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
#ifndef MULTIBYTE_H
|
||||
#define MULTIBYTE_H
|
||||
|
||||
/*
|
||||
* Ex/vi commands are generally separated by whitespace characters. We
|
||||
* can't use the standard isspace(3) macro because it returns true for
|
||||
* characters like ^K in the ASCII character set. The 4.4BSD isblank(3)
|
||||
* macro does exactly what we want, but it's not portable yet.
|
||||
*
|
||||
* XXX
|
||||
* Note side effect, ch is evaluated multiple times.
|
||||
*/
|
||||
#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
|
||||
#define ISDIGIT(c) ((c) >= '0' && (c) <= '9')
|
||||
#define ISXDIGIT(c) (ISDIGIT(c) || \
|
||||
((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
|
||||
#define ISALPHA(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
|
||||
#define ISALNUM(c) (ISALPHA(c) || ISDIGIT(c))
|
||||
|
||||
/*
|
||||
* Fundamental character types.
|
||||
*
|
||||
* CHAR_T An integral type that can hold any character.
|
||||
* ARG_CHAR_T The type of a CHAR_T when passed as an argument using
|
||||
* traditional promotion rules. It should also be able
|
||||
* to be compared against any CHAR_T for equality without
|
||||
* problems.
|
||||
*
|
||||
* If no integral type can hold a character, don't even try the port.
|
||||
*/
|
||||
|
||||
#ifdef USE_WIDECHAR
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
typedef wchar_t RCHAR_T;
|
||||
typedef wchar_t CHAR_T;
|
||||
#if defined(__NetBSD__)
|
||||
#define MAX_CHAR_T 0xffffffff
|
||||
#else
|
||||
#define MAX_CHAR_T WCHAR_MAX
|
||||
#endif
|
||||
typedef u_int UCHAR_T;
|
||||
typedef wint_t ARG_CHAR_T;
|
||||
typedef wint_t UCHAR_T;
|
||||
|
||||
#define STRLEN wcslen
|
||||
#define STRTOL wcstol
|
||||
@ -22,20 +47,28 @@ typedef u_int UCHAR_T;
|
||||
#define SPRINTF swprintf
|
||||
#define STRCMP wcscmp
|
||||
#define STRPBRK wcspbrk
|
||||
#define TOUPPER towupper
|
||||
#define TOLOWER towlower
|
||||
#define ISUPPER iswupper
|
||||
#define ISBLANK2 iswblank
|
||||
#define ISCNTRL iswcntrl
|
||||
#define ISGRAPH iswgraph
|
||||
#define ISLOWER iswlower
|
||||
#define ISPUNCT iswpunct
|
||||
#define ISSPACE iswspace
|
||||
#define ISUPPER iswupper
|
||||
#define TOLOWER towlower
|
||||
#define TOUPPER towupper
|
||||
#define STRSET wmemset
|
||||
#define STRCHR wcschr
|
||||
|
||||
#define L(ch) L ## ch
|
||||
#define WS "%ls"
|
||||
#define WVS "%*ls"
|
||||
#define WC "%lc"
|
||||
|
||||
#else
|
||||
typedef char RCHAR_T;
|
||||
typedef u_char CHAR_T;
|
||||
#define MAX_CHAR_T 0xff
|
||||
typedef u_char UCHAR_T;
|
||||
typedef char CHAR_T;
|
||||
typedef int ARG_CHAR_T;
|
||||
typedef unsigned char UCHAR_T;
|
||||
|
||||
#define STRLEN strlen
|
||||
#define STRTOL strtol
|
||||
@ -43,14 +76,22 @@ typedef u_char UCHAR_T;
|
||||
#define SPRINTF snprintf
|
||||
#define STRCMP strcmp
|
||||
#define STRPBRK strpbrk
|
||||
#define TOUPPER toupper
|
||||
#define TOLOWER tolower
|
||||
#define ISUPPER isupper
|
||||
#define ISBLANK2 isblank
|
||||
#define ISCNTRL iscntrl
|
||||
#define ISGRAPH isgraph
|
||||
#define ISLOWER islower
|
||||
#define ISPUNCT ispunct
|
||||
#define ISSPACE isspace
|
||||
#define ISUPPER isupper
|
||||
#define TOLOWER tolower
|
||||
#define TOUPPER toupper
|
||||
#define STRSET memset
|
||||
#define STRCHR strchr
|
||||
|
||||
#define L(ch) ch
|
||||
#define WS "%s"
|
||||
#define WVS "%*s"
|
||||
#define WC "%c"
|
||||
|
||||
#endif
|
||||
|
||||
|
4
dist/nvi/common/options.c
vendored
4
dist/nvi/common/options.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: options.c,v 1.9 2010/11/14 20:53:54 schnoebe Exp $ */
|
||||
/* $NetBSD: options.c,v 1.10 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -639,7 +639,7 @@ opts_set(SCR *sp, ARGS **argv, const char *usage)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ISDIGIT(sep[0]))
|
||||
if (!ISDIGIT((UCHAR_T)sep[0]))
|
||||
goto badnum;
|
||||
if ((nret =
|
||||
nget_uslong(sp, &value, sep, &endp, 10)) != NUM_OK) {
|
||||
|
16
dist/nvi/common/seq.c
vendored
16
dist/nvi/common/seq.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: seq.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
|
||||
/* $NetBSD: seq.c,v 1.3 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -118,7 +118,7 @@ mem1: errno = sv_errno;
|
||||
}
|
||||
|
||||
/* Set the fast lookup bit. */
|
||||
if ((UCHAR_T)qp->input[0] < MAX_BIT_SEQ)
|
||||
if ((qp->input[0] & ~MAX_BIT_SEQ) == 0)
|
||||
bit_set(sp->gp->seqb, qp->input[0]);
|
||||
|
||||
return (0);
|
||||
@ -319,7 +319,7 @@ seq_save(SCR *sp, FILE *fp, const char *prefix, seq_t stype)
|
||||
CHAR_T *p;
|
||||
SEQ *qp;
|
||||
size_t olen;
|
||||
int ch;
|
||||
ARG_CHAR_T ch;
|
||||
|
||||
/* Write a sequence command for all keys the user defined. */
|
||||
for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) {
|
||||
@ -328,21 +328,21 @@ seq_save(SCR *sp, FILE *fp, const char *prefix, seq_t stype)
|
||||
if (prefix)
|
||||
(void)fprintf(fp, "%s", prefix);
|
||||
for (p = qp->input, olen = qp->ilen; olen > 0; --olen) {
|
||||
ch = *p++;
|
||||
ch = (UCHAR_T)*p++;
|
||||
if (ch == CH_LITERAL || ch == '|' ||
|
||||
isblank(ch) || KEY_VAL(sp, ch) == K_NL)
|
||||
ISBLANK(ch) || KEY_VAL(sp, ch) == K_NL)
|
||||
(void)putc(CH_LITERAL, fp);
|
||||
(void)putc(ch, fp);
|
||||
(void)fprintf(fp, WC, ch);
|
||||
}
|
||||
(void)putc(' ', fp);
|
||||
if (qp->output != NULL)
|
||||
for (p = qp->output,
|
||||
olen = qp->olen; olen > 0; --olen) {
|
||||
ch = *p++;
|
||||
ch = (UCHAR_T)*p++;
|
||||
if (ch == CH_LITERAL || ch == '|' ||
|
||||
KEY_VAL(sp, ch) == K_NL)
|
||||
(void)putc(CH_LITERAL, fp);
|
||||
(void)putc(ch, fp);
|
||||
(void)fprintf(fp, WC, ch);
|
||||
}
|
||||
(void)putc('\n', fp);
|
||||
}
|
||||
|
4
dist/nvi/common/util.c
vendored
4
dist/nvi/common/util.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.c,v 1.3 2008/12/05 22:51:42 christos Exp $ */
|
||||
/* $NetBSD: util.c,v 1.4 2011/03/21 14:53:02 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -94,7 +94,7 @@ nonblank(SCR *sp, db_recno_t lno, size_t *cnop)
|
||||
return (0);
|
||||
|
||||
for (cnt = off, p = &p[off],
|
||||
len -= off; len && isblank(*p); ++cnt, ++p, --len);
|
||||
len -= off; len && ISBLANK((UCHAR_T)*p); ++cnt, ++p, --len);
|
||||
|
||||
/* Set the return. */
|
||||
*cnop = len ? cnt : cnt - 1;
|
||||
|
64
dist/nvi/ex/ex.c
vendored
64
dist/nvi/ex/ex.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex.c,v 1.6 2009/12/23 12:44:22 mlelstv Exp $ */
|
||||
/* $NetBSD: ex.c,v 1.7 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -212,7 +212,7 @@ ex_cmd(SCR *sp)
|
||||
int cnt, delim, isaddr, namelen;
|
||||
int newscreen, notempty, tmp, vi_address;
|
||||
CHAR_T *arg1, *s, *p, *t;
|
||||
CHAR_T ch;
|
||||
ARG_CHAR_T ch;
|
||||
const CHAR_T *n;
|
||||
const char *np;
|
||||
|
||||
@ -265,7 +265,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
|
||||
/* Skip <blank>s, empty lines. */
|
||||
for (notempty = 0; ecp->clen > 0; ++ecp->cp, --ecp->clen)
|
||||
if ((ch = *ecp->cp) == '\n') {
|
||||
if ((ch = (UCHAR_T)*ecp->cp) == '\n') {
|
||||
++wp->if_lno;
|
||||
++ecp->if_lno;
|
||||
} else if (ISBLANK(ch))
|
||||
@ -282,7 +282,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
*/
|
||||
if (ecp->clen != 0 && ch == ':') {
|
||||
notempty = 1;
|
||||
while (--ecp->clen > 0 && (ch = *++ecp->cp) == ':');
|
||||
while (--ecp->clen > 0 && (ch = (UCHAR_T)*++ecp->cp) == ':');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -306,7 +306,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
|
||||
/* Skip whitespace. */
|
||||
for (; ecp->clen > 0; ++ecp->cp, --ecp->clen) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (!ISBLANK(ch))
|
||||
break;
|
||||
}
|
||||
@ -361,7 +361,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
* worked, historically).
|
||||
*/
|
||||
for (; ecp->clen > 0; ++ecp->cp, --ecp->clen) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (!ISBLANK(ch) && ch != ':')
|
||||
break;
|
||||
}
|
||||
@ -397,7 +397,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
} else {
|
||||
for (p = ecp->cp;
|
||||
ecp->clen > 0; --ecp->clen, ++ecp->cp)
|
||||
if (!ISALPHA(*ecp->cp))
|
||||
if (!ISALPHA((UCHAR_T)*ecp->cp))
|
||||
break;
|
||||
if ((namelen = ecp->cp - p) == 0) {
|
||||
msgq(sp, M_ERR, "080|Unknown command name");
|
||||
@ -486,7 +486,7 @@ loop: ecp = wp->ecq.lh_first;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
unknown: if (newscreen)
|
||||
p[0] = TOUPPER(p[0]);
|
||||
p[0] = TOUPPER((UCHAR_T)p[0]);
|
||||
ex_unknown(sp, p, namelen);
|
||||
goto err;
|
||||
}
|
||||
@ -530,7 +530,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
*/
|
||||
if ((ecp->cmd == &cmds[C_SHIFTL] && *p == '<') ||
|
||||
(ecp->cmd == &cmds[C_SHIFTR] && *p == '>')) {
|
||||
for (ch = *p;
|
||||
for (ch = (UCHAR_T)*p;
|
||||
ecp->clen > 0; --ecp->clen, ++ecp->cp)
|
||||
if (*ecp->cp != ch)
|
||||
break;
|
||||
@ -670,12 +670,12 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
--ecp->clen;
|
||||
for (arg1 = p = ecp->cp;
|
||||
ecp->clen > 0; --ecp->clen, ++ecp->cp) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (IS_ESCAPE(sp, ecp, ch) &&
|
||||
ecp->clen > 1) {
|
||||
++discard;
|
||||
--ecp->clen;
|
||||
ch = *++ecp->cp;
|
||||
ch = (UCHAR_T)*++ecp->cp;
|
||||
} else if (ISBLANK(ch))
|
||||
break;
|
||||
*p++ = ch;
|
||||
@ -697,11 +697,11 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
* are stripped as no longer useful.
|
||||
*/
|
||||
for (p = ecp->cp; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (ch == '\\' && ecp->clen > 1 && ecp->cp[1] == '\n') {
|
||||
++discard;
|
||||
--ecp->clen;
|
||||
ch = *++ecp->cp;
|
||||
ch = (UCHAR_T)*++ecp->cp;
|
||||
|
||||
++wp->if_lno;
|
||||
++ecp->if_lno;
|
||||
@ -719,7 +719,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
* <newline>. Otherwise, we're done.
|
||||
*/
|
||||
for (tmp = 0; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (ISBLANK(ch))
|
||||
tmp = 1;
|
||||
else
|
||||
@ -741,7 +741,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
if (!ISBLANK(ecp->cp[0]))
|
||||
break;
|
||||
|
||||
if (ISALNUM(ecp->cp[0]) || ecp->cp[0] == '|') {
|
||||
if (ISALNUM((UCHAR_T)ecp->cp[0]) || ecp->cp[0] == '|') {
|
||||
ecp->rcmd = cmds[C_SUBSTITUTE];
|
||||
ecp->rcmd.fn = ex_subagain;
|
||||
ecp->cmd = &ecp->rcmd;
|
||||
@ -783,9 +783,9 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
|
||||
*/
|
||||
vi_address = ecp->clen != 0 && ecp->cp[0] != '\n';
|
||||
for (p = ecp->cp; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
|
||||
ch = ecp->cp[0];
|
||||
ch = (UCHAR_T)ecp->cp[0];
|
||||
if (IS_ESCAPE(sp, ecp, ch) && ecp->clen > 1) {
|
||||
CHAR_T tmp1 = ecp->cp[1];
|
||||
ARG_CHAR_T tmp1 = (UCHAR_T)ecp->cp[1];
|
||||
if (tmp1 == '\n' || tmp1 == '|') {
|
||||
if (tmp1 == '\n') {
|
||||
++wp->if_lno;
|
||||
@ -1050,7 +1050,7 @@ end_case23: break;
|
||||
* command "d2" would be a delete into buffer '2', and
|
||||
* not a two-line deletion.
|
||||
*/
|
||||
if (!ISDIGIT(ecp->cp[0])) {
|
||||
if (!ISDIGIT((UCHAR_T)ecp->cp[0])) {
|
||||
ecp->buffer = *ecp->cp;
|
||||
++ecp->cp;
|
||||
--ecp->clen;
|
||||
@ -1060,7 +1060,7 @@ end_case23: break;
|
||||
case 'c': /* count [01+a] */
|
||||
++np;
|
||||
/* Validate any signed value. */
|
||||
if (!ISDIGIT(*ecp->cp) && (*np != '+' ||
|
||||
if (!ISDIGIT((UCHAR_T)*ecp->cp) && (*np != '+' ||
|
||||
(*ecp->cp != '+' && *ecp->cp != '-')))
|
||||
break;
|
||||
/* If a signed value, set appropriate flags. */
|
||||
@ -1154,7 +1154,7 @@ end_case23: break;
|
||||
*/
|
||||
for (p = t = ecp->cp;
|
||||
ecp->clen > 0; --ecp->clen, ++ecp->cp) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (IS_ESCAPE(sp,
|
||||
ecp, ch) && ecp->clen > 1) {
|
||||
--ecp->clen;
|
||||
@ -1172,7 +1172,7 @@ end_case23: break;
|
||||
/* Delete intervening whitespace. */
|
||||
for (; ecp->clen > 0;
|
||||
--ecp->clen, ++ecp->cp) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (!ISBLANK(ch))
|
||||
break;
|
||||
}
|
||||
@ -1182,7 +1182,7 @@ end_case23: break;
|
||||
/* Followed by the string. */
|
||||
for (p = t = ecp->cp; ecp->clen > 0;
|
||||
--ecp->clen, ++ecp->cp, ++p) {
|
||||
ch = *ecp->cp;
|
||||
ch = (UCHAR_T)*ecp->cp;
|
||||
if (IS_ESCAPE(sp,
|
||||
ecp, ch) && ecp->clen > 1) {
|
||||
--ecp->clen;
|
||||
@ -1222,7 +1222,7 @@ arg_cnt_chk: if (*++np != 'N') { /* N */
|
||||
|
||||
/* Skip trailing whitespace. */
|
||||
for (; ecp->clen > 0; --ecp->clen) {
|
||||
ch = *ecp->cp++;
|
||||
ch = (UCHAR_T)*ecp->cp++;
|
||||
if (!ISBLANK(ch))
|
||||
break;
|
||||
}
|
||||
@ -1586,7 +1586,7 @@ err: /*
|
||||
*/
|
||||
if (ecp->save_cmdlen == 0)
|
||||
for (; ecp->clen; --ecp->clen) {
|
||||
ch = *ecp->cp++;
|
||||
ch = (UCHAR_T)*ecp->cp++;
|
||||
if (IS_ESCAPE(sp, ecp, ch) && ecp->clen > 1) {
|
||||
--ecp->clen;
|
||||
++ecp->cp;
|
||||
@ -1842,7 +1842,7 @@ ex_line(SCR *sp, EXCMD *ecp, MARK *mp, int *isaddrp, int *errp)
|
||||
F_CLR(ecp, E_DELTA);
|
||||
|
||||
/* No addresses permitted until a file has been read in. */
|
||||
if (sp->ep == NULL && strchr("$0123456789'\\/?.+-^", *ecp->cp)) {
|
||||
if (sp->ep == NULL && STRCHR(L"$0123456789'\\/?.+-^", *ecp->cp)) {
|
||||
ex_badaddr(sp, NULL, A_EMPTY, NUM_OK);
|
||||
*errp = 1;
|
||||
return (0);
|
||||
@ -1953,7 +1953,7 @@ search: mp->lno = sp->lno;
|
||||
* the '+' could be omitted. (This feature is found in ed
|
||||
* as well.)
|
||||
*/
|
||||
if (ecp->clen > 1 && ISDIGIT(ecp->cp[1]))
|
||||
if (ecp->clen > 1 && ISDIGIT((UCHAR_T)ecp->cp[1]))
|
||||
*ecp->cp = '+';
|
||||
else {
|
||||
++ecp->cp;
|
||||
@ -1964,14 +1964,14 @@ search: mp->lno = sp->lno;
|
||||
|
||||
/* Skip trailing <blank>s. */
|
||||
for (; ecp->clen > 0 &&
|
||||
ISBLANK(ecp->cp[0]); ++ecp->cp, --ecp->clen);
|
||||
ISBLANK((UCHAR_T)ecp->cp[0]); ++ecp->cp, --ecp->clen);
|
||||
|
||||
/*
|
||||
* Evaluate any offset. If no address yet found, the offset
|
||||
* is relative to ".".
|
||||
*/
|
||||
total = 0;
|
||||
if (ecp->clen != 0 && (ISDIGIT(ecp->cp[0]) ||
|
||||
if (ecp->clen != 0 && (ISDIGIT((UCHAR_T)ecp->cp[0]) ||
|
||||
ecp->cp[0] == '+' || ecp->cp[0] == '-' ||
|
||||
ecp->cp[0] == '^')) {
|
||||
if (!*isaddrp) {
|
||||
@ -2007,14 +2007,14 @@ search: mp->lno = sp->lno;
|
||||
*/
|
||||
F_SET(ecp, E_DELTA);
|
||||
for (;;) {
|
||||
for (; ecp->clen > 0 && ISBLANK(ecp->cp[0]);
|
||||
for (; ecp->clen > 0 && ISBLANK((UCHAR_T)ecp->cp[0]);
|
||||
++ecp->cp, --ecp->clen);
|
||||
if (ecp->clen == 0 || (!ISDIGIT(ecp->cp[0]) &&
|
||||
if (ecp->clen == 0 || (!ISDIGIT((UCHAR_T)ecp->cp[0]) &&
|
||||
ecp->cp[0] != '+' && ecp->cp[0] != '-' &&
|
||||
ecp->cp[0] != '^'))
|
||||
break;
|
||||
if (!ISDIGIT(ecp->cp[0]) &&
|
||||
!ISDIGIT(ecp->cp[1])) {
|
||||
if (!ISDIGIT((UCHAR_T)ecp->cp[0]) &&
|
||||
!ISDIGIT((UCHAR_T)ecp->cp[1])) {
|
||||
total += ecp->cp[0] == '+' ? 1 : -1;
|
||||
--ecp->clen;
|
||||
++ecp->cp;
|
||||
|
4
dist/nvi/ex/ex_abbrev.c
vendored
4
dist/nvi/ex/ex_abbrev.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_abbrev.c,v 1.1.1.2 2008/05/18 14:31:09 aymeric Exp $ */
|
||||
/* $NetBSD: ex_abbrev.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -71,7 +71,7 @@ ex_abbr(SCR *sp, EXCMD *cmdp)
|
||||
return (1);
|
||||
}
|
||||
for (p = cmdp->argv[0]->bp; *p != '\0'; ++p)
|
||||
if (ISBLANK(p[0])) {
|
||||
if (ISBLANK((UCHAR_T)p[0])) {
|
||||
msgq(sp, M_ERR,
|
||||
"107|Abbreviations may not contain tabs or spaces");
|
||||
return (1);
|
||||
|
17
dist/nvi/ex/ex_argv.c
vendored
17
dist/nvi/ex/ex_argv.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_argv.c,v 1.3 2009/01/13 15:43:27 christos Exp $ */
|
||||
/* $NetBSD: ex_argv.c,v 1.4 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
@ -105,7 +105,7 @@ argv_exp1(SCR *sp, EXCMD *excp, const CHAR_T *cmd, size_t cmdlen, int is_bang)
|
||||
/* If it's empty, we're done. */
|
||||
if (len != 0) {
|
||||
for (p = bp, t = bp + len; p < t; ++p)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (p == t)
|
||||
goto ret;
|
||||
@ -252,15 +252,16 @@ argv_exp3(SCR *sp, EXCMD *excp, const CHAR_T *cmd, size_t cmdlen)
|
||||
{
|
||||
EX_PRIVATE *exp;
|
||||
size_t len;
|
||||
int ch, off;
|
||||
ARG_CHAR_T ch;
|
||||
int off;
|
||||
const CHAR_T *ap;
|
||||
CHAR_T *p;
|
||||
|
||||
for (exp = EXP(sp); cmdlen > 0; ++exp->argsoff) {
|
||||
/* Skip any leading whitespace. */
|
||||
for (; cmdlen > 0; --cmdlen, ++cmd) {
|
||||
ch = *cmd;
|
||||
if (!isblank(ch))
|
||||
ch = (UCHAR_T)*cmd;
|
||||
if (!ISBLANK(ch))
|
||||
break;
|
||||
}
|
||||
if (cmdlen == 0)
|
||||
@ -276,11 +277,11 @@ argv_exp3(SCR *sp, EXCMD *excp, const CHAR_T *cmd, size_t cmdlen)
|
||||
* character.
|
||||
*/
|
||||
for (ap = cmd, len = 0; cmdlen > 0; ++cmd, --cmdlen, ++len) {
|
||||
ch = *cmd;
|
||||
ch = (UCHAR_T)*cmd;
|
||||
if (IS_ESCAPE(sp, excp, ch) && cmdlen > 1) {
|
||||
++cmd;
|
||||
--cmdlen;
|
||||
} else if (isblank(ch))
|
||||
} else if (ISBLANK(ch))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -745,7 +746,7 @@ alloc_err: rval = SEXP_ERR;
|
||||
rval = SEXP_EXPANSION_ERR;
|
||||
|
||||
for (p = bp; len; ++p, --len)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (len == 0)
|
||||
rval = SEXP_EXPANSION_ERR;
|
||||
|
8
dist/nvi/ex/ex_cscope.c
vendored
8
dist/nvi/ex/ex_cscope.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_cscope.c,v 1.6 2010/05/13 17:52:11 tnozaki Exp $ */
|
||||
/* $NetBSD: ex_cscope.c,v 1.7 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994, 1996
|
||||
@ -128,18 +128,18 @@ ex_cscope(SCR *sp, EXCMD *cmdp)
|
||||
|
||||
/* Skip leading whitespace. */
|
||||
for (p = cmdp->argv[0]->bp, i = cmdp->argv[0]->len; i > 0; --i, ++p)
|
||||
if (!isspace(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (i == 0)
|
||||
goto usage;
|
||||
|
||||
/* Skip the command to any arguments. */
|
||||
for (cmd = p; i > 0; --i, ++p)
|
||||
if (isspace(*p))
|
||||
if (ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (*p != '\0') {
|
||||
*p++ = '\0';
|
||||
for (; *p && isspace(*p); ++p);
|
||||
for (; *p && ISBLANK((UCHAR_T)*p); ++p);
|
||||
}
|
||||
|
||||
INT2CHAR(sp, cmd, STRLEN(cmd) + 1, np, nlen);
|
||||
|
6
dist/nvi/ex/ex_display.c
vendored
6
dist/nvi/ex/ex_display.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_display.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
|
||||
/* $NetBSD: ex_display.c,v 1.3 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -91,7 +91,7 @@ bdisplay(SCR *sp)
|
||||
|
||||
/* Display regular cut buffers. */
|
||||
for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
|
||||
if (isdigit(cbp->name))
|
||||
if (ISDIGIT(cbp->name))
|
||||
continue;
|
||||
if (cbp->textq.cqh_first != (void *)&cbp->textq)
|
||||
db(sp, cbp, NULL);
|
||||
@ -100,7 +100,7 @@ bdisplay(SCR *sp)
|
||||
}
|
||||
/* Display numbered buffers. */
|
||||
for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
|
||||
if (!isdigit(cbp->name))
|
||||
if (!ISDIGIT(cbp->name))
|
||||
continue;
|
||||
if (cbp->textq.cqh_first != (void *)&cbp->textq)
|
||||
db(sp, cbp, NULL);
|
||||
|
4
dist/nvi/ex/ex_global.c
vendored
4
dist/nvi/ex/ex_global.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_global.c,v 1.3 2009/11/14 23:31:37 christos Exp $ */
|
||||
/* $NetBSD: ex_global.c,v 1.4 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -92,7 +92,7 @@ ex_g_setup(SCR *sp, EXCMD *cmdp, enum which cmd)
|
||||
if (cmdp->argc == 0)
|
||||
goto usage;
|
||||
for (p = cmdp->argv[0]->bp; ISBLANK(*p); ++p);
|
||||
if (*p == '\0' || ISALNUM(*p) ||
|
||||
if (*p == '\0' || ISALNUM((UCHAR_T)*p) ||
|
||||
*p == '\\' || *p == '|' || *p == '\n') {
|
||||
usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
|
||||
return (1);
|
||||
|
13
dist/nvi/ex/ex_join.c
vendored
13
dist/nvi/ex/ex_join.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_join.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
|
||||
/* $NetBSD: ex_join.c,v 1.3 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -38,7 +38,8 @@ ex_join(SCR *sp, EXCMD *cmdp)
|
||||
{
|
||||
db_recno_t from, to;
|
||||
size_t blen, clen, len, tlen;
|
||||
int echar = 0, extra, first;
|
||||
ARG_CHAR_T echar = 0;
|
||||
int extra, first;
|
||||
CHAR_T *bp, *tbp = NULL;
|
||||
CHAR_T *p;
|
||||
|
||||
@ -105,17 +106,17 @@ ex_join(SCR *sp, EXCMD *cmdp)
|
||||
*/
|
||||
extra = 0;
|
||||
if (!first && !FL_ISSET(cmdp->iflags, E_C_FORCE)) {
|
||||
if (isblank(echar))
|
||||
for (; len && isblank(*p); --len, ++p);
|
||||
if (ISBLANK(echar))
|
||||
for (; len && ISBLANK((UCHAR_T)*p); --len, ++p);
|
||||
else if (p[0] != ')') {
|
||||
if (strchr(".?!", echar)) {
|
||||
if (STRCHR(L(".?!"), echar)) {
|
||||
*tbp++ = ' ';
|
||||
++clen;
|
||||
extra = 1;
|
||||
}
|
||||
*tbp++ = ' ';
|
||||
++clen;
|
||||
for (; len && isblank(*p); --len, ++p);
|
||||
for (; len && ISBLANK((UCHAR_T)*p); --len, ++p);
|
||||
}
|
||||
}
|
||||
|
||||
|
6
dist/nvi/ex/ex_map.c
vendored
6
dist/nvi/ex/ex_map.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_map.c,v 1.1.1.2 2008/05/18 14:31:16 aymeric Exp $ */
|
||||
/* $NetBSD: ex_map.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -71,8 +71,8 @@ ex_map(SCR *sp, EXCMD *cmdp)
|
||||
* call it as well. Note, the SEQ_FUNCMAP type is persistent across
|
||||
* screen types, maybe the next screen type will get it right.
|
||||
*/
|
||||
if (input[0] == '#' && isdigit(input[1])) {
|
||||
for (p = input + 2; isdigit(*p); ++p);
|
||||
if (input[0] == '#' && ISDIGIT((UCHAR_T)input[1])) {
|
||||
for (p = input + 2; ISDIGIT((UCHAR_T)*p); ++p);
|
||||
if (p[0] != '\0')
|
||||
goto nofunc;
|
||||
|
||||
|
4
dist/nvi/ex/ex_perl.c
vendored
4
dist/nvi/ex/ex_perl.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_perl.c,v 1.1.1.2 2008/05/18 14:31:16 aymeric Exp $ */
|
||||
/* $NetBSD: ex_perl.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -53,7 +53,7 @@ ex_perl(SCR *sp, EXCMD *cmdp)
|
||||
if (cmdp->argc != 0)
|
||||
for (p = cmdp->argv[0]->bp,
|
||||
len = cmdp->argv[0]->len; len > 0; --len, ++p)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (cmdp->argc == 0 || len == 0) {
|
||||
ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
|
||||
|
7
dist/nvi/ex/ex_shell.c
vendored
7
dist/nvi/ex/ex_shell.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_shell.c,v 1.4 2009/11/15 18:43:28 dsl Exp $ */
|
||||
/* $NetBSD: ex_shell.c,v 1.5 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -20,6 +20,7 @@ static const char sccsid[] = "Id: ex_shell.c,v 10.42 2003/11/05 17:11:54 skimo E
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <bitstring.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
@ -169,7 +170,7 @@ proc_wait(SCR *sp, long int pid, const char *cmd, int silent, int okpipe)
|
||||
* exit before reading all of its input.
|
||||
*/
|
||||
if (WIFSIGNALED(pstat) && (!okpipe || WTERMSIG(pstat) != SIGPIPE)) {
|
||||
for (; isblank(*cmd); ++cmd);
|
||||
for (; isblank((unsigned char)*cmd); ++cmd);
|
||||
p = msg_print(sp, cmd, &nf);
|
||||
len = strlen(p);
|
||||
msgq(sp, M_ERR, "%.*s%s: received signal: %s%s",
|
||||
@ -191,7 +192,7 @@ proc_wait(SCR *sp, long int pid, const char *cmd, int silent, int okpipe)
|
||||
* practice.
|
||||
*/
|
||||
if (!silent) {
|
||||
for (; isblank(*cmd); ++cmd);
|
||||
for (; isblank((unsigned char)*cmd); ++cmd);
|
||||
p = msg_print(sp, cmd, &nf);
|
||||
len = strlen(p);
|
||||
msgq(sp, M_ERR, "%.*s%s: exited with status %d",
|
||||
|
18
dist/nvi/ex/ex_subst.c
vendored
18
dist/nvi/ex/ex_subst.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_subst.c,v 1.3 2009/12/23 12:44:22 mlelstv Exp $ */
|
||||
/* $NetBSD: ex_subst.c,v 1.4 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -55,7 +55,7 @@ ex_s(SCR *sp, EXCMD *cmdp)
|
||||
regex_t *re;
|
||||
size_t blen, len;
|
||||
u_int flags;
|
||||
int delim;
|
||||
ARG_CHAR_T delim;
|
||||
CHAR_T *bp, *p, *ptrn, *rep, *t;
|
||||
|
||||
/*
|
||||
@ -73,14 +73,14 @@ ex_s(SCR *sp, EXCMD *cmdp)
|
||||
goto subagain;
|
||||
for (p = cmdp->argv[0]->bp,
|
||||
len = cmdp->argv[0]->len; len > 0; --len, ++p) {
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
}
|
||||
if (len == 0)
|
||||
subagain: return (ex_subagain(sp, cmdp));
|
||||
|
||||
delim = *p++;
|
||||
if (isalnum(delim) || delim == '\\')
|
||||
delim = (UCHAR_T)*p++;
|
||||
if (ISALNUM(delim) || delim == '\\')
|
||||
return (s(sp, cmdp, p, &sp->subre_c, SUB_MUSTSETR));
|
||||
|
||||
/*
|
||||
@ -912,7 +912,7 @@ re_compile(SCR *sp, CHAR_T *ptrn, size_t plen, CHAR_T **ptrnp, size_t *lenp, reg
|
||||
}
|
||||
if (LF_ISSET(SEARCH_ICL)) {
|
||||
iclower: for (p = ptrn, len = plen; len > 0; ++p, --len)
|
||||
if (ISUPPER(*p))
|
||||
if (ISUPPER((UCHAR_T)*p))
|
||||
break;
|
||||
if (len == 0)
|
||||
reflags |= REG_ICASE;
|
||||
@ -1355,8 +1355,8 @@ re_sub(SCR *sp, CHAR_T *ip, CHAR_T **lbp, size_t *lbclenp, size_t *lblenp, regma
|
||||
* all escaping characters. This (hopefully) matches historic practice.
|
||||
*/
|
||||
#define OUTCH(ch, nltrans) { \
|
||||
CHAR_T __ch = (ch); \
|
||||
u_int __value = KEY_VAL(sp, __ch); \
|
||||
ARG_CHAR_T __ch = (ch); \
|
||||
e_key_t __value = KEY_VAL(sp, __ch); \
|
||||
if (nltrans && (__value == K_CR || __value == K_NL)) { \
|
||||
NEEDNEWLINE(sp); \
|
||||
sp->newl[sp->newl_cnt++] = lbclen; \
|
||||
@ -1413,7 +1413,7 @@ subzero: if (match[no].rm_so == -1 ||
|
||||
break;
|
||||
mlen = match[no].rm_eo - match[no].rm_so;
|
||||
for (t = ip + match[no].rm_so; mlen--; ++t)
|
||||
OUTCH(*t, 0);
|
||||
OUTCH((UCHAR_T)*t, 0);
|
||||
continue;
|
||||
case 'e':
|
||||
case 'E':
|
||||
|
4
dist/nvi/ex/ex_tag.c
vendored
4
dist/nvi/ex/ex_tag.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_tag.c,v 1.8 2010/05/13 17:52:11 tnozaki Exp $ */
|
||||
/* $NetBSD: ex_tag.c,v 1.9 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -962,7 +962,7 @@ ctag_search(SCR *sp, CHAR_T *search, size_t slen, char *tag)
|
||||
* used a line number, not a search string. I got complaints, so
|
||||
* people are still using the format. POSIX 1003.2 permits it.
|
||||
*/
|
||||
if (ISDIGIT(search[0])) {
|
||||
if (ISDIGIT((UCHAR_T)search[0])) {
|
||||
INT2CHAR(sp, search, slen+1, np, nlen);
|
||||
m.lno = atoi(np);
|
||||
if (!db_exist(sp, m.lno)) {
|
||||
|
4
dist/nvi/ex/ex_tcl.c
vendored
4
dist/nvi/ex/ex_tcl.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_tcl.c,v 1.1.1.2 2008/05/18 14:31:20 aymeric Exp $ */
|
||||
/* $NetBSD: ex_tcl.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -57,7 +57,7 @@ ex_tcl(SCR *sp, EXCMD *cmdp)
|
||||
if (cmdp->argc != 0)
|
||||
for (p = cmdp->argv[0]->bp,
|
||||
len = cmdp->argv[0]->len; len > 0; --len, ++p)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
if (cmdp->argc == 0 || len == 0) {
|
||||
ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
|
||||
|
4
dist/nvi/ex/ex_txt.c
vendored
4
dist/nvi/ex/ex_txt.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_txt.c,v 1.5 2009/11/14 23:40:11 christos Exp $ */
|
||||
/* $NetBSD: ex_txt.c,v 1.6 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -246,7 +246,7 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q);
|
||||
*/
|
||||
if (LF_ISSET(TXT_CNTRLD)) {
|
||||
for (cnt = 0; cnt < tp->len; ++cnt)
|
||||
if (!isblank(tp->lb[cnt]))
|
||||
if (!ISBLANK((UCHAR_T)tp->lb[cnt]))
|
||||
break;
|
||||
if (cnt == tp->len) {
|
||||
tp->len = 1;
|
||||
|
10
dist/nvi/ex/ex_usage.c
vendored
10
dist/nvi/ex/ex_usage.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_usage.c,v 1.5 2010/05/13 17:52:11 tnozaki Exp $ */
|
||||
/* $NetBSD: ex_usage.c,v 1.6 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -68,9 +68,9 @@ ex_usage(SCR *sp, EXCMD *cmdp)
|
||||
switch (cmdp->argc) {
|
||||
case 1:
|
||||
ap = cmdp->argv[0];
|
||||
if (ISUPPER(ap->bp[0])) {
|
||||
if (ISUPPER((UCHAR_T)ap->bp[0])) {
|
||||
newscreen = 1;
|
||||
ap->bp[0] = TOLOWER(ap->bp[0]);
|
||||
ap->bp[0] = TOLOWER((UCHAR_T)ap->bp[0]);
|
||||
} else
|
||||
newscreen = 0;
|
||||
for (cp = cmds; cp->name != NULL &&
|
||||
@ -81,7 +81,7 @@ ex_usage(SCR *sp, EXCMD *cmdp)
|
||||
size_t nlen;
|
||||
|
||||
if (newscreen)
|
||||
ap->bp[0] = TOUPPER(ap->bp[0]);
|
||||
ap->bp[0] = TOUPPER((UCHAR_T)ap->bp[0]);
|
||||
|
||||
INT2CHAR(sp, ap->bp, ap->len + 1, nstr, nlen);
|
||||
(void)ex_printf(sp, "The %.*s command is unknown\n",
|
||||
@ -119,7 +119,7 @@ ex_usage(SCR *sp, EXCMD *cmdp)
|
||||
name = L("^D");
|
||||
else if (F_ISSET(cp, E_NEWSCREEN)) {
|
||||
nb[0] = L('[');
|
||||
nb[1] = TOUPPER(cp->name[0]);
|
||||
nb[1] = TOUPPER((UCHAR_T)cp->name[0]);
|
||||
nb[2] = cp->name[0];
|
||||
nb[3] = L(']');
|
||||
for (name = cp->name + 1,
|
||||
|
8
dist/nvi/ex/ex_write.c
vendored
8
dist/nvi/ex/ex_write.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ex_write.c,v 1.3 2009/10/31 14:30:55 dsl Exp $ */
|
||||
/* $NetBSD: ex_write.c,v 1.4 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -145,7 +145,7 @@ exwr(SCR *sp, EXCMD *cmdp, enum which cmd)
|
||||
|
||||
/* Skip any leading whitespace. */
|
||||
if (cmdp->argc != 0)
|
||||
for (p = cmdp->argv[0]->bp; *p != '\0' && isblank(*p); ++p);
|
||||
for (p = cmdp->argv[0]->bp; *p != '\0' && ISBLANK((UCHAR_T)*p); ++p);
|
||||
|
||||
/* If "write !" it's a pipe to a utility. */
|
||||
if (cmdp->argc != 0 && cmd == WRITE && *p == '!') {
|
||||
@ -156,7 +156,7 @@ exwr(SCR *sp, EXCMD *cmdp, enum which cmd)
|
||||
}
|
||||
|
||||
/* Expand the argument. */
|
||||
for (++p; *p && isblank(*p); ++p);
|
||||
for (++p; *p && ISBLANK((UCHAR_T)*p); ++p);
|
||||
if (*p == '\0') {
|
||||
ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
|
||||
return (1);
|
||||
@ -203,7 +203,7 @@ exwr(SCR *sp, EXCMD *cmdp, enum which cmd)
|
||||
LF_SET(FS_APPEND);
|
||||
|
||||
/* Skip ">>" and whitespace. */
|
||||
for (p += 2; *p && isblank(*p); ++p);
|
||||
for (p += 2; *p && ISBLANK((UCHAR_T)*p); ++p);
|
||||
}
|
||||
|
||||
/* If no other arguments, just write the file back. */
|
||||
|
6
dist/nvi/ip/ip_main.c
vendored
6
dist/nvi/ip/ip_main.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_main.c,v 1.1.1.2 2008/05/18 14:31:24 aymeric Exp $ */
|
||||
/* $NetBSD: ip_main.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996
|
||||
@ -211,10 +211,10 @@ get_fds(char *ip_arg, int *i_fd, int *o_fd)
|
||||
* file descriptor from the screen, the second is the file descriptor
|
||||
* to the screen.
|
||||
*/
|
||||
if (!ip_arg || !isdigit(ip_arg[0]))
|
||||
if (!ip_arg || !isdigit((unsigned char)ip_arg[0]))
|
||||
goto usage;
|
||||
*i_fd = strtol(ip_arg, &ep, 10);
|
||||
if (ep[0] != '.' || !isdigit(ep[1]))
|
||||
if (ep[0] != '.' || !isdigit((unsigned char)ep[1]))
|
||||
goto usage;
|
||||
*o_fd = strtol(++ep, &ep, 10);
|
||||
if (ep[0] != '\0') {
|
||||
|
12
dist/nvi/motif_l/m_vi.c
vendored
12
dist/nvi/motif_l/m_vi.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: m_vi.c,v 1.1.1.2 2008/05/18 14:31:29 aymeric Exp $ */
|
||||
/* $NetBSD: m_vi.c,v 1.2 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996
|
||||
@ -1107,10 +1107,10 @@ int *start;
|
||||
|
||||
switch ( select_type ) {
|
||||
case select_word:
|
||||
if ( *start == 0 || isspace( cur_screen->characters[*start] ) )
|
||||
if ( *start == 0 || isspace( (unsigned char)cur_screen->characters[*start] ) )
|
||||
return;
|
||||
for (;;) {
|
||||
if ( isspace( cur_screen->characters[*start-1] ) )
|
||||
if ( isspace( (unsigned char)cur_screen->characters[*start-1] ) )
|
||||
return;
|
||||
if ( --(*start) == 0 )
|
||||
return;
|
||||
@ -1136,10 +1136,10 @@ int *end;
|
||||
|
||||
switch ( select_type ) {
|
||||
case select_word:
|
||||
if ( *end == last || isspace( cur_screen->characters[*end] ) )
|
||||
if ( *end == last || isspace( (unsigned char)cur_screen->characters[*end] ) )
|
||||
return;
|
||||
for (;;) {
|
||||
if ( isspace( cur_screen->characters[*end+1] ) )
|
||||
if ( isspace( (unsigned char)cur_screen->characters[*end+1] ) )
|
||||
return;
|
||||
if ( ++(*end) == last )
|
||||
return;
|
||||
@ -1381,7 +1381,7 @@ __vi_set_word_at_caret(xvi_screen *this_screen)
|
||||
|
||||
/* Note that this really ought to be done by core due to wrapping issues */
|
||||
for ( end = start = CharAt( this_screen, newy, newx );
|
||||
(isalnum( *end ) || *end == '_') && (newx < this_screen->cols);
|
||||
(isalnum( (unsigned char)*end ) || *end == '_') && (newx < this_screen->cols);
|
||||
end++, newx++
|
||||
);
|
||||
save = *end;
|
||||
|
14
dist/nvi/regex/regcomp.c
vendored
14
dist/nvi/regex/regcomp.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: regcomp.c,v 1.5 2009/08/30 14:57:51 tnozaki Exp $ */
|
||||
/* $NetBSD: regcomp.c,v 1.6 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
|
||||
@ -414,7 +414,7 @@ p_ere_exp(register struct parse *p)
|
||||
ordinary(p, c);
|
||||
break;
|
||||
case '{': /* okay as ordinary except if digit follows */
|
||||
(void)REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT);
|
||||
(void)REQUIRE(!MORE() || !ISDIGIT((UCHAR_T)PEEK()), REG_BADRPT);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
ordinary(p, c);
|
||||
@ -426,7 +426,7 @@ p_ere_exp(register struct parse *p)
|
||||
c = PEEK();
|
||||
/* we call { a repetition if followed by a digit */
|
||||
if (!( c == '*' || c == '+' || c == '?' ||
|
||||
(c == '{' && MORE2() && isdigit(PEEK2())) ))
|
||||
(c == '{' && MORE2() && ISDIGIT((UCHAR_T)PEEK2())) ))
|
||||
return; /* no repetition, we're done */
|
||||
NEXT();
|
||||
|
||||
@ -455,7 +455,7 @@ p_ere_exp(register struct parse *p)
|
||||
case '{':
|
||||
count = p_count(p);
|
||||
if (EAT(',')) {
|
||||
if (isdigit(PEEK())) {
|
||||
if (ISDIGIT((UCHAR_T)PEEK())) {
|
||||
count2 = p_count(p);
|
||||
(void)REQUIRE(count <= count2, REG_BADBR);
|
||||
} else /* single number with comma */
|
||||
@ -476,7 +476,7 @@ p_ere_exp(register struct parse *p)
|
||||
return;
|
||||
c = PEEK();
|
||||
if (!( c == '*' || c == '+' || c == '?' ||
|
||||
(c == '{' && MORE2() && isdigit(PEEK2())) ) )
|
||||
(c == '{' && MORE2() && ISDIGIT((UCHAR_T)PEEK2())) ) )
|
||||
return;
|
||||
SETERROR(REG_BADRPT);
|
||||
}
|
||||
@ -639,7 +639,7 @@ p_simp_re(register struct parse *p, int starordinary)
|
||||
} else if (EATTWO('\\', '{')) {
|
||||
count = p_count(p);
|
||||
if (EAT(',')) {
|
||||
if (MORE() && isdigit(PEEK())) {
|
||||
if (MORE() && ISDIGIT((UCHAR_T)PEEK())) {
|
||||
count2 = p_count(p);
|
||||
(void)REQUIRE(count <= count2, REG_BADBR);
|
||||
} else /* single number with comma */
|
||||
@ -669,7 +669,7 @@ p_count(register struct parse *p)
|
||||
register int count = 0;
|
||||
register int ndigits = 0;
|
||||
|
||||
while (MORE() && isdigit(PEEK()) && count <= DUPMAX) {
|
||||
while (MORE() && ISDIGIT((UCHAR_T)PEEK()) && count <= DUPMAX) {
|
||||
count = count*10 + (GETNEXT() - '0');
|
||||
ndigits++;
|
||||
}
|
||||
|
4
dist/nvi/regex/regex2.h
vendored
4
dist/nvi/regex/regex2.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: regex2.h,v 1.2 2009/01/02 00:32:11 tnozaki Exp $ */
|
||||
/* $NetBSD: regex2.h,v 1.3 2011/03/21 14:53:03 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
|
||||
@ -171,4 +171,4 @@ struct re_guts {
|
||||
|
||||
/* misc utilities */
|
||||
#define OUT WEOF /* a non-character value */
|
||||
#define ISWORD(c) (((UCHAR_T)c <= 0xFF && isalnum((unsigned char)c)) || (c) == '_')
|
||||
#define ISWORD(c) ((c) == '_' || (ISGRAPH((UCHAR_T)c) && !ISPUNCT((UCHAR_T)c)))
|
||||
|
10
dist/nvi/vi/getc.c
vendored
10
dist/nvi/vi/getc.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getc.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: getc.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -123,12 +123,12 @@ cs_next(SCR *sp, VCS *csp)
|
||||
int
|
||||
cs_fspace(SCR *sp, VCS *csp)
|
||||
{
|
||||
if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
|
||||
if (csp->cs_flags != 0 || !ISBLANK2(csp->cs_ch))
|
||||
return (0);
|
||||
for (;;) {
|
||||
if (cs_next(sp, csp))
|
||||
return (1);
|
||||
if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
|
||||
if (csp->cs_flags != 0 || !ISBLANK2(csp->cs_ch))
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
@ -147,7 +147,7 @@ cs_fblank(SCR *sp, VCS *csp)
|
||||
if (cs_next(sp, csp))
|
||||
return (1);
|
||||
if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
|
||||
(csp->cs_flags == 0 && isblank(csp->cs_ch)))
|
||||
(csp->cs_flags == 0 && ISBLANK2(csp->cs_ch)))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
@ -216,7 +216,7 @@ cs_bblank(SCR *sp, VCS *csp)
|
||||
if (cs_prev(sp, csp))
|
||||
return (1);
|
||||
if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
|
||||
(csp->cs_flags == 0 && isblank(csp->cs_ch)))
|
||||
(csp->cs_flags == 0 && ISBLANK2(csp->cs_ch)))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
22
dist/nvi/vi/v_increment.c
vendored
22
dist/nvi/vi/v_increment.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_increment.c,v 1.4 2009/08/11 21:28:02 aymeric Exp $ */
|
||||
/* $NetBSD: v_increment.c,v 1.5 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -93,7 +93,7 @@ v_increment(SCR *sp, VICMD *vp)
|
||||
* implies moving the cursor to its beginning, if we moved, refresh
|
||||
* now.
|
||||
*/
|
||||
for (beg = vp->m_start.cno; beg < len && isspace(p[beg]); ++beg);
|
||||
for (beg = vp->m_start.cno; beg < len && ISSPACE((UCHAR_T)p[beg]); ++beg);
|
||||
if (beg >= len)
|
||||
goto nonum;
|
||||
if (beg != vp->m_start.cno) {
|
||||
@ -101,10 +101,8 @@ v_increment(SCR *sp, VICMD *vp)
|
||||
(void)vs_refresh(sp, 0);
|
||||
}
|
||||
|
||||
#undef ishex
|
||||
#define ishex(c) (isdigit(c) || STRCHR(L("abcdefABCDEF"), c))
|
||||
#undef isoctal
|
||||
#define isoctal(c) (isdigit(c) && (c) != '8' && (c) != '9')
|
||||
#define isoctal(c) ((c) >= '0' && (c) <= '7')
|
||||
|
||||
/*
|
||||
* Look for 0[Xx], or leading + or - signs, guess at the base.
|
||||
@ -117,26 +115,26 @@ v_increment(SCR *sp, VICMD *vp)
|
||||
(p[beg + 1] == 'X' || p[beg + 1] == 'x')) {
|
||||
base = 16;
|
||||
end = beg + 2;
|
||||
if (!ishex(p[end]))
|
||||
if (!ISXDIGIT((UCHAR_T)p[end]))
|
||||
goto decimal;
|
||||
ntype = p[beg + 1] == 'X' ? fmt[HEXC] : fmt[HEXL];
|
||||
} else if (p[beg] == '0' && wlen > 1) {
|
||||
base = 8;
|
||||
end = beg + 1;
|
||||
if (!isoctal(p[end]))
|
||||
if (!isoctal((UCHAR_T)p[end]))
|
||||
goto decimal;
|
||||
ntype = fmt[OCTAL];
|
||||
} else if (wlen >= 1 && (p[beg] == '+' || p[beg] == '-')) {
|
||||
base = 10;
|
||||
end = beg + 1;
|
||||
ntype = fmt[SDEC];
|
||||
if (!isdigit(p[end]))
|
||||
if (!ISDIGIT((UCHAR_T)p[end]))
|
||||
goto nonum;
|
||||
} else {
|
||||
decimal: base = 10;
|
||||
end = beg;
|
||||
ntype = fmt[DEC];
|
||||
if (!isdigit(p[end])) {
|
||||
if (!ISDIGIT((UCHAR_T)p[end])) {
|
||||
nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
|
||||
return (1);
|
||||
}
|
||||
@ -146,7 +144,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
|
||||
while (++end < len) {
|
||||
switch (base) {
|
||||
case 8:
|
||||
if (isoctal(p[end]))
|
||||
if (isoctal((UCHAR_T)p[end]))
|
||||
continue;
|
||||
if (p[end] == '8' || p[end] == '9') {
|
||||
base = 10;
|
||||
@ -155,11 +153,11 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (isdigit(p[end]))
|
||||
if (ISDIGIT((UCHAR_T)p[end]))
|
||||
continue;
|
||||
break;
|
||||
case 16:
|
||||
if (ishex(p[end]))
|
||||
if (ISXDIGIT((UCHAR_T)p[end]))
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
|
4
dist/nvi/vi/v_match.c
vendored
4
dist/nvi/vi/v_match.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_match.c,v 1.4 2009/01/18 03:45:50 lukem Exp $ */
|
||||
/* $NetBSD: v_match.c,v 1.5 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -163,7 +163,7 @@ nomatch: msgq(sp, M_BERR, "184|No match character on this line");
|
||||
if (db_get(sp, mp->lno, DBG_FATAL, &p, &len))
|
||||
return (1);
|
||||
for (p += mp->cno + 1, len -= mp->cno; --len; ++p)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
return (0);
|
||||
F_SET(vp, VM_LMODE);
|
||||
return (0);
|
||||
|
4
dist/nvi/vi/v_replace.c
vendored
4
dist/nvi/vi/v_replace.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_replace.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: v_replace.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -174,7 +174,7 @@ next: if (v_event_get(sp, &ev, 0, 0))
|
||||
p += vp->m_start.cno + cnt;
|
||||
len -= vp->m_start.cno + cnt;
|
||||
if (len != 0 && O_ISSET(sp, O_AUTOINDENT))
|
||||
for (; len && isblank(*p); --len, ++p);
|
||||
for (; len && ISBLANK((UCHAR_T)*p); --len, ++p);
|
||||
|
||||
if ((tp = text_init(sp, p, len, len)) == NULL)
|
||||
goto err_ret;
|
||||
|
4
dist/nvi/vi/v_search.c
vendored
4
dist/nvi/vi/v_search.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_search.c,v 1.3 2010/10/28 18:12:47 christos Exp $ */
|
||||
/* $NetBSD: v_search.c,v 1.4 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -227,7 +227,7 @@ v_exaddr(SCR *sp, VICMD *vp, dir_t dir)
|
||||
|
||||
/* No blanks, just like the z command. */
|
||||
for (t = cmd + 1, tlen = len - 1; tlen > 0; ++t, --tlen)
|
||||
if (!isdigit(*t))
|
||||
if (!ISDIGIT((UCHAR_T)*t))
|
||||
break;
|
||||
if (tlen &&
|
||||
(*t == '-' || *t == '.' || *t == '+' || *t == '^')) {
|
||||
|
16
dist/nvi/vi/v_sentence.c
vendored
16
dist/nvi/vi/v_sentence.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_sentence.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: v_sentence.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -74,7 +74,7 @@ v_sentencef(SCR *sp, VICMD *vp)
|
||||
* This may not handle " . " correctly, but it's real unclear
|
||||
* what correctly means in that case.
|
||||
*/
|
||||
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) {
|
||||
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && ISBLANK2(cs.cs_ch))) {
|
||||
if (cs_fblank(sp, &cs))
|
||||
return (1);
|
||||
if (--cnt == 0) {
|
||||
@ -95,7 +95,7 @@ v_sentencef(SCR *sp, VICMD *vp)
|
||||
if (cs_next(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == 0 &&
|
||||
isblank(cs.cs_ch) && cs_fblank(sp, &cs))
|
||||
ISBLANK2(cs.cs_ch) && cs_fblank(sp, &cs))
|
||||
return (1);
|
||||
goto okret;
|
||||
}
|
||||
@ -235,11 +235,11 @@ v_sentenceb(SCR *sp, VICMD *vp)
|
||||
if (cs.cs_flags != CS_EOL)
|
||||
break;
|
||||
}
|
||||
} else if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
|
||||
} else if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch))
|
||||
for (;;) {
|
||||
if (cs_prev(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ ret: slno = cs.cs_lno;
|
||||
} while (!cs.cs_flags &&
|
||||
(cs.cs_ch == ')' || cs.cs_ch == ']' ||
|
||||
cs.cs_ch == '"' || cs.cs_ch == '\''));
|
||||
if ((cs.cs_flags || isblank(cs.cs_ch)) &&
|
||||
if ((cs.cs_flags || ISBLANK2(cs.cs_ch)) &&
|
||||
cs_fblank(sp, &cs))
|
||||
return (1);
|
||||
|
||||
@ -305,7 +305,7 @@ ret: slno = cs.cs_lno;
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOL)
|
||||
continue;
|
||||
if (cs.cs_flags == 0 && isblank(cs.cs_ch))
|
||||
if (cs.cs_flags == 0 && ISBLANK2(cs.cs_ch))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
@ -323,7 +323,7 @@ ret: slno = cs.cs_lno;
|
||||
break;
|
||||
default:
|
||||
last =
|
||||
cs.cs_flags == CS_EOL || isblank(cs.cs_ch) ||
|
||||
cs.cs_flags == CS_EOL || ISBLANK2(cs.cs_ch) ||
|
||||
cs.cs_ch == ')' || cs.cs_ch == ']' ||
|
||||
cs.cs_ch == '"' || cs.cs_ch == '\'' ? 1 : 0;
|
||||
}
|
||||
|
50
dist/nvi/vi/v_txt.c
vendored
50
dist/nvi/vi/v_txt.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_txt.c,v 1.6 2009/08/07 16:19:54 lukem Exp $ */
|
||||
/* $NetBSD: v_txt.c,v 1.7 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
@ -653,7 +653,7 @@ replay: if (LF_ISSET(TXT_REPLAY)) {
|
||||
* this test delimits the value by any non-hex character. Offset by
|
||||
* one, we use 0 to mean that we've found <CH_HEX>.
|
||||
*/
|
||||
if (hexcnt > 1 && !isxdigit(evp->e_c)) {
|
||||
if (hexcnt > 1 && !ISXDIGIT(evp->e_c)) {
|
||||
hexcnt = 0;
|
||||
if (txt_hex(sp, tp))
|
||||
goto err;
|
||||
@ -752,16 +752,16 @@ k_cr: if (LF_ISSET(TXT_CR)) {
|
||||
owrite = tp->owrite;
|
||||
insert = tp->insert;
|
||||
if (LF_ISSET(TXT_REPLACE) && owrite != 0) {
|
||||
for (p = tp->lb + tp->cno; owrite > 0 && isblank(*p);
|
||||
for (p = tp->lb + tp->cno; owrite > 0 && ISBLANK((UCHAR_T)*p);
|
||||
++p, --owrite, ++tp->R_erase);
|
||||
if (owrite == 0)
|
||||
for (; insert > 0 && isblank(*p);
|
||||
for (; insert > 0 && ISBLANK((UCHAR_T)*p);
|
||||
++p, ++tp->R_erase, --insert);
|
||||
} else {
|
||||
p = tp->lb + tp->cno + owrite;
|
||||
if (O_ISSET(sp, O_AUTOINDENT))
|
||||
for (; insert > 0 &&
|
||||
isblank(*p); ++p, --insert);
|
||||
ISBLANK((UCHAR_T)*p); ++p, --insert);
|
||||
owrite = 0;
|
||||
}
|
||||
|
||||
@ -1080,7 +1080,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
|
||||
}
|
||||
|
||||
/* Skip over trailing space characters. */
|
||||
while (tp->cno > max && isblank(tp->lb[tp->cno - 1])) {
|
||||
while (tp->cno > max && ISBLANK((UCHAR_T)tp->lb[tp->cno - 1])) {
|
||||
--tp->cno;
|
||||
++tp->owrite;
|
||||
}
|
||||
@ -1113,7 +1113,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
|
||||
++tp->owrite;
|
||||
if (FL_ISSET(is_flags, IS_RUNNING))
|
||||
tp->lb[tp->cno] = ' ';
|
||||
if (isblank(tp->lb[tp->cno - 1]))
|
||||
if (ISBLANK((UCHAR_T)tp->lb[tp->cno - 1]))
|
||||
break;
|
||||
}
|
||||
else {
|
||||
@ -1122,18 +1122,18 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
|
||||
++tp->owrite;
|
||||
if (FL_ISSET(is_flags, IS_RUNNING))
|
||||
tp->lb[tp->cno] = ' ';
|
||||
if (isblank(tp->lb[tp->cno - 1]))
|
||||
if (ISBLANK((UCHAR_T)tp->lb[tp->cno - 1]))
|
||||
break;
|
||||
}
|
||||
if (tp->cno > max)
|
||||
tmp = inword(tp->lb[tp->cno - 1]);
|
||||
tmp = inword((UCHAR_T)tp->lb[tp->cno - 1]);
|
||||
while (tp->cno > max) {
|
||||
--tp->cno;
|
||||
++tp->owrite;
|
||||
if (FL_ISSET(is_flags, IS_RUNNING))
|
||||
tp->lb[tp->cno] = ' ';
|
||||
if (tmp != inword(tp->lb[tp->cno - 1])
|
||||
|| isblank(tp->lb[tp->cno - 1]))
|
||||
if (tmp != inword((UCHAR_T)tp->lb[tp->cno - 1])
|
||||
|| ISBLANK((UCHAR_T)tp->lb[tp->cno - 1]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1292,7 +1292,7 @@ insq_ch: /*
|
||||
goto resolve;
|
||||
}
|
||||
}
|
||||
if (isblank(evp->e_c) && UNMAP_TST)
|
||||
if (ISBLANK(evp->e_c) && UNMAP_TST)
|
||||
txt_unmap(sp, tp, &ec_flags);
|
||||
}
|
||||
if (abb != AB_NOTSET)
|
||||
@ -1342,7 +1342,7 @@ insl_ch: if (txt_insch(sp, tp, &evp->e_c, flags))
|
||||
if (txt_margin(sp, tp, &wmt, &tmp, flags))
|
||||
goto err;
|
||||
if (tmp) {
|
||||
if (isblank(evp->e_c))
|
||||
if (ISBLANK(evp->e_c))
|
||||
wm_skip = 1;
|
||||
wm_set = 1;
|
||||
goto k_cr;
|
||||
@ -1508,19 +1508,19 @@ txt_abbrev(SCR *sp, TEXT *tp, CHAR_T *pushcp, int isinfoline, int *didsubp, int
|
||||
off = tp->cno - 1; /* Previous character. */
|
||||
p = tp->lb + off;
|
||||
len = 1; /* One character test. */
|
||||
if (off == tp->offset || isblank(p[-1]))
|
||||
if (off == tp->offset || ISBLANK((UCHAR_T)p[-1]))
|
||||
goto search;
|
||||
if (inword(p[-1])) /* Move backward to change. */
|
||||
if (inword((UCHAR_T)p[-1])) /* Move backward to change. */
|
||||
for (;;) {
|
||||
--off; --p; ++len;
|
||||
if (off == tp->offset || !inword(p[-1]))
|
||||
if (off == tp->offset || !inword((UCHAR_T)p[-1]))
|
||||
break;
|
||||
}
|
||||
else
|
||||
for (;;) {
|
||||
--off; --p; ++len;
|
||||
if (off == tp->offset ||
|
||||
inword(p[-1]) || isblank(p[-1]))
|
||||
inword((UCHAR_T)p[-1]) || ISBLANK((UCHAR_T)p[-1]))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1645,7 +1645,7 @@ txt_unmap(SCR *sp, TEXT *tp, u_int32_t *ec_flagsp)
|
||||
|
||||
/* Find the beginning of this "word". */
|
||||
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) {
|
||||
if (isblank(*p)) {
|
||||
if (ISBLANK((UCHAR_T)*p)) {
|
||||
++p;
|
||||
break;
|
||||
}
|
||||
@ -1712,7 +1712,7 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *changedp)
|
||||
|
||||
/* Figure out the last <blank> screen column. */
|
||||
for (p = tp->lb, scno = 0, len = tp->len,
|
||||
spaces = tab_after_sp = 0; len-- && isblank(*p); ++p)
|
||||
spaces = tab_after_sp = 0; len-- && ISBLANK((UCHAR_T)*p); ++p)
|
||||
if (*p == '\t') {
|
||||
if (spaces)
|
||||
tab_after_sp = 1;
|
||||
@ -1793,7 +1793,7 @@ v_txt_auto(SCR *sp, db_recno_t lno, TEXT *aitp, size_t len, TEXT *tp)
|
||||
|
||||
/* Count whitespace characters. */
|
||||
for (p = t; len > 0; ++p, --len)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
|
||||
/* Set count, check for no indentation. */
|
||||
@ -2012,7 +2012,7 @@ txt_fc(SCR *sp, TEXT *tp, int *redrawp)
|
||||
} else
|
||||
retry: for (len = 0,
|
||||
off = tp->cno - 1, p = tp->lb + off;; --off, --p) {
|
||||
if (isblank(*p)) {
|
||||
if (ISBLANK((UCHAR_T)*p)) {
|
||||
++p;
|
||||
break;
|
||||
}
|
||||
@ -2349,7 +2349,7 @@ txt_hex(SCR *sp, TEXT *tp)
|
||||
{
|
||||
CHAR_T savec;
|
||||
size_t len, off;
|
||||
u_long value;
|
||||
long value;
|
||||
CHAR_T *p, *wp;
|
||||
|
||||
/*
|
||||
@ -2378,7 +2378,7 @@ txt_hex(SCR *sp, TEXT *tp)
|
||||
/* Get the value. */
|
||||
errno = 0;
|
||||
value = STRTOL(wp, NULL, 16);
|
||||
if (errno || value > MAX_CHAR_T) {
|
||||
if (errno || value < 0 || value > 0xff) {
|
||||
nothex: tp->lb[tp->cno] = savec;
|
||||
return (0);
|
||||
}
|
||||
@ -2788,7 +2788,7 @@ txt_margin(SCR *sp, TEXT *tp, TEXT *wmtp, int *didbreak, u_int32_t flags)
|
||||
|
||||
/* Find the nearest previous blank. */
|
||||
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) {
|
||||
if (isblank(*p)) {
|
||||
if (ISBLANK((UCHAR_T)*p)) {
|
||||
wp = p + 1;
|
||||
break;
|
||||
}
|
||||
@ -2840,7 +2840,7 @@ txt_margin(SCR *sp, TEXT *tp, TEXT *wmtp, int *didbreak, u_int32_t flags)
|
||||
* Delete any trailing whitespace from the current line.
|
||||
*/
|
||||
for (;; --p, --off) {
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
break;
|
||||
--tp->cno;
|
||||
--tp->len;
|
||||
|
8
dist/nvi/vi/v_ulcase.c
vendored
8
dist/nvi/vi/v_ulcase.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_ulcase.c,v 1.2 2009/12/23 12:44:22 mlelstv Exp $ */
|
||||
/* $NetBSD: v_ulcase.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -147,15 +147,15 @@ ulcase(SCR *sp, db_recno_t lno, CHAR_T *lp, size_t len, size_t scno, size_t ecno
|
||||
{
|
||||
size_t blen;
|
||||
int change, rval;
|
||||
CHAR_T ch, *p, *t;
|
||||
CHAR_T *bp;
|
||||
ARG_CHAR_T ch;
|
||||
CHAR_T *p, *t, *bp;
|
||||
|
||||
GET_SPACE_RETW(sp, bp, blen, len);
|
||||
MEMMOVEW(bp, lp, len);
|
||||
|
||||
change = rval = 0;
|
||||
for (p = bp + scno, t = bp + ecno + 1; p < t; ++p) {
|
||||
ch = *p;
|
||||
ch = (UCHAR_T)*p;
|
||||
if (ISLOWER(ch)) {
|
||||
*p = TOUPPER(ch);
|
||||
change = 1;
|
||||
|
4
dist/nvi/vi/v_util.c
vendored
4
dist/nvi/vi/v_util.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_util.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: v_util.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -125,7 +125,7 @@ int
|
||||
v_isempty(CHAR_T *p, size_t len)
|
||||
{
|
||||
for (; len--; ++p)
|
||||
if (!isblank(*p))
|
||||
if (!ISBLANK((UCHAR_T)*p))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
30
dist/nvi/vi/v_word.c
vendored
30
dist/nvi/vi/v_word.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: v_word.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: v_word.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -120,7 +120,7 @@ fword(SCR *sp, VICMD *vp, enum which type)
|
||||
* counts as a single word move. If it's a motion command,
|
||||
* don't move off the end of the line.
|
||||
*/
|
||||
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) {
|
||||
if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && ISBLANK2(cs.cs_ch))) {
|
||||
if (ISMOTION(vp) && cs.cs_flags != CS_EMP && cnt == 1) {
|
||||
if (ISCMD(vp->rkp, 'c'))
|
||||
return (0);
|
||||
@ -148,7 +148,7 @@ fword(SCR *sp, VICMD *vp, enum which type)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -180,7 +180,7 @@ fword(SCR *sp, VICMD *vp, enum which type)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
if (state == INWORD) {
|
||||
if (!inword(cs.cs_ch))
|
||||
@ -199,7 +199,7 @@ fword(SCR *sp, VICMD *vp, enum which type)
|
||||
}
|
||||
|
||||
/* Eat whitespace characters. */
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
if (cs_fblank(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
@ -279,10 +279,10 @@ eword(SCR *sp, VICMD *vp, enum which type)
|
||||
* it. (This doesn't count as a word move.) Stay at the character
|
||||
* past the current one, it sets word "state" for the 'e' command.
|
||||
*/
|
||||
if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
|
||||
if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch)) {
|
||||
if (cs_next(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
|
||||
if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch))
|
||||
goto start;
|
||||
}
|
||||
if (cs_fblank(sp, &cs))
|
||||
@ -301,7 +301,7 @@ start: if (type == BIGWORD)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -330,7 +330,7 @@ start: if (type == BIGWORD)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
if (state == INWORD) {
|
||||
if (!inword(cs.cs_ch))
|
||||
@ -347,7 +347,7 @@ start: if (type == BIGWORD)
|
||||
}
|
||||
|
||||
/* Eat whitespace characters. */
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
if (cs_fblank(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_EOF)
|
||||
@ -426,10 +426,10 @@ bword(SCR *sp, VICMD *vp, enum which type)
|
||||
* character before the current one, it sets word "state" for the
|
||||
* 'b' command.
|
||||
*/
|
||||
if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
|
||||
if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch)) {
|
||||
if (cs_prev(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
|
||||
if (cs.cs_flags == 0 && !ISBLANK2(cs.cs_ch))
|
||||
goto start;
|
||||
}
|
||||
if (cs_bblank(sp, &cs))
|
||||
@ -448,7 +448,7 @@ start: if (type == BIGWORD)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_SOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -477,7 +477,7 @@ start: if (type == BIGWORD)
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_SOF)
|
||||
goto ret;
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
break;
|
||||
if (state == INWORD) {
|
||||
if (!inword(cs.cs_ch))
|
||||
@ -494,7 +494,7 @@ start: if (type == BIGWORD)
|
||||
}
|
||||
|
||||
/* Eat whitespace characters. */
|
||||
if (cs.cs_flags != 0 || isblank(cs.cs_ch))
|
||||
if (cs.cs_flags != 0 || ISBLANK2(cs.cs_ch))
|
||||
if (cs_bblank(sp, &cs))
|
||||
return (1);
|
||||
if (cs.cs_flags == CS_SOF)
|
||||
|
10
dist/nvi/vi/vi.c
vendored
10
dist/nvi/vi/vi.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vi.c,v 1.3 2009/11/15 18:43:28 dsl Exp $ */
|
||||
/* $NetBSD: vi.c,v 1.4 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -450,7 +450,7 @@ v_cmd(SCR *sp, VICMD *dp, VICMD *vp, VICMD *ismotion, int *comcountp, int *mappe
|
||||
|
||||
{
|
||||
enum { COMMANDMODE, ISPARTIAL, NOTPARTIAL } cpart;
|
||||
CHAR_T key;
|
||||
ARG_CHAR_T key;
|
||||
VIKEYS const *kp;
|
||||
gcret_t gcret;
|
||||
u_int flags;
|
||||
@ -1084,7 +1084,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((UCHAR_T)p[beg]); moved = 1, ++beg);
|
||||
if (beg >= len) {
|
||||
msgq(sp, M_BERR, "212|Cursor not in a word");
|
||||
return (1);
|
||||
@ -1254,9 +1254,9 @@ v_comlog(sp, vp)
|
||||
SCR *sp;
|
||||
VICMD *vp;
|
||||
{
|
||||
vtrace(sp, "vcmd: %c", vp->key);
|
||||
vtrace(sp, "vcmd: "WC, vp->key);
|
||||
if (F_ISSET(vp, VC_BUFFER))
|
||||
vtrace(sp, " buffer: %c", vp->buffer);
|
||||
vtrace(sp, " buffer: "WC, vp->buffer);
|
||||
if (F_ISSET(vp, VC_C1SET))
|
||||
vtrace(sp, " c1: %lu", vp->count);
|
||||
if (F_ISSET(vp, VC_C2SET))
|
||||
|
17
dist/nvi/vi/vi.h
vendored
17
dist/nvi/vi/vi.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vi.h,v 1.3 2008/12/05 22:51:43 christos Exp $ */
|
||||
/* $NetBSD: vi.h,v 1.4 2011/03/21 14:53:04 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
@ -12,20 +12,15 @@
|
||||
*/
|
||||
|
||||
/* Definition of a vi "word". */
|
||||
#ifdef USE_WIDECHAR
|
||||
#define inword(ch) ((UCHAR_T)ch <= 255 && \
|
||||
(isalnum((unsigned char)ch) || (ch) == '_'))
|
||||
#else
|
||||
#define inword(ch) (isalnum((UCHAR_T)ch) || (ch) == '_')
|
||||
#endif
|
||||
#define inword(ch) ((ch) == '_' || (ISGRAPH((UCHAR_T)ch) && !ISPUNCT((UCHAR_T)ch)))
|
||||
|
||||
typedef struct _vikeys VIKEYS;
|
||||
|
||||
/* Structure passed around to functions implementing vi commands. */
|
||||
typedef struct _vicmd {
|
||||
CHAR_T key; /* Command key. */
|
||||
CHAR_T buffer; /* Buffer. */
|
||||
CHAR_T character; /* Character. */
|
||||
ARG_CHAR_T key; /* Command key. */
|
||||
ARG_CHAR_T buffer; /* Buffer. */
|
||||
ARG_CHAR_T character; /* Character. */
|
||||
u_long count; /* Count. */
|
||||
u_long count2; /* Second count (only used by z). */
|
||||
EVENT ev; /* Associated event. */
|
||||
@ -160,7 +155,7 @@ typedef struct _vcs {
|
||||
size_t cs_cno; /* Column. */
|
||||
CHAR_T *cs_bp; /* Buffer. */
|
||||
size_t cs_len; /* Length. */
|
||||
CHAR_T cs_ch; /* Character. */
|
||||
ARG_CHAR_T cs_ch; /* Character. */
|
||||
#define CS_EMP 1 /* Empty line. */
|
||||
#define CS_EOF 2 /* End-of-file. */
|
||||
#define CS_EOL 3 /* End-of-line. */
|
||||
|
Loading…
Reference in New Issue
Block a user