From 8471372f24b80813e8b419afe41222ab1bfed7b1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 13 Dec 2001 11:12:18 +0000 Subject: (wc): Use ISSPACE and iswspace in addition to hard-coding the ASCII space character. --- src/wc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/wc.c') diff --git a/src/wc.c b/src/wc.c index 7996f7757..1d638b8c2 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; -- cgit v1.2.3-54-g00ecf