tweaks: rename four more functions, to get rid of an abbreviation

Also, improve their comments.
This commit is contained in:
Benno Schulenberg 2020-03-12 15:35:02 +01:00
parent f6dedf3598
commit ae139021eb
4 changed files with 17 additions and 19 deletions

View File

@ -44,8 +44,8 @@ bool using_utf8(void)
}
#endif /* ENABLE_UTF8 */
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
/* Return TRUE when the given character is some kind of letter. */
bool is_alpha_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
@ -60,8 +60,8 @@ bool is_alpha_mbchar(const char *c)
return isalpha((unsigned char)*c);
}
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
/* Return TRUE when the given character is some kind of letter or a digit. */
bool is_alnum_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
@ -92,10 +92,8 @@ bool is_blank_char(const char *c)
return isblank((unsigned char)*c);
}
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
bool is_cntrl_mbchar(const char *c)
/* Return TRUE when the given character is a control character. */
bool is_cntrl_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
@ -106,8 +104,8 @@ bool is_cntrl_mbchar(const char *c)
return (((unsigned char)*c & 0x60) == 0 || (unsigned char)*c == 127);
}
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
/* Return TRUE when the given character is a punctuation character. */
bool is_punct_char(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
@ -129,7 +127,7 @@ bool is_word_char(const char *c, bool allow_punct)
if (*c == '\0')
return FALSE;
if (is_alnum_mbchar(c))
if (is_alnum_char(c))
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
@ -140,7 +138,7 @@ bool is_word_char(const char *c, bool allow_punct)
return (strstr(word_chars, symbol) != NULL);
}
return (allow_punct && is_punct_mbchar(c));
return (allow_punct && is_punct_char(c));
}
/* Return the visible representation of control character c. */
@ -292,7 +290,7 @@ int advance_over(const char *string, size_t *column)
int charlen = mblen(string, MAXCHARLEN);
if (charlen > 0) {
if (is_cntrl_mbchar(string))
if (is_cntrl_char(string))
*column += 2;
else
*column += mbwidth(string);

View File

@ -203,9 +203,9 @@ char *strip_last_component(const char *path);
void utf8_init(void);
bool using_utf8(void);
#endif
bool is_alpha_mbchar(const char *c);
bool is_alpha_char(const char *c);
bool is_blank_char(const char *c);
bool is_cntrl_mbchar(const char *c);
bool is_cntrl_char(const char *c);
bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8

View File

@ -209,8 +209,8 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_mbchar(before)) &&
(buf[word_end] == '\0' || !is_alpha_mbchar(after)));
return ((position == 0 || !is_alpha_char(before)) &&
(buf[word_end] == '\0' || !is_alpha_char(after)));
}
#endif /* ENABLE_SPELLER */

View File

@ -1857,7 +1857,7 @@ char *display_string(const char *buf, size_t column, size_t span,
* overwritten by a "<" token, then show placeholders instead. */
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
if (is_cntrl_mbchar(buf)) {
if (is_cntrl_char(buf)) {
if (start_col < column) {
converted[index++] = control_mbrep(buf, isdata);
column++;
@ -1931,7 +1931,7 @@ char *display_string(const char *buf, size_t column, size_t span,
}
/* Represent a control character with a leading caret. */
if (is_cntrl_mbchar(buf)) {
if (is_cntrl_char(buf)) {
converted[index++] = '^';
converted[index++] = control_mbrep(buf, isdata);
buf += char_length(buf);