A partion of Key_Console() can be simplified by using memmove()

This commit is contained in:
Anton E. Gavrilov 2000-07-28 14:37:41 +00:00
parent 858a0e5db2
commit b0f20f955c

View file

@ -428,19 +428,14 @@ no_lf:
if (key < 32 || key > 127) if (key < 32 || key > 127)
return; // non printable return; // non printable
if (key_linepos < MAXCMDLINE-1) i = strlen(key_lines[edit_line]);
{ if (i >= MAXCMDLINE-1)
i = strlen(key_lines[edit_line]) - 1; return;
if (i == MAXCMDLINE-2) i--;
for (; i >= key_linepos; i--)
key_lines[edit_line][i + 1] = key_lines[edit_line][i];
i = key_lines[edit_line][key_linepos];
key_lines[edit_line][key_linepos] = key;
key_linepos++;
if (!i) // // only null terminate if at the end
key_lines[edit_line][key_linepos] = 0;
}
// This also moves the ending \0
memmove (key_lines[edit_line]+key_linepos+1, key_lines[edit_line]+key_linepos, i-key_linepos+1);
key_lines[edit_line][key_linepos] = key;
key_linepos++;
} }
//============================================================================ //============================================================================