X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmbswidth.c;h=072695172b5f33376f7cc42ca804a5cc1d286483;hb=f0e088d682de0015abdfacae91576ef7836fd2d8;hp=ef8398a78674063d5c8b992c26287e07ca36e9b8;hpb=d0bcee4e6a778c34a4d3e4c922789219c16bfe4b;p=gnulib.git diff --git a/lib/mbswidth.c b/lib/mbswidth.c index ef8398a78..072695172 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -51,7 +51,7 @@ # include #endif #if !defined iswcntrl && !HAVE_ISWCNTRL -# define iswcntrl(wc) 0 +# define iswcntrl(wc) (((wc) & ~0x1f) == 0 || (wc) == 0x7f) #endif #ifndef mbsinit @@ -60,18 +60,6 @@ # endif #endif -/* Get ISPRINT. */ -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -# define IN_CTYPE_DOMAIN(c) 1 -#else -# define IN_CTYPE_DOMAIN(c) isascii(c) -#endif -/* Undefine to protect against the definition in wctype.h of Solaris 2.6. */ -#undef ISPRINT -#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) -#undef ISCNTRL -#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c)) - /* Returns the number of columns needed to represent the multibyte character string pointed to by STRING. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. @@ -195,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags) { unsigned char c = (unsigned char) *p++; - if (ISPRINT (c)) + if (isprint (c)) width++; else if (!(flags & MBSW_REJECT_UNPRINTABLE)) - width += (ISCNTRL (c) ? 0 : 1); + width += (iscntrl (c) ? 0 : 1); else return -1; }