tweaks: remove non-UTF-8 code from three more functions
parent
b2c63c3d3c
commit
004af03ea5
15
src/chars.c
15
src/chars.c
|
@ -47,33 +47,23 @@ bool using_utf8(void)
|
||||||
/* Return TRUE when the given character is some kind of letter. */
|
/* Return TRUE when the given character is some kind of letter. */
|
||||||
bool is_alpha_char(const char *c)
|
bool is_alpha_char(const char *c)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
if (use_utf8) {
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
|
|
||||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return iswalpha(wc);
|
return iswalpha(wc);
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
return isalpha((unsigned char)*c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE when the given character is some kind of letter or a digit. */
|
/* Return TRUE when the given character is some kind of letter or a digit. */
|
||||||
bool is_alnum_char(const char *c)
|
bool is_alnum_char(const char *c)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
if (use_utf8) {
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
|
|
||||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return iswalnum(wc);
|
return iswalnum(wc);
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
return isalnum((unsigned char)*c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE when the given character is space or tab or other whitespace. */
|
/* Return TRUE when the given character is space or tab or other whitespace. */
|
||||||
|
@ -105,17 +95,12 @@ bool is_cntrl_char(const char *c)
|
||||||
/* Return TRUE when the given character is a punctuation character. */
|
/* Return TRUE when the given character is a punctuation character. */
|
||||||
bool is_punct_char(const char *c)
|
bool is_punct_char(const char *c)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
if (use_utf8) {
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
|
|
||||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return iswpunct(wc);
|
return iswpunct(wc);
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
return ispunct((unsigned char)*c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE when the given character is word-forming (it is alphanumeric or
|
/* Return TRUE when the given character is word-forming (it is alphanumeric or
|
||||||
|
|
Loading…
Reference in New Issue