summaryrefslogtreecommitdiff
path: root/src/wc.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-12-13 11:12:18 +0000
committerJim Meyering <jim@meyering.net>2001-12-13 11:12:18 +0000
commit8471372f24b80813e8b419afe41222ab1bfed7b1 (patch)
tree80d7fb9c1e4765234dbbaf46180e4f0b347e2c68 /src/wc.c
parent80f17f22f26b2df8c985e744742c47136ce6d530 (diff)
downloadcoreutils-8471372f24b80813e8b419afe41222ab1bfed7b1.tar.xz
(wc): Use ISSPACE and iswspace in addition to hard-coding
the ASCII space character.
Diffstat (limited to 'src/wc.c')
-rw-r--r--src/wc.c10
1 files changed, 9 insertions, 1 deletions
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 <wchar.h>
#endif
-/* Get iswprint(). */
+/* Get iswprint(), iswspace(). */
#if HAVE_WCTYPE_H
# include <wctype.h>
#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;