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
.
master
parent
845a5973c9
commit
547de4a7bb
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue