about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--Doc/Zsh/zle.yo6
-rw-r--r--Src/builtin.c44
3 files changed, 37 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ec6f2cb3..88243e5a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-12-10  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* unpost: Doc/Zsh/zle.yo: documentation for CUTBUFFER and killring
+	ought to be more explicit about their connection.
+
+	* 23044: Src/builtin.c: print -c/-C is yet another version
+	of print no one bothered to fix up to handle unmetafication
+	properly.
+
 2006-12-08  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* based on 23038: Completion/Unix/Command/_webbrowser,
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 6e0d82513..d600a49eb 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -662,7 +662,8 @@ cursor being moved to the appropriate end of the buffer.
 vindex(CUTBUFFER)
 item(tt(CUTBUFFER) (scalar))(
 The last item to be cut using one of the `tt(kill-)' commands; the
-string which the next yank would insert in the line.
+string which the next yank would insert in the line.  Later entries in
+the kill ring are in the array tt(killring).
 )
 vindex(HISTNO)
 item(tt(HISTNO) (integer))(
@@ -686,7 +687,8 @@ vindex(killring)
 item(tt(killring) (array))(
 The array of previously killed items, with the most recently killed first.
 This gives the items that would be retrieved by a tt(yank-pop) in the
-same order.
+same order.  Note, however, that the most recently killed item is in
+tt($CUTBUFFER); tt($killring) shows the array of previous entries.
 
 The default size for the kill ring is eight, however the length may be
 changed by normal array operations.  Any empty string in the kill ring is
diff --git a/Src/builtin.c b/Src/builtin.c
index e567675ff..d756b28bb 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3603,6 +3603,13 @@ bin_print(char *name, char **args, Options ops, int func)
     }
 
     /* -o and -O -- sort the arguments */
+    /*
+     * TODO: this appears to be yet another of the endless
+     * chunks of code that didn't get fixed up properly
+     * to reflect the fact that args contains unmetafied
+     * strings that may contain NULs with the lengths in
+     * len.
+     */
     if (OPT_ISSET(ops,'o')) {
 	if (fmt && !*args) return 0;
 	if (OPT_ISSET(ops,'i'))
@@ -3624,7 +3631,6 @@ bin_print(char *name, char **args, Options ops, int func)
     /* -c -- output in columns */
     if (!fmt && (OPT_ISSET(ops,'c') || OPT_ISSET(ops,'C'))) {
 	int l, nc, nr, sc, n, t, i;
-	char **ap;
 
 	if (OPT_ISSET(ops,'C')) {
 	    char *eptr, *argptr = OPT_ARG(ops,'C');
@@ -3647,13 +3653,12 @@ bin_print(char *name, char **args, Options ops, int func)
 
 	    /*
 	     * i: loop counter
-	     * ap: array iterator
 	     * l: maximum length seen
 	     *
 	     * Ignore lengths in last column since they don't affect
 	     * the separation.
 	     */
-	    for (i = l = 0, ap = args; *ap; ap++, i++) {
+	    for (i = l = 0; i < argc; i++) {
 		if (OPT_ISSET(ops, 'a')) {
 		    if ((i % nc) == nc - 1)
 			continue;
@@ -3661,8 +3666,8 @@ bin_print(char *name, char **args, Options ops, int func)
 		    if (i >= nr * (nc - 1))
 			break;
 		}
-		if (l < (t = strlen(*ap)))
-		    l = t;
+		if (l < len[i])
+		    l = len[i];
 	    }
 	    sc = l + 2;
 	}
@@ -3670,12 +3675,11 @@ bin_print(char *name, char **args, Options ops, int func)
 	{
 	    /*
 	     * n: loop counter
-	     * ap: array iterator
 	     * l: maximum length seen
 	     */
-	    for (n = l = 0, ap = args; *ap; ap++, n++)
-		if (l < (t = strlen(*ap)))
-		    l = t;
+	    for (n = l = 0; n < argc; n++)
+		if (l < len[n])
+		    l = len[n];
 
 	    /*
 	     * sc: column width
@@ -3689,31 +3693,31 @@ bin_print(char *name, char **args, Options ops, int func)
 	}
 
 	if (OPT_ISSET(ops,'a'))	/* print across, i.e. columns first */
-	    ap = args;
+	    n = 0;
 	for (i = 0; i < nr; i++) {
 	    if (OPT_ISSET(ops,'a'))
 	    {
 		int ic;
-		for (ic = 0; ic < nc && *ap; ic++, ap++)
+		for (ic = 0; ic < nc && n < argc; ic++, n++)
 		{
-		    l = strlen(*ap);
-		    fprintf(fout, "%s", *ap);
-		    if (*ap)
+		    l = len[n];
+		    fwrite(args[n], l, 1, fout);
+		    if (n < argc)
 			for (; l < sc; l++)
 			    fputc(' ', fout);
 		}
 	    }
 	    else
 	    {
-		ap = args + i;
+		n = i;
 		do {
-		    l = strlen(*ap);
-		    fprintf(fout, "%s", *ap);
-		    for (t = nr; t && *ap; t--, ap++);
-		    if (*ap)
+		    l = len[n];
+		    fwrite(args[n], l, 1, fout);
+		    for (t = nr; t && n < argc; t--, n++);
+		    if (n < argc)
 			for (; l < sc; l++)
 			    fputc(' ', fout);
-		} while (*ap);
+		} while (n < argc);
 	    }
 	    fputc(OPT_ISSET(ops,'N') ? '\0' : '\n', fout);
 	}