]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(wc): Use ISSPACE and iswspace in addition to hard-coding
authorJim Meyering <jim@meyering.net>
Thu, 13 Dec 2001 11:12:18 +0000 (11:12 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 13 Dec 2001 11:12:18 +0000 (11:12 +0000)
the ASCII space character.

src/wc.c

index 7996f7757165ccd48d81e21cf89571c3d554568d..1d638b8c20d1c931acceb388b690a51c30b31b1c 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
 # 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;