Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: crash fixed, other minor issue though was: crash in completing code with unicode support



On Wednesday 17 August 2005 04:22, Mikael Magnusson wrote:
> However, when
> i make these things directories instead of files, cd <tab><tab>
> doesn't add any trailing slashes. If i mkdir Øa Øb aa ab, then cd
> <tab><tab><tab> and so on adds trailing slashes after aa and ab, but
> not the first two. (with the same zsh -f sequence as earlier)

This makes ztat() unmetafy its argument; it effectively reverts 21631 (ztat() 
was called in several places). This fixes this issue for me (also some others 
like zstyle ignore-parents parent).

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.75
diff -u -p -r1.75 compcore.c
--- Src/Zle/compcore.c  16 Aug 2005 17:25:49 -0000      1.75
+++ Src/Zle/compcore.c  18 Aug 2005 16:44:07 -0000
@@ -2471,24 +2471,17 @@ add_match_data(int alt, char *str, char
     cm->modec = '\0';
     if ((flags & CMF_FILE) && orig[0] && orig[strlen(orig) - 1] != '/') {
         struct stat buf;
-       char *pb, *blah;
-       int blahl;
+       char *pb;

         pb = (char *) zhalloc((cm->prpre ? strlen(cm->prpre) : 0) +
                               3 + strlen(orig));
         sprintf(pb, "%s%s", (cm->prpre ? cm->prpre : "./"), orig);

-       blah = ztrdup(pb);
-
-       unmetafy(blah, &blahl);
-
-        if (!ztat(blah, &buf, 1)) {
+        if (!ztat(pb, &buf, 1)) {
             cm->mode = buf.st_mode;
             if ((cm->modec = file_type(buf.st_mode)) == ' ')
                 cm->modec = '\0';
         }
-
-       free(blah);
     }
     if ((*compqstack == '\\' && compqstack[1]) ||
        (autoq && *compqstack && compqstack[1] == '\\'))
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.56
diff -u -p -r1.56 compresult.c
--- Src/Zle/compresult.c        10 Aug 2005 19:51:30 -0000      1.56
+++ Src/Zle/compresult.c        18 Aug 2005 16:44:08 -0000
@@ -849,27 +849,33 @@ do_ambiguous(void)
  * parameter says if we have to do lstat() or stat().  I think this   *
  * should instead be done by use of a general function to expand a    *
  * filename (stripping backslashes), combined with the actual         *
- * (l)stat().                                                         */
+ * (l)stat().                                                         *
+ * Make sure input is unmetafied                                      */

 /**/
 mod_export int
 ztat(char *nam, struct stat *buf, int ls)
 {
-    if (!(ls ? lstat(nam, buf) : stat(nam, buf)))
-       return 0;
-    else {
-       char *p;
-       VARARR(char, b, strlen(nam) + 1);
+    int ret;

-       for (p = b; *nam; nam++)
-           if (*nam == '\\' && nam[1])
-               *p++ = *++nam;
+    nam = unmeta(nam);
+    if (!nam)
+       return -1;
+
+    if ((ret = ls ? lstat(nam, buf) : stat(nam, buf))) {
+       char *p, *q;
+
+       for (p = q = nam; *q; q++)
+           if (*q == '\\' && q[1])
+               *p++ = *++q;
            else
-               *p++ = *nam;
+               *p++ = *q;
        *p = '\0';

-       return ls ? lstat(b, buf) : stat(b, buf);
+       ret = ls ? lstat(nam, buf) : stat(nam, buf);
     }
+
+    return ret;
 }

 /* Insert all matches in the command line. */

Attachment: pgpH9CZNeCS0c.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author