treg: upper-case letter to append to yank buffers - neatvi - [fork] simple vi-t… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit ec086911d042a074ad149289f4200c3248446096 | |
parent 02c3248a2537cdccb0ccf6f91ad6df16cf902c15 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Sat, 16 May 2015 12:26:48 +0430 | |
reg: upper-case letter to append to yank buffers | |
Diffstat: | |
M reg.c | 13 ++++++++----- | |
1 file changed, 8 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/reg.c b/reg.c | |
t@@ -1,3 +1,4 @@ | |
+#include <ctype.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "vi.h" | |
t@@ -13,11 +14,13 @@ char *reg_get(int c, int *ln) | |
void reg_put(int c, char *s, int ln) | |
{ | |
- char *buf = malloc(strlen(s) + 1); | |
- strcpy(buf, s); | |
- free(bufs[c]); | |
- bufs[c] = buf; | |
- lnmode[c] = ln; | |
+ char *pre = isupper(c) ? bufs[tolower(c)] : ""; | |
+ char *buf = malloc(strlen(pre) + strlen(s) + 1); | |
+ strcpy(buf, pre); | |
+ strcat(buf, s); | |
+ free(bufs[tolower(c)]); | |
+ bufs[tolower(c)] = buf; | |
+ lnmode[tolower(c)] = ln; | |
} | |
void reg_done(void) |