commit 8625609c2d96f77cda7a52679447a20e10cd8936
parent 3c4a4b04cec738d45939a3d2f4ba82a7e4bf6e69
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 17 Feb 2020 19:41:57 +0100
tweaks: rename a variable, and add a helping one
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -1638,7 +1638,8 @@ void process_a_keystroke(void)
/* Insert the given short burst of bytes into the edit buffer. */
void inject(char *burst, size_t count)
{
- size_t current_len = strlen(openfile->current->data);
+ size_t datalen = strlen(openfile->current->data);
+ char *thepoint = openfile->current->data + openfile->current_x;
#ifndef NANO_TINY
size_t original_row = 0, old_amount = 0;
@@ -1665,11 +1666,9 @@ void inject(char *burst, size_t count)
/* Make room for the new bytes and copy them into the line. */
openfile->current->data = charealloc(openfile->current->data,
- current_len + count + 1);
- memmove(openfile->current->data + openfile->current_x + count,
- openfile->current->data + openfile->current_x,
- current_len - openfile->current_x + 1);
- strncpy(openfile->current->data + openfile->current_x, burst, count);
+ datalen + count + 1);
+ memmove(thepoint + count, thepoint, datalen - openfile->current_x + 1);
+ strncpy(thepoint, burst, count);
#ifndef NANO_TINY
/* When the mark is to the right of the cursor, compensate its position. */