input: elide an extra buffer for inserting stuff into the text
Do the casting from integer to character rightaway in the first intermediate buffer.master
parent
24b10179a1
commit
067b0a3367
24
src/nano.c
24
src/nano.c
|
@ -1569,7 +1569,7 @@ int do_input(bool allow_funcs)
|
||||||
{
|
{
|
||||||
int input;
|
int input;
|
||||||
/* The keystroke we read in: a character or a shortcut. */
|
/* The keystroke we read in: a character or a shortcut. */
|
||||||
static int *puddle = NULL;
|
static char *puddle = NULL;
|
||||||
/* The input buffer for actual characters. */
|
/* The input buffer for actual characters. */
|
||||||
static size_t depth = 0;
|
static size_t depth = 0;
|
||||||
/* The length of the input buffer. */
|
/* The length of the input buffer. */
|
||||||
|
@ -1625,9 +1625,9 @@ int do_input(bool allow_funcs)
|
||||||
if (ISSET(VIEW_MODE))
|
if (ISSET(VIEW_MODE))
|
||||||
print_view_warning();
|
print_view_warning();
|
||||||
else {
|
else {
|
||||||
depth++;
|
/* Store the byte, and leave room for a terminating zero. */
|
||||||
puddle = (int *)nrealloc(puddle, depth * sizeof(int));
|
puddle = charealloc(puddle, depth + 2);
|
||||||
puddle[depth - 1] = input;
|
puddle[depth++] = (char)input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1644,18 +1644,10 @@ int do_input(bool allow_funcs)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (puddle != NULL) {
|
if (puddle != NULL) {
|
||||||
/* Display all the characters in the input buffer at
|
/* Insert all bytes in the input buffer into the edit buffer
|
||||||
* once, filtering out control characters. */
|
* at once, filtering out any low control codes. */
|
||||||
char *output = charalloc(depth + 1);
|
puddle[depth] = '\0';
|
||||||
size_t i;
|
do_output(puddle, depth, FALSE);
|
||||||
|
|
||||||
for (i = 0; i < depth; i++)
|
|
||||||
output[i] = (char)puddle[i];
|
|
||||||
output[i] = '\0';
|
|
||||||
|
|
||||||
do_output(output, depth, FALSE);
|
|
||||||
|
|
||||||
free(output);
|
|
||||||
|
|
||||||
/* Empty the input buffer. */
|
/* Empty the input buffer. */
|
||||||
free(puddle);
|
free(puddle);
|
||||||
|
|
Loading…
Reference in New Issue