commit 547de4a7bbb755e532c295bf03fb1d08d0fcf4b7
parent 845a5973c946d44dc963368e1e2913f391e41966
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 6 Apr 2020 11:04:21 +0200
counting: count words correctly also when --wordchars is used
It should give the same result as 'wc -w' as long as the content
of 'wordchars' does not affect the counting.
This fixes https://savannah.gnu.org/bugs/?58123.
Bug existed since version 2.6.2, since the --wordchars option was
introduced in commit 6f12992c.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -131,15 +131,17 @@ bool is_word_char(const char *c, bool allow_punct)
if (is_alnum_char(c))
return TRUE;
+ if (allow_punct && is_punct_char(c))
+ return TRUE;
+
if (word_chars != NULL && *word_chars != '\0') {
char symbol[MAXCHARLEN + 1];
int symlen = collect_char(c, symbol);
symbol[symlen] = '\0';
return (strstr(word_chars, symbol) != NULL);
- }
-
- return (allow_punct && is_punct_char(c));
+ } else
+ return FALSE;
}
/* Return the visible representation of control character c. */