Commit 81c3c3e4054f88049c4401b1d472188c75bdd5e4

Aaron Dierking 2018-06-14T11:38:31

Replace reintroduced legacy u_* type usage in strnvis() and strnunvis() This fixes a regression caused by 2d7de18. These types are not available on all systems. Fixes: commit 2d7de186e9cb19a756c0630ee85cb3f2d29b3484 Signed-off-by: Guillem Jover <guillem@hadrons.org>

diff --git a/src/unvis.c b/src/unvis.c
index 94e3e7a..ae963aa 100644
--- a/src/unvis.c
+++ b/src/unvis.c
@@ -68,7 +68,8 @@ __weak_alias(strnunvisx,_strnunvisx)
 #define	S_NUMBER	14	/* collecting number */
 #define	S_STRING	15	/* collecting string */
 
-#define	isoctal(c)	(((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+#define	isoctal(c) \
+	(((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
 #define	xtod(c)		(isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
 #define	XTOD(c)		(isdigit(c) ? (c - '0') : ((c - 'A') + 10))
 
diff --git a/src/vis.c b/src/vis.c
index 674d971..3e6ade8 100644
--- a/src/vis.c
+++ b/src/vis.c
@@ -117,7 +117,8 @@ iscgraph(int c) {
 #define ISGRAPH(flags, c) \
     (((flags) & VIS_NOLOCALE) ? iscgraph(c) : iswgraph(c))
 
-#define iswoctal(c)	(((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
+#define iswoctal(c)	\
+	(((unsigned char)(c)) >= L'0' && ((unsigned char)(c)) <= L'7')
 #define iswwhite(c)	(c == L' ' || c == L'\t' || c == L'\n')
 #define iswsafe(c)	(c == L'\b' || c == BELL || c == L'\r')
 #define xtoa(c)		L"0123456789abcdef"[c]
@@ -253,9 +254,11 @@ do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
 	}
 	if (iswextra || ((c & 0177) == L' ') || (flags & VIS_OCTAL)) {
 		*dst++ = L'\\';
-		*dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + L'0';
-		*dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + L'0';
-		*dst++ =			     (c	      & 07) + L'0';
+		*dst++ =
+			(unsigned char)(((uint32_t)(unsigned char)c >> 6) & 03) + L'0';
+		*dst++ =
+			(unsigned char)(((uint32_t)(unsigned char)c >> 3) & 07) + L'0';
+		*dst++ = (c & 07) + L'0';
 	} else {
 		if ((flags & VIS_NOSLASH) == 0)
 			*dst++ = L'\\';
@@ -349,7 +352,7 @@ makeextralist(int flags, const char *src)
 	if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) {
 		size_t i;
 		for (i = 0; i < len; i++)
-			dst[i] = (wchar_t)(u_char)src[i];
+			dst[i] = (wchar_t)(unsigned char)src[i];
 		d = dst + len;
 	} else
 		d = dst + wcslen(dst);
@@ -452,7 +455,7 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
 			clen = mbtowc(src, mbsrc, MB_LEN_MAX);
 		if (cerr || clen < 0) {
 			/* Conversion error, process as a byte instead. */
-			*src = (wint_t)(u_char)*mbsrc;
+			*src = (wint_t)(unsigned char)*mbsrc;
 			clen = 1;
 			cerr = 1;
 		}