spelling: don't consider digits as word parts, because GNU spell doesn't

This fixes https://savannah.gnu.org/bugs/?48660.
master
Benno Schulenberg 2016-08-02 22:09:22 +02:00
parent f6dd0ad18a
commit 20058a1b63
3 changed files with 26 additions and 6 deletions

View File

@ -93,6 +93,26 @@ void wctomb_reset(void)
IGNORE_CALL_RESULT(wctomb(NULL, 0)); IGNORE_CALL_RESULT(wctomb(NULL, 0));
} }
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc_reset();
return 0;
}
return iswalpha(wc);
} else
#endif
return isalpha((unsigned char)*c);
}
/* This function is equivalent to isalnum() for multibyte characters. */ /* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c) bool is_alnum_mbchar(const char *c)
{ {

View File

@ -183,6 +183,7 @@ bool nisblank(int c);
bool niswblank(wchar_t wc); bool niswblank(wchar_t wc);
#endif #endif
bool is_byte(int c); bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_alnum_mbchar(const char *c); bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c); bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c); bool is_ascii_cntrl_char(int c);

View File

@ -290,12 +290,11 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
parse_mbchar(buf + move_mbleft(buf, position), before, NULL); parse_mbchar(buf + move_mbleft(buf, position), before, NULL);
parse_mbchar(buf + word_end, after, NULL); parse_mbchar(buf + word_end, after, NULL);
/* If we're at the beginning of the line or the character before the /* If the word starts at the beginning of the line OR the character before
* word isn't a non-punctuation "word" character, and if we're at * the word isn't a letter, and if the word ends at the end of the line OR
* the end of the line or the character after the word isn't a * the character after the word isn't a letter, we have a whole word. */
* non-punctuation "word" character, we have a whole word. */ retval = (position == 0 || !is_alpha_mbchar(before)) &&
retval = (position == 0 || !is_alnum_mbchar(before)) && (word_end == strlen(buf) || !is_alpha_mbchar(after));
(word_end == strlen(buf) || !is_alnum_mbchar(after));
free(before); free(before);
free(after); free(after);