summary refs log tree commit diff
path: root/Src/Zle/zle_utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-01-27 14:54:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-01-27 14:54:31 +0000
commit778a73b027509c9c9f70c8dbd184097efeacae43 (patch)
tree17d52da7da8fd0a1f85a0491b52e80ab66299f4b /Src/Zle/zle_utils.c
parentcd70d2745cc34cd05292e6c87fa1e4f272792313 (diff)
downloadzsh-778a73b027509c9c9f70c8dbd184097efeacae43.tar.gz
zsh-778a73b027509c9c9f70c8dbd184097efeacae43.tar.xz
zsh-778a73b027509c9c9f70c8dbd184097efeacae43.zip
18139: Improve $killring interface; can now change length. Empty
strings in $killring are ignored when yank-popping.  Yank-popping
is more consistent about looping and using the original cutbuffer.
Diffstat (limited to 'Src/Zle/zle_utils.c')
-rw-r--r--Src/Zle/zle_utils.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 107ff37ec..28f5647bd 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -38,9 +38,9 @@ struct cutbuffer cutbuf;
 /* Emacs-style kill buffer ring */
 
 /**/
-struct cutbuffer kring[KRINGCT];
+struct cutbuffer *kring;
 /**/
-int kringnum;
+int kringsize, kringnum;
 
 /* Vi named cut buffers.  0-25 are the named buffers "a to "z, and *
  * 26-34 are the numbered buffer stack "1 to "9.                   */
@@ -167,10 +167,16 @@ cut(int i, int ct, int dir)
 	cutbuf.buf = ztrdup("");
 	cutbuf.len = cutbuf.flags = 0;
     } else if (!(lastcmd & ZLE_KILL)) {
-	kringnum = (kringnum + 1) % KRINGCT;
-	if (kring[kringnum].buf)
-	    free(kring[kringnum].buf);
-	kring[kringnum] = cutbuf;
+	Cutbuffer kptr;
+	if (!kring) {
+	    kringsize = KRINGCTDEF;
+	    kring = (Cutbuffer)zcalloc(kringsize * sizeof(struct cutbuffer));
+	} else
+	    kringnum = (kringnum + 1) % kringsize;
+	kptr = kring + kringnum;
+	if (kptr->buf)
+	    zfree(kptr->buf, kptr->len);
+	*kptr = cutbuf;
 	cutbuf.buf = ztrdup("");
 	cutbuf.len = cutbuf.flags = 0;
     }