tweaks: improve four comments
parent
57c52de99a
commit
a0d2e63c8e
17
src/winio.c
17
src/winio.c
|
@ -837,31 +837,28 @@ int parse_escape_sequence(int firstbyte)
|
||||||
|
|
||||||
#define PROCEED -44
|
#define PROCEED -44
|
||||||
|
|
||||||
/* Turn a three-digit decimal number (from 000 to 255) into its corresponding
|
/* For each consecutive call, gather the given digit into a three-digit
|
||||||
* byte value. */
|
* decimal byte code (from 000 to 255). Return the assembled code when
|
||||||
|
* it is complete, but until then return PROCEED when the given digit is
|
||||||
|
* valid, and the given digit itself otherwise. */
|
||||||
int assemble_byte_code(int kbinput)
|
int assemble_byte_code(int kbinput)
|
||||||
{
|
{
|
||||||
static int byte = 0;
|
static int byte = 0;
|
||||||
|
|
||||||
/* 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. */
|
|
||||||
switch (++digit_count) {
|
switch (++digit_count) {
|
||||||
case 1:
|
case 1:
|
||||||
/* The first digit (the 100's position) is from zero to two. */
|
/* The first digit is either 0, 1, or 2. */
|
||||||
byte = (kbinput - '0') * 100;
|
byte = (kbinput - '0') * 100;
|
||||||
return PROCEED;
|
return PROCEED;
|
||||||
case 2:
|
case 2:
|
||||||
/* The second digit (the 10's position) must be from zero to five
|
/* The second digit may be at most 5 if the first was 2. */
|
||||||
* 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;
|
||||||
return PROCEED;
|
return PROCEED;
|
||||||
} else
|
} else
|
||||||
return kbinput;
|
return kbinput;
|
||||||
case 3:
|
case 3:
|
||||||
/* The third digit (the 1's position) must be from zero to five
|
/* The third digit may be at most 5 if first two were 2 and 5. */
|
||||||
* if the first was two and the second was five, and may be any
|
|
||||||
* decimal value otherwise. */
|
|
||||||
if (byte < 250 || kbinput <= '5') {
|
if (byte < 250 || kbinput <= '5') {
|
||||||
return (byte + kbinput - '0');
|
return (byte + kbinput - '0');
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue