(SVIS): add some (unsigned char) before calling isfoo*

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10277 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2001-07-03 19:22:01 +00:00
parent d97fdd9971
commit de95583293

View File

@@ -107,71 +107,73 @@ do { \
* extra: Pointer to the list of extra characters to be * extra: Pointer to the list of extra characters to be
* backslash-protected. * backslash-protected.
*/ */
#define SVIS(dst, c, flag, nextc, extra) \ #define SVIS(dst, c, flag, nextc, extra) \
do { \ do { \
int isextra, isc; \ int isextra, isc; \
isextra = strchr(extra, c) != NULL; \ isextra = strchr(extra, c) != NULL; \
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \ if (!isextra && \
((flag & VIS_SAFE) && issafe(c)))) { \ isascii((unsigned char)c) && \
*dst++ = c; \ (isgraph((unsigned char)c) || iswhite(c) || \
break; \ ((flag & VIS_SAFE) && issafe(c)))) { \
} \ *dst++ = c; \
isc = 0; \ break; \
if (flag & VIS_CSTYLE) { \ } \
switch (c) { \ isc = 0; \
case '\n': \ if (flag & VIS_CSTYLE) { \
isc = 1; *dst++ = '\\'; *dst++ = 'n'; \ switch (c) { \
break; \ case '\n': \
case '\r': \ isc = 1; *dst++ = '\\'; *dst++ = 'n'; \
isc = 1; *dst++ = '\\'; *dst++ = 'r'; \ break; \
break; \ case '\r': \
case '\b': \ isc = 1; *dst++ = '\\'; *dst++ = 'r'; \
isc = 1; *dst++ = '\\'; *dst++ = 'b'; \ break; \
break; \ case '\b': \
case BELL: \ isc = 1; *dst++ = '\\'; *dst++ = 'b'; \
isc = 1; *dst++ = '\\'; *dst++ = 'a'; \ break; \
break; \ case BELL: \
case '\v': \ isc = 1; *dst++ = '\\'; *dst++ = 'a'; \
isc = 1; *dst++ = '\\'; *dst++ = 'v'; \ break; \
break; \ case '\v': \
case '\t': \ isc = 1; *dst++ = '\\'; *dst++ = 'v'; \
isc = 1; *dst++ = '\\'; *dst++ = 't'; \ break; \
break; \ case '\t': \
case '\f': \ isc = 1; *dst++ = '\\'; *dst++ = 't'; \
isc = 1; *dst++ = '\\'; *dst++ = 'f'; \ break; \
break; \ case '\f': \
case ' ': \ isc = 1; *dst++ = '\\'; *dst++ = 'f'; \
isc = 1; *dst++ = '\\'; *dst++ = 's'; \ break; \
break; \ case ' ': \
case '\0': \ isc = 1; *dst++ = '\\'; *dst++ = 's'; \
isc = 1; *dst++ = '\\'; *dst++ = '0'; \ break; \
if (isoctal(nextc)) { \ case '\0': \
*dst++ = '0'; \ isc = 1; *dst++ = '\\'; *dst++ = '0'; \
*dst++ = '0'; \ if (isoctal(nextc)) { \
} \ *dst++ = '0'; \
} \ *dst++ = '0'; \
} \ } \
if (isc) break; \ } \
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \ } \
*dst++ = '\\'; \ if (isc) break; \
*dst++ = (u_char)(((unsigned)(u_char)c >> 6) & 03) + '0'; \ if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
*dst++ = (u_char)(((unsigned)(u_char)c >> 3) & 07) + '0'; \ *dst++ = '\\'; \
*dst++ = (c & 07) + '0'; \ *dst++ = (u_char)(((unsigned)(u_char)c >> 6) & 03) + '0'; \
} else { \ *dst++ = (u_char)(((unsigned)(u_char)c >> 3) & 07) + '0'; \
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \ *dst++ = (c & 07) + '0'; \
if (c & 0200) { \ } else { \
c &= 0177; *dst++ = 'M'; \ if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
} \ if (c & 0200) { \
if (iscntrl(c)) { \ c &= 0177; *dst++ = 'M'; \
*dst++ = '^'; \ } \
if (c == 0177) \ if (iscntrl(c)) { \
*dst++ = '?'; \ *dst++ = '^'; \
else \ if (c == 0177) \
*dst++ = c + '@'; \ *dst++ = '?'; \
} else { \ else \
*dst++ = '-'; *dst++ = c; \ *dst++ = c + '@'; \
} \ } else { \
} \ *dst++ = '-'; *dst++ = c; \
} \
} \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)