1
1

tweaks: rename three variables, for contrast and more sense

Этот коммит содержится в:
Benno Schulenberg 2019-10-03 10:12:30 +02:00
родитель acf50ae26d
Коммит 3158133edd

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

@ -222,32 +222,32 @@ int mbwidth(const char *c)
return 1; return 1;
} }
/* Convert the Unicode value in chr to a multibyte character, if possible. /* Convert the Unicode value in code to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte * If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically * character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */ * allocated) multibyte character and a length of zero. */
char *make_mbchar(long chr, int *chr_mb_len) char *make_mbchar(long code, int *length)
{ {
char *chr_mb; char *mb_char;
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
if (use_utf8) { if (use_utf8) {
chr_mb = charalloc(MAXCHARLEN); mb_char = charalloc(MAXCHARLEN);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr); *length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */ /* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) { if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0)); IGNORE_CALL_RESULT(wctomb(NULL, 0));
*chr_mb_len = 0; *length = 0;
} }
} else } else
#endif #endif
{ {
*chr_mb_len = 1; mb_char = mallocstrncpy(NULL, (char *)&code, 1);
chr_mb = mallocstrncpy(NULL, (char *)&chr, 1); *length = 1;
} }
return chr_mb; return mb_char;
} }
/* Return the length (in bytes) of the character located at *pointer. */ /* Return the length (in bytes) of the character located at *pointer. */