zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: completion after < at the start of the line
Date: Thu, 29 Mar 2007 22:25:03 +0100	[thread overview]
Message-ID: <20070329222503.2b920aa4.p.w.stephenson@ntlworld.com> (raw)
In-Reply-To: <20070328222525.e4cf0654.p.w.stephenson@ntlworld.com>

On Wed, 28 Mar 2007 22:25:25 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> I've been seeing something screwy to do with the complist module when
> trying this.  It doesn't seem to be related; it happens with or without
> an initial redirection, but I happened to fall over it when testing
> this.  I've been getting it with "ls --<TAB>" with menu selection turned
> on.

I think I've tracked this down after a couple of hours of frustration:
if the last line in a completion list was just short of the width,
complist() turned off printing early, but didn't increment over the
character it wasn't printing, which could be just enough to force the
string to need an extra line.  This was quite a special case.

I added some extra debugging aids to help track this down; in
particular, if zsh is compiled with debugging, ZSH_DEBUG_LOG can be used
to give a file to which dputs output is appended.  I've left this in.

Index: INSTALL
===================================================================
RCS file: /cvsroot/zsh/zsh/INSTALL,v
retrieving revision 1.28
diff -u -r1.28 INSTALL
--- INSTALL	1 Nov 2006 12:25:21 -0000	1.28
+++ INSTALL	29 Mar 2007 21:18:14 -0000
@@ -326,6 +326,9 @@
 To add some sanity checks and generate debugging information for debuggers
 you can use the following option.  This also disables optimization.
  --enable-zsh-debug            # use it if you want to debug zsh
+In this mode, zsh may output extra information about internal errors
+to stderr.  The shell variable ZSH_DEBUG_LOG may be set to another file
+to which errors will be appended.
 
 Startup/shutdown files
 ----------------------
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.159
diff -u -r1.159 utils.c
--- Src/utils.c	26 Feb 2007 18:47:25 -0000	1.159
+++ Src/utils.c	29 Mar 2007 21:18:16 -0000
@@ -129,7 +129,7 @@
 	fputc((unsigned char)':', stderr);
     }
 
-    zerrmsg(fmt, ap);
+    zerrmsg(stderr, fmt, ap);
 }
 
 
@@ -218,14 +218,20 @@
 dputs(VA_ALIST1(const char *message))
 VA_DCL
 {
+    char *filename;
+    FILE *file;
     va_list ap;
     VA_DEF_ARG(const char *message);
 
     VA_START(ap, message);
     VA_GET_ARG(ap, message, const char *);
-    zerrmsg(message, ap);
+    if ((filename = getsparam("ZSH_DEBUG_LOG")) != NULL &&
+	(file = fopen(filename, "a")) != NULL) {
+	zerrmsg(file, message, ap);
+	fclose(file);
+    } else
+	zerrmsg(stderr, message, ap);
     va_end(ap);
-    fflush(stderr);
 }
 
 #endif /* DEBUG */
@@ -245,15 +251,15 @@
 
 /**/
 void
-zerrmsg(const char *fmt, va_list ap)
+zerrmsg(FILE *file, const char *fmt, va_list ap)
 {
     const char *str;
     int num;
 
     if ((unset(SHINSTDIN) || locallevel) && lineno)
-	fprintf(stderr, "%ld: ", (long)lineno);
+	fprintf(file, "%ld: ", (long)lineno);
     else
-	fputc((unsigned char)' ', stderr);
+	fputc((unsigned char)' ', file);
 
     while (*fmt)
 	if (*fmt == '%') {
@@ -261,7 +267,7 @@
 	    switch (*fmt++) {
 	    case 's':
 		str = va_arg(ap, const char *);
-		nicezputs(str, stderr);
+		nicezputs(str, file);
 		break;
 	    case 'l': {
 		char *s;
@@ -271,50 +277,50 @@
 		s = zhalloc(num + 1);
 		memcpy(s, str, num);
 		s[num] = '\0';
-		nicezputs(s, stderr);
+		nicezputs(s, file);
 		break;
 	    }
 	    case 'd':
 		num = va_arg(ap, int);
-		fprintf(stderr, "%d", num);
+		fprintf(file, "%d", num);
 		break;
 	    case '%':
-		putc('%', stderr);
+		putc('%', file);
 		break;
 	    case 'c':
 		num = va_arg(ap, int);
 #ifdef MULTIBYTE_SUPPORT
 		mb_metacharinit();
-		zputs(wcs_nicechar(num, NULL, NULL), stderr);
+		zputs(wcs_nicechar(num, NULL, NULL), file);
 #else
-		zputs(nicechar(num), stderr);
+		zputs(nicechar(num), file);
 #endif
 		break;
 	    case 'e':
 		/* print the corresponding message for this errno */
 		num = va_arg(ap, int);
 		if (num == EINTR) {
-		    fputs("interrupt\n", stderr);
+		    fputs("interrupt\n", file);
 		    errflag = 1;
 		    return;
 		}
 		/* If the message is not about I/O problems, it looks better *
 		 * if we uncapitalize the first letter of the message        */
 		if (num == EIO)
-		    fputs(strerror(num), stderr);
+		    fputs(strerror(num), file);
 		else {
 		    char *errmsg = strerror(num);
-		    fputc(tulower(errmsg[0]), stderr);
-		    fputs(errmsg + 1, stderr);
+		    fputc(tulower(errmsg[0]), file);
+		    fputs(errmsg + 1, file);
 		}
 		break;
 	    }
 	} else {
-	    putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, stderr);
+	    putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, file);
 	    fmt++;
 	}
-    putc('\n', stderr);
-    fflush(stderr);
+    putc('\n', file);
+    fflush(file);
 }
 
 /* Output a single character, for the termcap routines.     *
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.111
diff -u -r1.111 zsh.h
--- Src/zsh.h	19 Mar 2007 12:21:55 -0000	1.111
+++ Src/zsh.h	29 Mar 2007 21:18:17 -0000
@@ -1925,10 +1925,12 @@
 # define DPUTS(X,Y) if (!(X)) {;} else dputs(ERRMSG(Y))
 # define DPUTS1(X,Y,Z1) if (!(X)) {;} else dputs(ERRMSG(Y), Z1)
 # define DPUTS2(X,Y,Z1,Z2) if (!(X)) {;} else dputs(ERRMSG(Y), Z1, Z2)
+# define DPUTS3(X,Y,Z1,Z2,Z3) if (!(X)) {;} else dputs(ERRMSG(Y), Z1, Z2, Z3)
 #else
 # define DPUTS(X,Y)
 # define DPUTS1(X,Y,Z1)
 # define DPUTS2(X,Y,Z1,Z2)
+# define DPUTS3(X,Y,Z1,Z2,Z3)
 #endif
 
 /**************************/
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.99
diff -u -r1.99 complist.c
--- Src/Zle/complist.c	6 Feb 2007 10:12:20 -0000	1.99
+++ Src/Zle/complist.c	29 Mar 2007 21:18:18 -0000
@@ -1139,6 +1139,10 @@
 	    if (dopr == 1) {
 		if (ml == mlend - 1 && (cc % columns) == columns - 1) {
 		    dopr = 0;
+		    if (*p == Meta)
+			p += 2;
+		    else
+			p++;
 		    continue;
 		}
 		while (len--) {
@@ -1580,6 +1584,8 @@
     Cmatch m;
     int len, subcols = 0, stop = 0, ret = 0;
 
+    DPUTS2(ml >= mlines, "clprintm called with ml too large (%d/%d)",
+	   ml, mlines);
     if (g != last_group)
         *last_cap = '\0';
 

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2007-03-29 21:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-27 21:37 Stephane Chazelas
2007-03-28 14:29 ` Peter Stephenson
2007-03-28 21:25   ` Peter Stephenson
2007-03-29 21:25     ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070329222503.2b920aa4.p.w.stephenson@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).