summaryrefslogtreecommitdiff
blob: ebf3305fcbcac118193c061a470f89fbc1292987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Make sure nvi handles multibyte characters properly in more cases than
before. Submitted by Karl Hakimian, http://bugs.gentoo.org/150169

--- nvi-1.81.5/common/multibyte.h
+++ nvi-1.81.5/common/multibyte.h
@@ -19,7 +19,12 @@
 #define STRCMP		wcscmp
 #define STRPBRK		wcspbrk
 #define TOUPPER		towupper
+#define TOLOWER		towlower
+#define ISUPPER		iswupper
+#define ISLOWER		iswlower
 #define STRSET		wmemset
+#define GETC		getwc
+#define VI_EOF		WEOF
 
 #define L(ch)		L ## ch
 
@@ -38,7 +43,12 @@
 #define STRCMP		strcmp
 #define STRPBRK		strpbrk
 #define TOUPPER		toupper
+#define TOLOWER		tolower
+#define ISUPPER		isupper
+#define ISLOWER		islower
 #define STRSET		memset
+#define GETC		getc
+#define VI_EOF		EOF
 
 #define L(ch)		ch
 
--- nvi-1.81.5/ex/ex_subst.c
+++ nvi-1.81.5/ex/ex_subst.c
@@ -909,7 +909,7 @@
 	}
 	if (LF_ISSET(SEARCH_ICL)) {
 iclower:	for (p = ptrn, len = plen; len > 0; ++p, --len)
-			if (isupper(*p))
+			if (ISUPPER(*p))
 				break;
 		if (len == 0)
 			reflags |= REG_ICASE;
@@ -1363,15 +1363,15 @@
 			conv = C_NOTSET;				\
 			/* FALLTHROUGH */				\
 		case C_LOWER:						\
-			if (isupper(__ch))				\
+			if (ISUPPER(__ch))				\
-				__ch = tolower(__ch);			\
+				__ch = TOLOWER(__ch);			\
 			break;						\
 		case C_ONEUPPER:					\
 			conv = C_NOTSET;				\
 			/* FALLTHROUGH */				\
 		case C_UPPER:						\
-			if (islower(__ch))				\
+			if (ISLOWER(__ch))				\
-				__ch = toupper(__ch);			\
+				__ch = TOUPPER(__ch);			\
 			break;						\
 		default:						\
 			abort();					\
--- nvi-1.81.5/ex/ex_util.c
+++ nvi-1.81.5/ex/ex_util.c
@@ -67,7 +67,7 @@
 			BINC_RETW(sp, exp->ibp, exp->ibp_len, off + 1);
 			p = exp->ibp + off;
 		}
-		if ((ch = getc(fp)) == EOF && !feof(fp)) {
+		if ((ch = GETC(fp)) == VI_EOF && !feof(fp)) {
 			if (errno == EINTR) {
 				errno = 0;
 				clearerr(fp);
@@ -75,8 +75,8 @@
 			}
 			return (1);
 		}
-		if (ch == EOF || ch == '\n') {
+		if (ch == VI_EOF || ch == '\n') {
-			if (ch == EOF && !off)
+			if (ch == VI_EOF && !off)
 				return (1);
 			*lenp = off;
 			return (0);
--- nvi-1.81.5/vi/v_ulcase.c
+++ nvi-1.81.5/vi/v_ulcase.c
@@ -154,11 +154,11 @@
 	change = rval = 0;
 	for (p = bp + scno, t = bp + ecno + 1; p < t; ++p) {
 		ch = *(u_char *)p;
-		if (islower(ch)) {
+		if (ISLOWER(*p)) {
-			*p = toupper(ch);
+			*p = TOUPPER(*p);
 			change = 1;
-		} else if (isupper(ch)) {
+		} else if (ISUPPER(*p)) {
-			*p = tolower(ch);
+			*p = TOLOWER(*p);
 			change = 1;
 		}
 	}