tweaks: rename two variables, away from abbreviations
parent
6b9084ad09
commit
aafda2358f
34
src/winio.c
34
src/winio.c
|
@ -1317,12 +1317,12 @@ int get_kbinput(WINDOW *win, bool showcursor)
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
/* If the character in kbinput is a valid hexadecimal digit, multiply it
|
/* If the character in kbinput is a valid hexadecimal digit, multiply it
|
||||||
* by factor and add the result to uni, and return PROCEED to signify okay. */
|
* by factor and add the result to uni, and return PROCEED to signify okay. */
|
||||||
long add_unicode_digit(int kbinput, long factor, long *uni)
|
long add_unicode_digit(int kbinput, long factor, long *unicode)
|
||||||
{
|
{
|
||||||
if ('0' <= kbinput && kbinput <= '9')
|
if ('0' <= kbinput && kbinput <= '9')
|
||||||
*uni += (kbinput - '0') * factor;
|
*unicode += (kbinput - '0') * factor;
|
||||||
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
|
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
|
||||||
*uni += (tolower(kbinput) - 'a' + 10) * factor;
|
*unicode += (tolower(kbinput) - 'a' + 10) * factor;
|
||||||
else
|
else
|
||||||
/* The character isn't hexadecimal; give it as the result. */
|
/* The character isn't hexadecimal; give it as the result. */
|
||||||
return (long)kbinput;
|
return (long)kbinput;
|
||||||
|
@ -1335,38 +1335,38 @@ long add_unicode_digit(int kbinput, long factor, long *uni)
|
||||||
* assembled Unicode; until then, return PROCEED when the given digit is valid. */
|
* assembled Unicode; until then, return PROCEED when the given digit is valid. */
|
||||||
long assemble_unicode(int kbinput)
|
long assemble_unicode(int kbinput)
|
||||||
{
|
{
|
||||||
static int uni_digits = 0;
|
static long unicode = 0;
|
||||||
static long uni = 0;
|
static int digits = 0;
|
||||||
long retval = PROCEED;
|
long retval = PROCEED;
|
||||||
|
|
||||||
switch (++uni_digits) {
|
switch (++digits) {
|
||||||
case 1:
|
case 1:
|
||||||
uni = (kbinput - '0') * 0x100000;
|
unicode = (kbinput - '0') * 0x100000;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* The second digit must be zero if the first was one, but
|
/* The second digit must be zero if the first was one, but
|
||||||
* may be any hexadecimal value if the first was zero. */
|
* may be any hexadecimal value if the first was zero. */
|
||||||
if (kbinput == '0' || uni == 0)
|
if (kbinput == '0' || unicode == 0)
|
||||||
retval = add_unicode_digit(kbinput, 0x10000, &uni);
|
retval = add_unicode_digit(kbinput, 0x10000, &unicode);
|
||||||
else
|
else
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Later digits may be any hexadecimal value. */
|
/* Later digits may be any hexadecimal value. */
|
||||||
retval = add_unicode_digit(kbinput, 0x1000, &uni);
|
retval = add_unicode_digit(kbinput, 0x1000, &unicode);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
retval = add_unicode_digit(kbinput, 0x100, &uni);
|
retval = add_unicode_digit(kbinput, 0x100, &unicode);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
retval = add_unicode_digit(kbinput, 0x10, &uni);
|
retval = add_unicode_digit(kbinput, 0x10, &unicode);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
retval = add_unicode_digit(kbinput, 0x1, &uni);
|
retval = add_unicode_digit(kbinput, 0x1, &unicode);
|
||||||
/* If also the sixth digit was a valid hexadecimal value, then
|
/* If also the sixth digit was a valid hexadecimal value, then
|
||||||
* the Unicode sequence is complete, so return it. */
|
* the Unicode sequence is complete, so return it. */
|
||||||
if (retval == PROCEED)
|
if (retval == PROCEED)
|
||||||
retval = uni;
|
retval = unicode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1375,8 +1375,8 @@ long assemble_unicode(int kbinput)
|
||||||
char partial[7] = "......";
|
char partial[7] = "......";
|
||||||
|
|
||||||
/* Construct the partial result, right-padding it with dots. */
|
/* Construct the partial result, right-padding it with dots. */
|
||||||
snprintf(partial, uni_digits + 1, "%06lX", uni);
|
snprintf(partial, digits + 1, "%06lX", unicode);
|
||||||
partial[uni_digits] = '.';
|
partial[digits] = '.';
|
||||||
|
|
||||||
/* TRANSLATORS: This is shown while a six-digit hexadecimal
|
/* TRANSLATORS: This is shown while a six-digit hexadecimal
|
||||||
* Unicode character code (%s) is being typed in. */
|
* Unicode character code (%s) is being typed in. */
|
||||||
|
@ -1385,7 +1385,7 @@ long assemble_unicode(int kbinput)
|
||||||
|
|
||||||
/* If we have an end result, reset the Unicode digit counter. */
|
/* If we have an end result, reset the Unicode digit counter. */
|
||||||
if (retval != PROCEED)
|
if (retval != PROCEED)
|
||||||
uni_digits = 0;
|
digits = 0;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue