summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2006-02-27 00:17:39 +0000
committersabetts <sabetts>2006-02-27 00:17:39 +0000
commit8460497f0ed5ea8a6b7f0029243a26713a36cc47 (patch)
tree27472aa0351711de67abc531052650a18e540c87 /src
parent50171e15dbe6a51464059ad820f5a0464f3d60fa (diff)
downloadratpoison-8460497f0ed5ea8a6b7f0029243a26713a36cc47.zip
(editor_insert): use memmove to make room for
inserted string.
Diffstat (limited to 'src')
-rw-r--r--src/editor.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/editor.c b/src/editor.c
index 98147ac..3965464 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -443,27 +443,23 @@ static edit_status
editor_insert (rp_input_line *line, char *keysym_buf)
{
int nbytes;
- int i;
PRINT_DEBUG (("keysym_buf: '%s'\n", keysym_buf));
nbytes = strlen (keysym_buf);
if (line->length + nbytes > line->size - 1)
{
+ /* FIXME: This seems like a very bad idea. */
line->size += nbytes + 100;
line->buffer = xrealloc (line->buffer, line->size);
}
- for (i = line->length + nbytes; i > line->position; i--)
- line->buffer[i] = line->buffer[i - nbytes];
-
+ memmove (&line->buffer[line->position + nbytes], &line->buffer[line->position], line->length - line->position);
strncpy (&line->buffer[line->position], keysym_buf, nbytes);
line->length += nbytes;
line->position += nbytes;
- PRINT_DEBUG (("line->buffer: '%s'\n", line->buffer));
-
return EDIT_INSERT;
}