1
1

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

Also, improve their comments.
Этот коммит содержится в:
Benno Schulenberg 2020-03-12 15:35:02 +01:00
родитель f6dedf3598
Коммит ae139021eb
4 изменённых файлов: 17 добавлений и 19 удалений

Просмотреть файл

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

Просмотреть файл

@ -203,9 +203,9 @@ char *strip_last_component(const char *path);
void utf8_init(void); void utf8_init(void);
bool using_utf8(void); bool using_utf8(void);
#endif #endif
bool is_alpha_mbchar(const char *c); bool is_alpha_char(const char *c);
bool is_blank_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); bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata); char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8

Просмотреть файл

@ -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 /* 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 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. */ * the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_mbchar(before)) && return ((position == 0 || !is_alpha_char(before)) &&
(buf[word_end] == '\0' || !is_alpha_mbchar(after))); (buf[word_end] == '\0' || !is_alpha_char(after)));
} }
#endif /* ENABLE_SPELLER */ #endif /* ENABLE_SPELLER */

Просмотреть файл

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