summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 14a15db)
raw | patch | inline | side by side (parent: 14a15db)
author | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:18 +0000 (14:56 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:18 +0000 (14:56 +0200) |
Let memmove() do the dirty work on overlapping buffers..
src/wreadln.c | patch | blob | history |
diff --git a/src/wreadln.c b/src/wreadln.c
index 608141f6414e589d6ec74aca7c2610f33694feb1..89bcc123ce371de17e06b2d9f529755b76ed3ca4 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
static void
wreadln_delete_char(struct wreadln *wr, size_t x)
{
- size_t i;
+ size_t rest;
+ const size_t length = 1;
assert(x < strlen(wr->line));
- for (i = x; wr->line[i] != 0; i++)
- wr->line[i] = wr->line[i + 1];
+ rest = strlen(&wr->line[x + length]) + 1;
+ memmove(&wr->line[x], &wr->line[x + length], rest);
}
/* libcurses version */