From: Jim Meyering Date: Thu, 13 Dec 2001 11:12:18 +0000 (+0000) Subject: (wc): Use ISSPACE and iswspace in addition to hard-coding X-Git-Tag: FILEUTILS-4_1_4~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8471372f24b80813e8b419afe41222ab1bfed7b1;p=thirdparty%2Fcoreutils.git (wc): Use ISSPACE and iswspace in addition to hard-coding the ASCII space character. --- diff --git a/src/wc.c b/src/wc.c index 7996f77571..1d638b8c20 100644 --- a/src/wc.c +++ b/src/wc.c @@ -32,13 +32,17 @@ # include #endif -/* Get iswprint(). */ +/* Get iswprint(), iswspace(). */ #if HAVE_WCTYPE_H # include #endif #if !defined iswprint && !HAVE_ISWPRINT # define iswprint(wc) 1 #endif +#if !defined iswspace && !HAVE_ISWSPACE +# define iswspace(wc) \ + ((wc) == (unsigned char) (wc) && ISSPACE ((unsigned char) (wc))) +#endif /* Include this after wctype.h so that we `#undef' ISPRINT (from Solaris's euc.h, from widec.h, from wctype.h) before @@ -378,6 +382,8 @@ wc (int fd, const char *file) int width = wcwidth (wide_char); if (width > 0) linepos += width; + if (iswspace (wide_char)) + goto mb_word_separator; in_word = 1; } break; @@ -452,6 +458,8 @@ wc (int fd, const char *file) if (ISPRINT ((unsigned char) p[-1])) { linepos++; + if (ISSPACE ((unsigned char) p[-1])) + goto word_separator; in_word = 1; } break;