tweaks: rename a variable to be shorter and clearer

master
Benno Schulenberg 2016-12-15 15:50:07 +01:00
parent eb88ad980a
commit fc101a6ded
1 changed files with 9 additions and 9 deletions

View File

@ -372,27 +372,27 @@ char *make_mbchar(long chr, int *chr_mb_len)
* we expect col to have the current display width. */ * we expect col to have the current display width. */
int parse_mbchar(const char *buf, char *chr, size_t *col) int parse_mbchar(const char *buf, char *chr, size_t *col)
{ {
int buf_mb_len; int length;
assert(buf != NULL); assert(buf != NULL);
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
if (use_utf8) { if (use_utf8) {
/* Get the number of bytes in the multibyte character. */ /* Get the number of bytes in the multibyte character. */
buf_mb_len = mblen(buf, MB_CUR_MAX); length = mblen(buf, MB_CUR_MAX);
/* When the multibyte sequence is invalid, only take the first byte. */ /* When the multibyte sequence is invalid, only take the first byte. */
if (buf_mb_len < 0) { if (length < 0) {
IGNORE_CALL_RESULT(mblen(NULL, 0)); IGNORE_CALL_RESULT(mblen(NULL, 0));
buf_mb_len = 1; length = 1;
} else if (buf_mb_len == 0) } else if (length == 0)
buf_mb_len++; length = 1;
/* When requested, store the multibyte character in chr. */ /* When requested, store the multibyte character in chr. */
if (chr != NULL) { if (chr != NULL) {
int i; int i;
for (i = 0; i < buf_mb_len; i++) for (i = 0; i < length; i++)
chr[i] = buf[i]; chr[i] = buf[i];
} }
@ -415,7 +415,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
#endif #endif
{ {
/* A byte character is one byte long. */ /* A byte character is one byte long. */
buf_mb_len = 1; length = 1;
/* When requested, store the byte character in chr. */ /* When requested, store the byte character in chr. */
if (chr != NULL) if (chr != NULL)
@ -437,7 +437,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
} }
} }
return buf_mb_len; return length;
} }
/* Return the index in buf of the beginning of the multibyte character /* Return the index in buf of the beginning of the multibyte character