tweaks: elide a variable, by returning the result directly

master
Benno Schulenberg 2020-07-20 16:54:22 +02:00
parent e4fa0b54a2
commit 9067f7a0c7
1 changed files with 13 additions and 15 deletions

View File

@ -862,6 +862,8 @@ int convert_to_control(int kbinput)
return kbinput; return kbinput;
} }
#define PROCEED -44
/* Extract one keystroke from the input stream. Translate escape sequences /* Extract one keystroke from the input stream. Translate escape sequences
* and possibly keypad codes into their corresponding values. Set meta_key * and possibly keypad codes into their corresponding values. Set meta_key
* to TRUE when appropriate. Supported keypad keystrokes are: the arrow keys, * to TRUE when appropriate. Supported keypad keystrokes are: the arrow keys,
@ -960,7 +962,9 @@ int parse_kbinput(WINDOW *win)
/* If the decimal byte value is complete, convert it and /* If the decimal byte value is complete, convert it and
* put the obtained byte(s) back into the input buffer. */ * put the obtained byte(s) back into the input buffer. */
if (byte != ERR) { if (byte == PROCEED)
return ERR;
else {
char *multibyte; char *multibyte;
int count, onebyte, i; int count, onebyte, i;
@ -1316,7 +1320,6 @@ int get_kbinput(WINDOW *win, bool showcursor)
int get_byte_kbinput(int kbinput) int get_byte_kbinput(int kbinput)
{ {
static int byte = 0; static int byte = 0;
int retval = ERR;
/* Check that the given digit is within the allowed range for its position. /* Check that the given digit is within the allowed range for its position.
* If yes, store it. If no, return the digit (or character) itself. */ * If yes, store it. If no, return the digit (or character) itself. */
@ -1324,34 +1327,29 @@ int get_byte_kbinput(int kbinput)
case 1: case 1:
/* The first digit (the 100's position) is from zero to two. */ /* The first digit (the 100's position) is from zero to two. */
byte = (kbinput - '0') * 100; byte = (kbinput - '0') * 100;
break; return PROCEED;
case 2: case 2:
/* The second digit (the 10's position) must be from zero to five /* The second digit (the 10's position) must be from zero to five
* if the first was two, and may be any decimal value otherwise. */ * if the first was two, and may be any decimal value otherwise. */
if (byte < 200 || kbinput <= '5') if (byte < 200 || kbinput <= '5') {
byte += (kbinput - '0') * 10; byte += (kbinput - '0') * 10;
else return PROCEED;
retval = kbinput; } else
break; return kbinput;
case 3: case 3:
/* The third digit (the 1's position) must be from zero to five /* The third digit (the 1's position) must be from zero to five
* if the first was two and the second was five, and may be any * if the first was two and the second was five, and may be any
* decimal value otherwise. */ * decimal value otherwise. */
if (byte < 250 || kbinput <= '5') { if (byte < 250 || kbinput <= '5') {
byte += kbinput - '0'; return (byte + kbinput - '0');
/* The byte sequence is complete. */
retval = byte;
} else } else
retval = kbinput; return kbinput;
break;
} }
return retval; return 0; /* FIXME: this suppresses a compilation warning */
} }
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
#define PROCEED -4
/* 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 *uni)