zsh-workers
 help / color / mirror / code / Atom feed
* completion in quotes - " vs ' - no suffix added
@ 2002-05-06  7:54 Borsenkow Andrej
  2002-05-06 15:31 ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Borsenkow Andrej @ 2002-05-06  7:54 UTC (permalink / raw)
  To: 'Zsh hackers list'

I stumbled upon that doing mondo completion. It is irrelevant for mondo
itself still it looks strange in general case.

With this completion (from _mondo) and menu selection active:

  "-E[exclude path(s) from backup]:paths to exclude from
backup:->quoted_path" \
  "-I[path(s) to backup]:paths to inlcude in backup:->quoted_path" \

  quoted_path )
    local suf="/ \t\n"
    [[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf"; compset -q;
}
    _files -r $suf && ret=0
  ;;

I get:

bor@itsrm2% l
a b/  c d/
bor@itsrm2% mondoarchive -I 'a\ b c\ d'
Completing file
a\ b/  c\ d/

this is O.K. (including auto-suffix removal) but with " I get

bor@itsrm2% mondoarchive -I "a\\ b
Completing file
a\\ b   c\\ d

no suffix added.

This is with the current CVS version.

-andrej


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-06  7:54 completion in quotes - " vs ' - no suffix added Borsenkow Andrej
@ 2002-05-06 15:31 ` Bart Schaefer
  2002-05-08  7:37   ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2002-05-06 15:31 UTC (permalink / raw)
  To: Borsenkow Andrej, 'Zsh hackers list'

On May 6, 11:54am, Borsenkow Andrej wrote:
} Subject: completion in quotes - " vs ' - no suffix added
}
}   "-E[exclude path(s) from backup]:paths to exclude from
} backup:->quoted_path" \
}   "-I[path(s) to backup]:paths to inlcude in backup:->quoted_path" \
                                    ^^^^^^^
				    You might want to fix that before
				    you commit this completion ...
} 
} bor@itsrm2% mondoarchive -I "a\\ b
} Completing file
} a\\ b   c\\ d
} 
} no suffix added.

Hmm.  It's slightly worse than that ...

schaefer<510> functions _foo
_foo () {
        local suf="/ \t\n"
        [[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf" 
                compset -q }
        _files -r $suf
}
schaefer<511> compdef _foo foo         
schaefer<512> ls                 
don't stop/  rmthat/
schaefer<514> foo '<TAB>
Completing file
don\'\''t\ stop   rmthat/         
schaefer<514> foo "<TAB>
Completing file
don\\'t\\ stop   rmthat/        

Wrong number of backslashes in both cases; that's why the trailing suffix
didn't get added.  This looks similar to the problem we had with _values,
that Sven patched in 16998.

Same thing happens in 4.0.1, by the way, so this is not a new problem.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-06 15:31 ` Bart Schaefer
@ 2002-05-08  7:37   ` Sven Wischnowsky
  2002-05-08  8:49     ` Borsenkow Andrej
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-08  7:37 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> Hmm.  It's slightly worse than that ...
> 
> schaefer<510> functions _foo
> _foo () {
>         local suf="/ \t\n"
>         [[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf" 
>                 compset -q }
>         _files -r $suf
> }
> schaefer<511> compdef _foo foo         
> schaefer<512> ls                 
> don't stop/  rmthat/
> schaefer<514> foo '<TAB>
> Completing file
> don\'\''t\ stop   rmthat/         
> schaefer<514> foo "<TAB>
> Completing file
> don\\'t\\ stop   rmthat/        
> 
> Wrong number of backslashes in both cases; that's why the trailing suffix
> didn't get added.  This looks similar to the problem we had with _values,
> that Sven patched in 16998.

No, it doesn't: there's nothing wrong, as far as I can see. Always
remember, what `compset -q' is intended for, namely things like:

  zsh -c 'echo do<TAB>

Try it and you'll see that it does the right thing. At least it does
for me.

What Andrej probably wants is splitting the current string with a
combination of `compset -[PS]' and the ${(z)...} parameter flag. I'd
like to know how that command is then able to find the different
sub-words in the quoted string if things like spaces are not quoted a
second time.

Or am I missing something?


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: completion in quotes - " vs ' - no suffix added
  2002-05-08  7:37   ` Sven Wischnowsky
@ 2002-05-08  8:49     ` Borsenkow Andrej
  2002-05-08 12:39       ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Borsenkow Andrej @ 2002-05-08  8:49 UTC (permalink / raw)
  To: 'Sven Wischnowsky', zsh-workers

> 
> No, it doesn't: there's nothing wrong, as far as I can see. Always
> remember, what `compset -q' is intended for, namely things like:
> 
>   zsh -c 'echo do<TAB>
> 

Sure. And command can contain anything including file names with spaces
in them, special characters and whatever.

> Try it and you'll see that it does the right thing. At least it does
> for me.
> 

It does not for me. It is the same ` vs " thing:

bor@itsrm2% zsh -c "cd ./a\\ b
Completing directory
a\\ b      c\\ d      uudecode/

but

bor@itsrm2% zsh -c 'cd ./a\ b/
Completing directory
a\ b/      c\ d/      uudecode/


> What Andrej probably wants is splitting the current string with a
> combination of `compset -[PS]' and the ${(z)...} parameter flag. I'd
> like to know how that command is then able to find the different
> sub-words in the quoted string if things like spaces are not quoted a
> second time.
> 
> Or am I missing something?
> 

I do not know. What I actually need is completion of file list in
quotes. This list cannot contain spaces (because mondoarchive cannot
handle them anyway) and wihout spaces compset -q does exactly the right
thing to me. Still as long as I have stumbled onto something that looks
like a bug  ... :-)

-andrej


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: completion in quotes - " vs ' - no suffix added
  2002-05-08  8:49     ` Borsenkow Andrej
@ 2002-05-08 12:39       ` Sven Wischnowsky
  2002-05-08 15:38         ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-08 12:39 UTC (permalink / raw)
  To: zsh-workers


Borsenkow Andrej wrote:

> ...
> 
> It does not for me. It is the same ` vs " thing:
> 
> bor@itsrm2% zsh -c "cd ./a\\ b
> Completing directory
> a\\ b      c\\ d      uudecode/
> 
> but
> 
> bor@itsrm2% zsh -c 'cd ./a\ b/
> Completing directory
> a\ b/      c\ d/      uudecode/

So it does for you, too.

I do you get something different from:

  % ls
  don't stop  rmthat
  % zsh -c 'echo do<TAB>
  % zsh -c 'echo don\''\ stop   # now insert ' and hit RET
  don't stop
  % zsh -c "echo do<TAB>
  % zsh -c "echo don\\'\\ stop   # now insert " and hit RET
  don't stop


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-08 12:39       ` Sven Wischnowsky
@ 2002-05-08 15:38         ` Bart Schaefer
  2002-05-13  9:30           ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2002-05-08 15:38 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On May 8,  2:39pm, Sven Wischnowsky wrote:
} Subject: RE: completion in quotes - " vs ' - no suffix added
}
} 
} Borsenkow Andrej wrote:
} 
} > ...
} > 
} > It does not for me. It is the same ` vs " thing:
} > 
} > bor@itsrm2% zsh -c "cd ./a\\ b
} > Completing directory
} > a\\ b      c\\ d      uudecode/


} So it does for you, too.


Sven, what you're missing is that although the result is correct after
you execute the command, the completion is not correct while the command
line is being built.  That is, if the completion system is going to turn
the file name `a\ b' into the string `"a\\ b"' when it inserts it on the
line, then `compset -q' should also UNDO the backslash-doubling again
when the quote character is a double-quote, so that it's possible to
correctly complete the file path on the second and subsequent calls to
the completion system.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-08 15:38         ` Bart Schaefer
@ 2002-05-13  9:30           ` Sven Wischnowsky
  2002-05-13 10:14             ` Borsenkow Andrej
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-13  9:30 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> Sven, what you're missing is that although the result is correct after
> you execute the command, the completion is not correct while the command
> line is being built.  That is, if the completion system is going to turn
> the file name `a\ b' into the string `"a\\ b"' when it inserts it on the
> line, then `compset -q' should also UNDO the backslash-doubling again
> when the quote character is a double-quote, so that it's possible to
> correctly complete the file path on the second and subsequent calls to
> the completion system.

(Sorry for the delay, I was away on Thursday and Friday.)

(Also sorry for being so bone-headed. Ahem.)

Whew, this was pretty complicated, we have to special-case this stuff.
Because a quoting a single quote inserts more single quotes. This
wasn't even handled correctly (in the case that there was one quoted
single quote in the string) by get_comp_string().

The patch below should fix it. At least it does for the pretty
complicated cases I tried.

Bye
  Sven

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.56
diff -u -r1.56 compcore.c
--- Src/Zle/compcore.c	1 Mar 2002 10:42:02 -0000	1.56
+++ Src/Zle/compcore.c	13 May 2002 09:27:02 -0000
@@ -1175,6 +1175,30 @@
     return t;
 }
 
+/* Remove one of every pair of single quotes, without copying. Return
+ * the number of removed quotes. */
+
+/**/
+mod_export int
+remsquote(char *s)
+{
+    int ret = 0, qa = (isset(RCQUOTES) ? 1 : 3);
+    char *t = s;
+
+    while (*s)
+	if (qa == 1 ?
+            (s[0] == '\'' && s[1] == '\'') :
+            (s[0] == '\'' && s[1] == '\\' && s[2] == '\'' && s[3] == '\'')) {
+            ret += qa;
+            *t++ = '\'';
+            s += qa + 1;
+	} else
+	    *t++ = *s++;
+    *t = '\0';
+
+    return ret;
+}
+
 /* This should probably be moved into tokenize(). */
 
 /**/
@@ -1244,7 +1268,8 @@
     LinkList foo = newlinklist();
     LinkNode n;
     int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
-    int tl, got = 0, i = 0, cur = -1, oll = ll, sl, remq;
+    int tl, got = 0, i = 0, j, cur = -1, oll = ll, sl;
+    int remq = 0, dq = 0, odq, sq = 0, osq, issq = 0, sqq = 0, lsq = 0, qa = 0;
     int ois = instring, oib = inbackt, noffs = lp, ona = noaliases;
     char *tmp, *p, *ns, *ol = (char *) line, sav, *qp, *qs, *ts, qc = '\0';
 
@@ -1266,8 +1291,33 @@
     memcpy(tmp + 1, s, noffs);
     tmp[(scs = cs = 1 + noffs)] = 'x';
     strcpy(tmp + 2 + noffs, s + noffs);
-    if ((remq = (*compqstack == '\\')))
+
+    switch (*compqstack) {
+    case '\\':
+        remq = 1;
 	tmp = rembslash(tmp);
+        break;
+    case '\'':
+        issq = 1;
+        if (isset(RCQUOTES))
+            qa = 1;
+        else
+            qa = 3;
+
+        sq = remsquote(tmp);
+
+        break;
+    case '"':
+        for (j = 0, p = tmp; *p; p++, j++)
+            if (*p == '\\' && p[1] == '\\') {
+                dq++;
+                chuck(p);
+                if (!*p)
+                    break;
+            }
+    }
+    odq = dq;
+    osq = sq;
     inpush(dupstrspace(tmp), 0, NULL);
     line = (unsigned char *) tmp;
     ll = tl - 1;
@@ -1280,9 +1330,10 @@
 
 	    if (!tokstr)
 		break;
-	    for (j = 0, p = tokstr; *p; p++)
+	    for (j = 0, p = tokstr; *p; p++) {
 		if (*p == Snull || *p == Dnull)
 		    j++;
+            }
 	    if (j & 1) {
 		tok = STRING;
 		if (p > tokstr && p[-1] == ' ')
@@ -1291,16 +1342,33 @@
 	}
 	if (tok == ENDINPUT || tok == LEXERR)
 	    break;
-	if (tokstr && *tokstr)
+	if (tokstr && *tokstr) {
+            for (p = tokstr; dq && *p; p++)
+                if (*p == Bnull)
+                    dq--;
+            if (issq) {
+                for (p = tokstr, lsq = 0; *p; p++) {
+                    if (sq && *p == Snull)
+                        sq -= qa;
+                    if (*p == '\'') {
+                        sq -= qa;
+                        lsq += qa;
+                    }
+                }
+            }
+            else
+                lsq = 0;
 	    addlinknode(foo, (p = ztrdup(tokstr)));
+        }
 	else
 	    p = NULL;
 	if (!got && !zleparse) {
 	    DPUTS(!p, "no current word in substr");
 	    got = 1;
 	    cur = i;
-	    swb = wb - 1;
-	    swe = we - 1;
+	    swb = wb - 1 - dq - sq;
+	    swe = we - 1 - dq - sq;
+            sqq = lsq;
 	    soffs = cs - swb;
 	    chuck(p + soffs);
 	    ns = dupstring(p);
@@ -1352,8 +1420,12 @@
     for (p = ns, i = swb; *p; p++, i++) {
 	if (INULL(*p)) {
 	    if (i < scs) {
-		if (remq && *p == Bnull && p[1])
-		    swb -= 2;
+		if (*p == Bnull && p[1]) {
+                    if (remq)
+                        swb -= 2;
+                    if (odq)
+                        swb--;
+                }
 	    }
 	    if (p[1] || *p != Bnull) {
 		if (*p == Bnull) {
@@ -1378,9 +1450,9 @@
 	if (ql > rl)
 	    swb -= ql - rl;
     }
-    sav = s[(i = swb - 1)];
+    sav = s[(i = swb - 1 - sqq)];
     s[i] = '\0';
-    qp = rembslash(s);
+    qp = (issq ? dupstring(s) : rembslash(s));
     s[i] = sav;
     if (swe < swb)
 	swe = swb;
@@ -1391,11 +1463,14 @@
 	if (strlen(ns) > swe - swb + 1)
 	    ns[swe - swb + 1] = '\0';
     }
-    qs = rembslash(s + swe);
+    qs = (issq ? dupstring(s + swe) : rembslash(s + swe));
     sl = strlen(ns);
     if (soffs > sl)
 	soffs = sl;
-
+    if (issq) {
+        remsquote(qp);
+        remsquote(qs);
+    }
     {
 	int set = CP_QUOTE | CP_QUOTING, unset = 0;
 
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.36
diff -u -r1.36 zle_tricky.c
--- Src/Zle/zle_tricky.c	16 Apr 2002 07:53:13 -0000	1.36
+++ Src/Zle/zle_tricky.c	13 May 2002 09:27:02 -0000
@@ -985,7 +985,7 @@
 get_comp_string(void)
 {
     int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0;
-    int ona = noaliases;
+    int ona = noaliases, qsub;
     char *s = NULL, *linptr, *tmp, *p, *tt = NULL, rdop[20];
 
     freebrinfo(brbeg);
@@ -1051,6 +1051,8 @@
     * and whatnot. */
 
     do {
+        qsub = 0;
+
 	lincmd = ((incmdpos && !ins && !incond) || (oins == 2 && i == 2) ||
 		  (ins == 3 && i == 1));
 	linredir = (inredir && !ins);
@@ -1126,9 +1128,16 @@
 	if (!zleparse && !tt0) {
 	    /* This is done when the lexer reached the word the cursor is on. */
 	    tt = tokstr ? dupstring(tokstr) : NULL;
+
+            if (isset(RCQUOTES) && *tt == Snull) {
+                char *p, *e = tt + cs - wb;
+                for (p = tt; *p && p < e; p++)
+                    if (*p == '\'')
+                        qsub++;
+            }
 	    /* If we added a `x', remove it. */
 	    if (addedx && tt)
-		chuck(tt + cs - wb);
+		chuck(tt + cs - wb - qsub);
 	    tt0 = tok;
 	    /* Store the number of this word. */
 	    clwpos = i;
@@ -1176,8 +1185,8 @@
 	/* If this is the word the cursor is in and we added a `x', *
 	 * remove it.                                               */
 	if (clwpos == i++ && addedx)
-	    chuck(&clwords[i - 1][((cs - wb) >= sl) ?
-				 (sl - 1) : (cs - wb)]);
+	    chuck(&clwords[i - 1][((cs - wb - qsub) >= sl) ?
+				 (sl - 1) : (cs - wb - qsub)]);
     } while (tok != LEXERR && tok != ENDINPUT &&
 	     (tok != SEPER || (zleparse && !tt0)));
     /* Calculate the number of words stored in the clwords array. */

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: completion in quotes - " vs ' - no suffix added
  2002-05-13  9:30           ` Sven Wischnowsky
@ 2002-05-13 10:14             ` Borsenkow Andrej
  2002-05-13 17:33               ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Borsenkow Andrej @ 2002-05-13 10:14 UTC (permalink / raw)
  To: 'Sven Wischnowsky', zsh-workers

> 
> Bart Schaefer wrote:
> 
> > ...
> >
> > Sven, what you're missing is that although the result is correct
after
> > you execute the command, the completion is not correct while the
command
> > line is being built.  That is, if the completion system is going to
turn
> > the file name `a\ b' into the string `"a\\ b"' when it inserts it on
the
> > line, then `compset -q' should also UNDO the backslash-doubling
again
> > when the quote character is a double-quote, so that it's possible to
> > correctly complete the file path on the second and subsequent calls
to
> > the completion system.
> 
> (Sorry for the delay, I was away on Thursday and Friday.)
> 
> (Also sorry for being so bone-headed. Ahem.)
> 
> Whew, this was pretty complicated, we have to special-case this stuff.
> Because a quoting a single quote inserts more single quotes. This
> wasn't even handled correctly (in the case that there was one quoted
> single quote in the string) by get_comp_string().
> 
> The patch below should fix it. At least it does for the pretty
> complicated cases I tried.
> 

I do not see any difference with this patch. As before, listing
pathnames with spaces in single quotes correctly adds slash to
directories and in double quotes adds nothing.

-andrej


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-13 10:14             ` Borsenkow Andrej
@ 2002-05-13 17:33               ` Bart Schaefer
  2002-05-13 18:04                 ` Borsenkow Andrej
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2002-05-13 17:33 UTC (permalink / raw)
  To: zsh-workers

On May 13, 11:30am, Sven Wischnowsky wrote:
}
} (Also sorry for being so bone-headed. Ahem.)

S'ok.

} Because a quoting a single quote inserts more single quotes. This
} wasn't even handled correctly (in the case that there was one quoted
} single quote in the string) by get_comp_string().
} 
} The patch below should fix it. At least it does for the pretty
} complicated cases I tried.

On May 13,  2:14pm, Borsenkow Andrej wrote:
}
} I do not see any difference with this patch. As before, listing
} pathnames with spaces in single quotes correctly adds slash to
} directories and in double quotes adds nothing.

I see slashes getting added to directories in double quotes:

schaefer<505> ls        
a\ b  a\ d/  don't stop/  rmthat/
schaefer<506> ls "a<TAB><TAB>
schaefer<506> ls "a\\
Completing files
a\\ d/  a\\ b 

And then going on:

schaefer<506> ls "a\\ <TAB>
schaefer<506> ls "a\\ d/<TAB>
schaefer<506> ls "a\\ b"

One oddity is that typing the closing quote after `ls "a\\ d/' does not
auto-remove the slash, but I don't think that's strictly a bug.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-13 17:33               ` Bart Schaefer
@ 2002-05-13 18:04                 ` Borsenkow Andrej
  2002-05-14  7:44                   ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Borsenkow Andrej @ 2002-05-13 18:04 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

В Пнд, 13.05.2002, в 21:33, Bart Schaefer написал:
> 
> On May 13,  2:14pm, Borsenkow Andrej wrote:
> }
> } I do not see any difference with this patch. As before, listing
> } pathnames with spaces in single quotes correctly adds slash to
> } directories and in double quotes adds nothing.
> 
> I see slashes getting added to directories in double quotes:
> 
> schaefer<505> ls        
> a\ b  a\ d/  don't stop/  rmthat/
> schaefer<506> ls "a<TAB><TAB>
> schaefer<506> ls "a\\
> Completing files
> a\\ d/  a\\ b 
> 
> And then going on:
> 
> schaefer<506> ls "a\\ <TAB>
> schaefer<506> ls "a\\ d/<TAB>
> schaefer<506> ls "a\\ b"
> 

Wrong example. My concern is

zsh -c "ls TAB"

It is _here_ it should escape spaces:

itsrm2% ls "
a b/       c d/       uudecode/

O.K. (just lists filenames verbatim) 

but
itsrm2% zsh -c "ls
a\\ b      c\\ d      uudecode/

wrong (upon dequoting of matches). Second TAB:

itsrm2% zsh -c "ls a\\ b
a\\ b      c\\ d      uudecode/

so correctly escaped filename is inserted but is not unquoted when
testing for file type.

> One oddity is that typing the closing quote after `ls "a\\ d/' does not
> auto-remove the slash, but I don't think that's strictly a bug.
>

May be it should; but then it becomes increasingly more complicated with
nested quotes. Besides, you may want to continue quoted word ...

-andrej


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-13 18:04                 ` Borsenkow Andrej
@ 2002-05-14  7:44                   ` Sven Wischnowsky
  2002-05-14 14:23                     ` Bart Schaefer
  2002-05-21  8:06                     ` PATCH: " Sven Wischnowsky
  0 siblings, 2 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-14  7:44 UTC (permalink / raw)
  To: zsh-workers


Borsenkow Andrej wrote:

> ...
> 
> so correctly escaped filename is inserted but is not unquoted when
> testing for file type.

That's exactly the point -- the code in compresult.c responsible for
this is *very* old and, ahem, hasn't been updated for this. The patch
I sent is only for the quoting issues Bart described in the mail I
replied to, not for the file-testing code -- it was already hard
enough without that ;-}

> > One oddity is that typing the closing quote after `ls "a\\ d/' does not
> > auto-remove the slash, but I don't think that's strictly a bug.
> >
> 
> May be it should; but then it becomes increasingly more complicated with
> nested quotes. Besides, you may want to continue quoted word ...

I think we decided against it exactly for this reason. I'll have more
to say about this when I start talking about what we can do to improve
suffix handling.


So the next steps are to get the file-type testing right. I'd like to
do that more thoroughly to finally be able to implement this other
thing we've been talking about, where a space as a file-type character
(with LIST_TYPES) isn't counted to allow tighter packing of rows in
listings.

That's also the reason why I haven't tried to change the difference in
quoting in listings Andrej pointed out. To repeat: we meant to make it
always be quoted. But with display strings and what not the shell code
is able to defeat this. Personally, I prefer it this way, so we might
want to make this be controlled by a style. But then the shell code
would be responsible to handle different quoting behaviour in some
cases, namely: whenever it uses display strings. If there are no
display strings, the C-code could use them internally for the unquoted
form.

Do others have any opinions on this?


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-14  7:44                   ` Sven Wischnowsky
@ 2002-05-14 14:23                     ` Bart Schaefer
  2002-05-14 14:31                       ` Bart Schaefer
  2002-05-21  8:06                     ` PATCH: " Sven Wischnowsky
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2002-05-14 14:23 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On May 14,  9:44am, Sven Wischnowsky wrote:
} 
} Borsenkow Andrej wrote:
} 
} > so correctly escaped filename is inserted but is not unquoted when
} > testing for file type.
} 
} That's exactly the point -- the code in compresult.c responsible for
} this is *very* old and, ahem, hasn't been updated for this. The patch
} I sent is only for the quoting issues Bart described

Well, something is not quite right.  Look what I get with the latest CVS:

schaefer<502> ls -l              
total 3
-rw-rw-r--   1 schaefer schaefer        0 May 13 10:29 a\ b
drwxrwxr-x   2 schaefer schaefer     1024 May 13 10:29 a\ d/
drwxrwxr-x   2 schaefer schaefer     1024 Apr 15 08:30 don't stop/
drwxrwxr-x   2 schaefer schaefer     1024 Feb  5 09:38 rmthat/
schaefer<503> zsh -c "ls a<TAB>
schaefer<503> zsh -c "ls a\\\\\\ 

There are several too many backslashes there, I'd say.  It behaves the
same way if I delete _all_ my zstyles, so ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-14 14:23                     ` Bart Schaefer
@ 2002-05-14 14:31                       ` Bart Schaefer
  2002-05-14 15:23                         ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2002-05-14 14:31 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On May 14,  2:23pm, Bart Schaefer wrote:
}
} -rw-rw-r--   1 schaefer schaefer        0 May 13 10:29 a\ b
} drwxrwxr-x   2 schaefer schaefer     1024 May 13 10:29 a\ d/
} schaefer<503> zsh -c "ls a<TAB>
} schaefer<503> zsh -c "ls a\\\\\\ 

It's worse than that -- if I type TAB again at this point, the shell
crashes.

#0  0x400ab824 in chunk_free (ar_ptr=0x80fc458b, p=0x81b2e08) at malloc.c:2899
#1  0x400ab7c1 in __libc_free (mem=0x81b2e10) at malloc.c:2872
#2  0x808496a in zsfree (p=0x81b2e10 "patterns")
    at ../../zsh-4.0/Src/mem.c:1399
#3  0x809012f in strsetfn (pm=0x81b1a98, x=0x819a460 "")
    at ../../zsh-4.0/Src/params.c:2354
#4  0x808d874 in setstrvalue (v=0xbfffc844, val=0x819a460 "")
    at ../../zsh-4.0/Src/params.c:1608
#5  0x808ebb1 in assignsparam (s=0x81a2495 "", val=0x819a460 "", augment=0)
    at ../../zsh-4.0/Src/params.c:1994
#6  0x805e057 in addvars (state=0xbfffc9cc, pc=0x81a2350, export=0)
    at ../../zsh-4.0/Src/exec.c:1569
#7  0x805bd69 in execsimple (state=0xbfffc9cc) at ../../zsh-4.0/Src/exec.c:753
#8  0x805becb in execlist (state=0xbfffc9cc, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:806
#9  0x807ec73 in execif (state=0xbfffc9cc, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:519
#10 0x805bdc6 in execsimple (state=0xbfffc9cc) at ../../zsh-4.0/Src/exec.c:760
#11 0x805becb in execlist (state=0xbfffc9cc, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:806
#12 0x805bccf in execode (p=0x81a22a0, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#13 0x8063026 in runshfunc (prog=0x81a22a0, wrap=0x0, 
    name=0x40135758 "_normal") at ../../zsh-4.0/Src/exec.c:3492
#14 0x80cfc44 in comp_wrapper (prog=0x81a22a0, w=0x0, 
    name=0x40135758 "_normal") at ../../../zsh-4.0/Src/Zle/complete.c:1274
#15 0x8062fba in runshfunc (prog=0x81a22a0, wrap=0x8121200, 
    name=0x40135758 "_normal") at ../../zsh-4.0/Src/exec.c:3480
#16 0x8062dce in doshfunc (name=0x815c680 "_normal", prog=0x81a22a0, 
    doshargs=0x40135728, flags=8192, noreturnval=0)
    at ../../zsh-4.0/Src/exec.c:3407
#17 0x80627dc in execshfunc (shf=0x815c1a0, args=0x40135728)
    at ../../zsh-4.0/Src/exec.c:3217
#18 0x80603d8 in execcmd (state=0xbfffd04c, input=0, output=0, how=18, last1=2)
    at ../../zsh-4.0/Src/exec.c:2295
#19 0x805d0ef in execpline2 (state=0xbfffd04c, pcode=963, how=18, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#20 0x805c667 in execpline (state=0xbfffd04c, slcode=3074, how=18, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#21 0x805bfb5 in execlist (state=0xbfffd04c, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#22 0x807ec73 in execif (state=0xbfffd04c, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:519
#23 0x80601ed in execcmd (state=0xbfffd04c, input=0, output=0, how=18, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#24 0x805d0ef in execpline2 (state=0xbfffd04c, pcode=835, how=18, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#25 0x805c667 in execpline (state=0xbfffd04c, slcode=57346, how=18, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#26 0x805bfb5 in execlist (state=0xbfffd04c, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#27 0x805bccf in execode (p=0x817c6c0, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#28 0x8063026 in runshfunc (prog=0x817c6c0, wrap=0x0, name=0x40135500 "_sh")
    at ../../zsh-4.0/Src/exec.c:3492
#29 0x80cfc44 in comp_wrapper (prog=0x817c6c0, w=0x0, name=0x40135500 "_sh")
    at ../../../zsh-4.0/Src/Zle/complete.c:1274
#30 0x8062fba in runshfunc (prog=0x817c6c0, wrap=0x8121200, 
    name=0x40135500 "_sh") at ../../zsh-4.0/Src/exec.c:3480
#31 0x8062dce in doshfunc (name=0x816afb8 "_sh", prog=0x817c6c0, 
    doshargs=0x401354d0, flags=8192, noreturnval=0)
    at ../../zsh-4.0/Src/exec.c:3407
#32 0x80627dc in execshfunc (shf=0x816b630, args=0x401354d0)
    at ../../zsh-4.0/Src/exec.c:3217
#33 0x80603d8 in execcmd (state=0xbfffd470, input=0, output=0, how=18, last1=2)
    at ../../zsh-4.0/Src/exec.c:2295
#34 0x805d0ef in execpline2 (state=0xbfffd470, pcode=131, how=18, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#35 0x805c667 in execpline (state=0xbfffd470, slcode=3074, how=18, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#36 0x805bfb5 in execlist (state=0xbfffd470, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#37 0x805bccf in execode (p=0x40135498, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#38 0x8056a4d in bin_eval (nam=0x40135458 "eval", argv=0xbfffd4b8, 
    ops=0xbfffd51c "", func=14) at ../../zsh-4.0/Src/builtin.c:3824
#39 0x804b339 in execbuiltin (args=0x40135438, bn=0x811d988)
    at ../../zsh-4.0/Src/builtin.c:380
#40 0x806045e in execcmd (state=0xbfffda2c, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2306
#41 0x805d0ef in execpline2 (state=0xbfffda2c, pcode=3523, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#42 0x805c667 in execpline (state=0xbfffda2c, slcode=4130, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#43 0x805c001 in execlist (state=0xbfffda2c, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:833
#44 0x807ec73 in execif (state=0xbfffda2c, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:519
#45 0x80601ed in execcmd (state=0xbfffda2c, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#46 0x805d0ef in execpline2 (state=0xbfffda2c, pcode=3395, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#47 0x805c667 in execpline (state=0xbfffda2c, slcode=43010, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#48 0x805bfb5 in execlist (state=0xbfffda2c, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#49 0x805bccf in execode (p=0x81a2d38, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#50 0x8063026 in runshfunc (prog=0x81a2d38, wrap=0x0, 
    name=0x40135008 "_dispatch") at ../../zsh-4.0/Src/exec.c:3492
#51 0x80cfc44 in comp_wrapper (prog=0x81a2d38, w=0x0, 
    name=0x40135008 "_dispatch") at ../../../zsh-4.0/Src/Zle/complete.c:1274
#52 0x8062fba in runshfunc (prog=0x81a2d38, wrap=0x8121200, 
    name=0x40135008 "_dispatch") at ../../zsh-4.0/Src/exec.c:3480
#53 0x8062dce in doshfunc (name=0x815bdf0 "_dispatch", prog=0x81a2d38, 
    doshargs=0x40134ee8, flags=8192, noreturnval=0)
    at ../../zsh-4.0/Src/exec.c:3407
#54 0x80627dc in execshfunc (shf=0x815bd98, args=0x40134ee8)
    at ../../zsh-4.0/Src/exec.c:3217
#55 0x80603d8 in execcmd (state=0xbfffde60, input=0, output=0, how=18, last1=2)
    at ../../zsh-4.0/Src/exec.c:2295
#56 0x805d0ef in execpline2 (state=0xbfffde60, pcode=1667, how=18, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#57 0x805c667 in execpline (state=0xbfffde60, slcode=8194, how=18, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#58 0x805bfb5 in execlist (state=0xbfffde60, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#59 0x805bccf in execode (p=0x81a22a0, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#60 0x8063026 in runshfunc (prog=0x81a22a0, wrap=0x0, 
    name=0x40134de0 "_normal") at ../../zsh-4.0/Src/exec.c:3492
#61 0x80cfc44 in comp_wrapper (prog=0x81a22a0, w=0x0, 
    name=0x40134de0 "_normal") at ../../../zsh-4.0/Src/Zle/complete.c:1274
#62 0x8062fba in runshfunc (prog=0x81a22a0, wrap=0x8121200, 
    name=0x40134de0 "_normal") at ../../zsh-4.0/Src/exec.c:3480
#63 0x8062dce in doshfunc (name=0x815c680 "_normal", prog=0x81a22a0, 
    doshargs=0x40134da0, flags=8192, noreturnval=0)
    at ../../zsh-4.0/Src/exec.c:3407
#64 0x80627dc in execshfunc (shf=0x815c1a0, args=0x40134da0)
    at ../../zsh-4.0/Src/exec.c:3217
#65 0x80603d8 in execcmd (state=0xbfffe4d8, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2295
#66 0x805d0ef in execpline2 (state=0xbfffe4d8, pcode=7555, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#67 0x805c667 in execpline (state=0xbfffe4d8, slcode=4130, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#68 0x805c001 in execlist (state=0xbfffe4d8, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:833
#69 0x807ec73 in execif (state=0xbfffe4d8, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:519
#70 0x80601ed in execcmd (state=0xbfffe4d8, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#71 0x805d0ef in execpline2 (state=0xbfffe4d8, pcode=7427, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#72 0x805c667 in execpline (state=0xbfffe4d8, slcode=114690, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#73 0x805bfb5 in execlist (state=0xbfffe4d8, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#74 0x805bccf in execode (p=0x81a12a0, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#75 0x8063026 in runshfunc (prog=0x81a12a0, wrap=0x0, 
    name=0x40134978 "_complete") at ../../zsh-4.0/Src/exec.c:3492
#76 0x80cfc44 in comp_wrapper (prog=0x81a12a0, w=0x0, 
    name=0x40134978 "_complete") at ../../../zsh-4.0/Src/Zle/complete.c:1274
#77 0x8062fba in runshfunc (prog=0x81a12a0, wrap=0x8121200, 
    name=0x40134978 "_complete") at ../../zsh-4.0/Src/exec.c:3480
#78 0x8062dce in doshfunc (name=0x815ae28 "_complete", prog=0x81a12a0, 
    doshargs=0x40134928, flags=8192, noreturnval=0)
    at ../../zsh-4.0/Src/exec.c:3407
#79 0x80627dc in execshfunc (shf=0x815b2c8, args=0x40134928)
    at ../../zsh-4.0/Src/exec.c:3217
#80 0x80603d8 in execcmd (state=0xbffff088, input=0, output=0, how=18, last1=2)
    at ../../zsh-4.0/Src/exec.c:2295
#81 0x805d0ef in execpline2 (state=0xbffff088, pcode=9987, how=18, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#82 0x805c667 in execpline (state=0xbffff088, slcode=3074, how=18, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#83 0x805bfb5 in execlist (state=0xbffff088, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#84 0x807eb91 in execif (state=0xbffff088, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:504
#85 0x80601ed in execcmd (state=0xbffff088, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#86 0x805d0ef in execpline2 (state=0xbffff088, pcode=9667, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#87 0x805c667 in execpline (state=0xbffff088, slcode=48130, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#88 0x805bfb5 in execlist (state=0xbffff088, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#89 0x807dd10 in execfor (state=0xbffff088, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:159
#90 0x80601ed in execcmd (state=0xbffff088, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#91 0x805d0ef in execpline2 (state=0xbffff088, pcode=9155, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#92 0x805c667 in execpline (state=0xbffff088, slcode=90114, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#93 0x805bfb5 in execlist (state=0xbffff088, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#94 0x807dd10 in execfor (state=0xbffff088, do_exec=0)
    at ../../zsh-4.0/Src/loop.c:159
#95 0x80601ed in execcmd (state=0xbffff088, input=0, output=0, how=2, last1=2)
    at ../../zsh-4.0/Src/exec.c:2253
#96 0x805d0ef in execpline2 (state=0xbffff088, pcode=7875, how=2, input=0, 
    output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1201
#97 0x805c667 in execpline (state=0xbffff088, slcode=205826, how=2, last1=0)
    at ../../zsh-4.0/Src/exec.c:991
#98 0x805bfb5 in execlist (state=0xbffff088, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:826
#99 0x805bccf in execode (p=0x819ae48, dont_change_job=1, exiting=0)
    at ../../zsh-4.0/Src/exec.c:729
#100 0x8063026 in runshfunc (prog=0x819ae48, wrap=0x0, 
    name=0x40133030 "_main_complete") at ../../zsh-4.0/Src/exec.c:3492
#101 0x80cfc44 in comp_wrapper (prog=0x819ae48, w=0x0, 
    name=0x40133030 "_main_complete")
    at ../../../zsh-4.0/Src/Zle/complete.c:1274
#102 0x8062fba in runshfunc (prog=0x819ae48, wrap=0x8121200, 
    name=0x40133030 "_main_complete") at ../../zsh-4.0/Src/exec.c:3480
#103 0x8062dce in doshfunc (name=0x818a750 "_main_complete", prog=0x819ae48, 
    doshargs=0x0, flags=0, noreturnval=0) at ../../zsh-4.0/Src/exec.c:3407
#104 0x80d1a75 in callcompfunc (s=0x4011b420 "ls a\\\\\\ ", 
    fn=0x818a750 "_main_complete") at ../../../zsh-4.0/Src/Zle/compcore.c:781
#105 0x80d217a in makecomplist (s=0x4011b420 "ls a\\\\\\ ", incmd=0, lst=0)
    at ../../../zsh-4.0/Src/Zle/compcore.c:932
#106 0x80d078d in do_completion (dummy=0x812465c, dat=0xbffff37c)
    at ../../../zsh-4.0/Src/Zle/compcore.c:342
#107 0x80886f2 in runhookdef (h=0x812465c, d=0xbffff37c)
    at ../../zsh-4.0/Src/module.c:1858
#108 0x810c9e6 in docompletion (s=0x81b5d68 "ls a\\\\\\ ", lst=0, incmd=0)
    at ../../../zsh-4.0/Src/Zle/zle_tricky.c:1822
#109 0x8109ebb in docomplete (lst=0)
    at ../../../zsh-4.0/Src/Zle/zle_tricky.c:810
#110 0x8108a0f in completeword (args=0x81245d8)
    at ../../../zsh-4.0/Src/Zle/zle_tricky.c:205
#111 0x8108923 in completecall (args=0x81245d8)
    at ../../../zsh-4.0/Src/Zle/zle_tricky.c:181
#112 0x80ff2c1 in execzlefunc (func=0x812233c, args=0x81245d8)
    at ../../../zsh-4.0/Src/Zle/zle_main.c:662


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-14 14:31                       ` Bart Schaefer
@ 2002-05-14 15:23                         ` Sven Wischnowsky
  2002-05-14 15:35                           ` Borsenkow Andrej
  2002-05-15  7:37                           ` Sven Wischnowsky
  0 siblings, 2 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-14 15:23 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On May 14,  2:23pm, Bart Schaefer wrote:
> }
> } -rw-rw-r--   1 schaefer schaefer        0 May 13 10:29 a\ b
> } drwxrwxr-x   2 schaefer schaefer     1024 May 13 10:29 a\ d/
> } schaefer<503> zsh -c "ls a<TAB>
> } schaefer<503> zsh -c "ls a\\\\\\ 
> 
> It's worse than that -- if I type TAB again at this point, the shell
> crashes.

The number of backslashes is ok.

But the segv not, obviously. A quick check shows that there's another
bug in the zle_tricky code, similar to the one I fixed in that other
patch -- only this time it's with double quotes, whereas the other one
was with single quotes. One of the effects of these bugs is that the
`x' inserted into the line stays there so the completion code gets to
see it. With this bug I guess this means the code calls chuck() with a
pointer pointing to the null byte at the end of the string, messing up
the following memory.

But this might take more time, so it'll have to wait until I get home
but I hope to send a patch tomorrow. Sorry.


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: completion in quotes - " vs ' - no suffix added
  2002-05-14 15:23                         ` Sven Wischnowsky
@ 2002-05-14 15:35                           ` Borsenkow Andrej
  2002-05-15  7:37                           ` Sven Wischnowsky
  1 sibling, 0 replies; 17+ messages in thread
From: Borsenkow Andrej @ 2002-05-14 15:35 UTC (permalink / raw)
  To: zsh-workers


> 
> > On May 14,  2:23pm, Bart Schaefer wrote:
> > }
> > } -rw-rw-r--   1 schaefer schaefer        0 May 13 10:29 a\ b
> > } drwxrwxr-x   2 schaefer schaefer     1024 May 13 10:29 a\ d/
> > } schaefer<503> zsh -c "ls a<TAB>
> > } schaefer<503> zsh -c "ls a\\\\\\
> >
> > It's worse than that -- if I type TAB again at this point, the shell
> > crashes.
> 
> The number of backslashes is ok.
> 

It is weird situation where there may be 5 or 6 backslashes without
changing semantic because in double quotes

\\non-meta

is exactly the same as

\non-meta

-andrej



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: completion in quotes - " vs ' - no suffix added
  2002-05-14 15:23                         ` Sven Wischnowsky
  2002-05-14 15:35                           ` Borsenkow Andrej
@ 2002-05-15  7:37                           ` Sven Wischnowsky
  1 sibling, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-15  7:37 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> 
> Bart Schaefer wrote:
> 
> > On May 14,  2:23pm, Bart Schaefer wrote:
> > }
> > } -rw-rw-r--   1 schaefer schaefer        0 May 13 10:29 a\ b
> > } drwxrwxr-x   2 schaefer schaefer     1024 May 13 10:29 a\ d/
> > } schaefer<503> zsh -c "ls a<TAB>
> > } schaefer<503> zsh -c "ls a\\\\\\ 
> > 
> > It's worse than that -- if I type TAB again at this point, the shell
> > crashes.
> 
> The number of backslashes is ok.
> 
> But the segv not, obviously. A quick check shows that there's another
> bug in the zle_tricky code, [...]

I was wrong there, it was entirely in set_comp_sep(), the function
that splits strings-as-command-lines. We have to treat backslashed
backslashes correctly (there, not every backslash is turned int a
Bnull, for obvious reasons, sorry, should have thought of that).


Bye
  Sven

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.57
diff -u -r1.57 compcore.c
--- Src/Zle/compcore.c	13 May 2002 09:32:00 -0000	1.57
+++ Src/Zle/compcore.c	15 May 2002 07:37:37 -0000
@@ -1268,7 +1268,7 @@
     LinkList foo = newlinklist();
     LinkNode n;
     int owe = we, owb = wb, ocs = cs, swb, swe, scs, soffs, ne = noerrs;
-    int tl, got = 0, i = 0, j, cur = -1, oll = ll, sl;
+    int tl, got = 0, i = 0, j, cur = -1, oll = ll, sl, css = 0;
     int remq = 0, dq = 0, odq, sq = 0, osq, issq = 0, sqq = 0, lsq = 0, qa = 0;
     int ois = instring, oib = inbackt, noffs = lp, ona = noaliases;
     char *tmp, *p, *ns, *ol = (char *) line, sav, *qp, *qs, *ts, qc = '\0';
@@ -1312,6 +1312,10 @@
             if (*p == '\\' && p[1] == '\\') {
                 dq++;
                 chuck(p);
+                if (j > cs) {
+                    cs++;
+                    css++;
+                }
                 if (!*p)
                     break;
             }
@@ -1343,9 +1347,13 @@
 	if (tok == ENDINPUT || tok == LEXERR)
 	    break;
 	if (tokstr && *tokstr) {
-            for (p = tokstr; dq && *p; p++)
-                if (*p == Bnull)
+            for (p = tokstr; dq && *p; p++) {
+                if (*p == Bnull) {
                     dq--;
+                    if (p[1] == '\\')
+                        dq--;
+                }
+            }
             if (issq) {
                 for (p = tokstr, lsq = 0; *p; p++) {
                     if (sq && *p == Snull)
@@ -1369,7 +1377,7 @@
 	    swb = wb - 1 - dq - sq;
 	    swe = we - 1 - dq - sq;
             sqq = lsq;
-	    soffs = cs - swb;
+	    soffs = cs - swb - css;
 	    chuck(p + soffs);
 	    ns = dupstring(p);
 	}
@@ -1423,8 +1431,11 @@
 		if (*p == Bnull && p[1]) {
                     if (remq)
                         swb -= 2;
-                    if (odq)
+                    if (odq) {
                         swb--;
+                        if (p[1] == '\\')
+                            swb--;
+                    }
                 }
 	    }
 	    if (p[1] || *p != Bnull) {

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* PATCH: Re: completion in quotes - " vs ' - no suffix added
  2002-05-14  7:44                   ` Sven Wischnowsky
  2002-05-14 14:23                     ` Bart Schaefer
@ 2002-05-21  8:06                     ` Sven Wischnowsky
  1 sibling, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2002-05-21  8:06 UTC (permalink / raw)
  To: zsh-workers


Sven Wischnowsky wrote:

> ...
> 
> So the next steps are to get the file-type testing right. I'd like to
> do that more thoroughly to finally be able to implement this other
> thing we've been talking about, where a space as a file-type character
> (with LIST_TYPES) isn't counted to allow tighter packing of rows in
> listings.

Here is the patch for this. Also, Andrej's `zsh -c "ls dir<TAB>'
should now work ;-)


Bye
  Sven

Index: Src/Zle/comp.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/comp.h,v
retrieving revision 1.13
diff -u -r1.13 comp.h
--- Src/Zle/comp.h	1 Mar 2002 10:42:02 -0000	1.13
+++ Src/Zle/comp.h	21 May 2002 08:05:00 -0000
@@ -92,6 +92,7 @@
 
 struct cmatch {
     char *str;			/* the match itself */
+    char *orig;                 /* the match string unquoted */
     char *ipre;			/* ignored prefix, has to be re-inserted */
     char *ripre;		/* ignored prefix, unquoted */
     char *isuf;			/* ignored suffix */
@@ -111,6 +112,8 @@
     int qisl;			/* length of quote-suffix */
     int rnum;			/* group relative number */
     int gnum;			/* global number */
+    mode_t mode;                /* mode field of a stat */
+    char modec;                 /* LIST_TYPE-character for mode or nul */
 };
 
 #define CMF_FILE     (1<< 0)	/* this is a file */
@@ -286,8 +289,7 @@
     int showall;		/* != 0 if hidden matches should be shown */
 };
 
-typedef void (*CLPrintFunc)(Cmgroup, Cmatch *, int, int, int, int,
-			    char *, struct stat *);
+typedef void (*CLPrintFunc)(Cmgroup, Cmatch *, int, int, int, int);
 
 /* Flags for fromcomp. */
 
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.59
diff -u -r1.59 compcore.c
--- Src/Zle/compcore.c	21 May 2002 07:47:35 -0000	1.59
+++ Src/Zle/compcore.c	21 May 2002 08:05:00 -0000
@@ -2104,7 +2104,7 @@
 		for (bp = obsl; bp; bp = bp->next)
 		    bp->curpos += bsadd;
 
-		if ((cm = add_match_data(0, ms, lc, dat->ipre, NULL,
+		if ((cm = add_match_data(0, ms, s, lc, dat->ipre, NULL,
 					 dat->isuf, dat->pre, dat->prpre,
 					 dat->ppre, pline,
 					 dat->psuf, sline,
@@ -2184,7 +2184,7 @@
 
 /**/
 mod_export Cmatch
-add_match_data(int alt, char *str, Cline line,
+add_match_data(int alt, char *str, char *orig, Cline line,
 	       char *ipre, char *ripre, char *isuf,
 	       char *pre, char *prpre,
 	       char *ppre, Cline pline,
@@ -2412,6 +2412,7 @@
     /* Allocate and fill the match structure. */
     cm = (Cmatch) zhalloc(sizeof(struct cmatch));
     cm->str = str;
+    cm->orig = dupstring(orig);
     cm->ppre = (ppre && *ppre ? ppre : NULL);
     cm->psuf = (psuf && *psuf ? psuf : NULL);
     cm->prpre = ((flags & CMF_FILE) && prpre && *prpre ? prpre : NULL);
@@ -2430,7 +2431,22 @@
 		 (complist ?
 		  ((strstr(complist, "packed") ? CMF_PACKED : 0) |
 		   (strstr(complist, "rows")   ? CMF_ROWS   : 0)) : 0));
-
+    cm->mode = 0;
+    cm->modec = '\0';
+    if ((flags & CMF_FILE) && orig[0] && orig[strlen(orig) - 1] != '/') {
+        struct stat buf;
+        char *pb;
+
+        pb = (char *) zhalloc((cm->prpre ? strlen(cm->prpre) : 0) +
+                              3 + strlen(orig));
+        sprintf(pb, "%s%s", (cm->prpre ? cm->prpre : "./"), orig);
+
+        if (!ztat(pb, &buf, 1)) {
+            cm->mode = buf.st_mode;
+            if ((cm->modec = file_type(buf.st_mode)) == ' ')
+                cm->modec = '\0';
+        }
+    }
     if ((*compqstack == '\\' && compqstack[1]) ||
 	(autoq && *compqstack && compqstack[1] == '\\'))
 	cm->flags |= CMF_NOSPACE;
@@ -2803,6 +2819,7 @@
     r = (Cmatch) zcalloc(sizeof(struct cmatch));
 
     r->str = ztrdup(m->str);
+    r->orig = ztrdup(m->orig);
     r->ipre = ztrdup(m->ipre);
     r->ripre = ztrdup(m->ripre);
     r->isuf = ztrdup(m->isuf);
@@ -2836,6 +2853,8 @@
     r->qipl = m->qipl;
     r->qisl = m->qisl;
     r->disp = ztrdup(m->disp);
+    r->mode = m->mode;
+    r->modec = m->modec;
 
     return r;
 }
@@ -2994,6 +3013,7 @@
     if (!m) return;
 
     zsfree(m->str);
+    zsfree(m->orig);
     zsfree(m->ipre);
     zsfree(m->ripre);
     zsfree(m->isuf);
Index: Src/Zle/compctl.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compctl.c,v
retrieving revision 1.12
diff -u -r1.12 compctl.c
--- Src/Zle/compctl.c	22 Jan 2002 10:22:48 -0000	1.12
+++ Src/Zle/compctl.c	21 May 2002 08:05:00 -0000
@@ -2025,7 +2025,7 @@
     }
     if (!ms)
 	return;
-    add_match_data(isalt, ms, lc, ipre, ripre, isuf, 
+    add_match_data(isalt, ms, s, lc, ipre, ripre, isuf, 
 		   (incompfunc ? dupstring(curcc->prefix) : curcc->prefix),
 		   prpre, 
 		   (isfile ? lppre : NULL), NULL,
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.45
diff -u -r1.45 complist.c
--- Src/Zle/complist.c	22 Jan 2002 10:22:48 -0000	1.45
+++ Src/Zle/complist.c	21 May 2002 08:05:00 -0000
@@ -1199,7 +1199,7 @@
 			    mfirstl = ml;
 			if (dolist(ml))
 			    printed++;
-			if (clprintm(g, p, 0, ml, 1, 0, NULL, NULL))
+			if (clprintm(g, p, 0, ml, 1, 0))
 			    goto end;
 			ml += mlprinted;
 			if (dolistcl(ml) && (cl -= mlprinted) <= 1) {
@@ -1250,26 +1250,12 @@
 		while (n && i--) {
 		    wid = (g->widths ? g->widths[mc] : g->width);
 		    if (!(m = *q)) {
-			if (clprintm(g, NULL, mc, ml, (!i), wid, NULL, NULL))
+			if (clprintm(g, NULL, mc, ml, (!i), wid))
 			    goto end;
 			break;
 		    }
-		    if (!m->disp && (m->flags & CMF_FILE) &&
-			m->str[0] && m->str[strlen(m->str) - 1] != '/') {
-			struct stat buf;
-			char *pb;
-
-			pb = (char *) zhalloc((m->prpre ? strlen(m->prpre) : 0) +
-					     3 + strlen(m->str));
-			sprintf(pb, "%s%s", (m->prpre ? m->prpre : "./"),
-				m->str);
-
-			if (ztat(pb, &buf, 1) ?
-			    clprintm(g, q, mc, ml, (!i), wid, NULL, NULL) :
-			    clprintm(g, q, mc, ml, (!i), wid, pb, &buf))
-			    goto end;
-		    } else if (clprintm(g, q, mc, ml, (!i), wid, NULL, NULL))
-			goto end;
+                    if (clprintm(g, q, mc, ml, (!i), wid))
+                        goto end;
 
 		    if (dolist(ml))
 			printed++;
@@ -1290,8 +1276,7 @@
 		}
 		while (i-- > 0) {
 		    if (clprintm(g, NULL, mc, ml, (!i),
-				 (g->widths ? g->widths[mc] : g->width),
-				 NULL, NULL))
+				 (g->widths ? g->widths[mc] : g->width)))
 			goto end;
 		    mc++;
 		}
@@ -1366,8 +1351,7 @@
 
 /**/
 static int
-clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
-	 char *path, struct stat *buf)
+clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width)
 {
     Cmatch m;
     int len, subcols = 0, stop = 0, ret = 0;
@@ -1467,8 +1451,8 @@
 	    zcputs(&mcolors, g->name, COL_HI);
 	else if (mselect >= 0 && (m->flags & (CMF_MULT | CMF_FMULT)))
 	    zcputs(&mcolors, g->name, COL_DU);
-	else if (buf)
-	    subcols = putfilecol(&mcolors, g->name, m->str, buf->st_mode);
+	else if (m->mode)
+	    subcols = putfilecol(&mcolors, g->name, m->str, m->mode);
 	else
 	    subcols = putmatchcol(&mcolors, g->name, (m->disp ? m->disp : m->str));
 
@@ -1483,12 +1467,12 @@
 	len = niceztrlen(m->disp ? m->disp : m->str);
 	mlprinted = len / columns;
 
-	if ((g->flags & CGF_FILES) && buf) {
+	if ((g->flags & CGF_FILES) && m->modec) {
 	    if (m->gnum != mselect) {
 		zcoff();
 		zcputs(&mcolors, g->name, COL_TC);
 	    }
-	    putc(file_type(buf->st_mode), shout);
+	    putc(m->modec, shout);
 	    len++;
         }
 	if ((len = width - len - 2) > 0) {
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.43
diff -u -r1.43 compresult.c
--- Src/Zle/compresult.c	22 Jan 2002 10:22:48 -0000	1.43
+++ Src/Zle/compresult.c	21 May 2002 08:05:00 -0000
@@ -30,6 +30,10 @@
 #include "complete.mdh"
 #include "compresult.pro"
 
+/* The number of columns to leave empty between rows of matches. */
+
+#define CM_SPACE  2
+
 /* This counts how often the list of completions was invalidated.
  * Can be used to detect if we have a new list.  */
 
@@ -929,7 +933,7 @@
     int l, sr = 0, scs;
     int havesuff = 0;
     int partest = (m->ripre || ((m->flags & CMF_ISPAR) && parpre));
-    char *str = m->str, *ppre = m->ppre, *psuf = m->psuf, *prpre = m->prpre;
+    char *str = m->orig, *ppre = m->ppre, *psuf = m->psuf, *prpre = m->prpre;
 
     if (!prpre) prpre = "";
     if (!ppre) ppre = "";
@@ -1380,7 +1384,7 @@
     Cmgroup g;
     Cmatch *p, m;
     Cexpl *e;
-    int hidden = 0, nlist = 0, nlines = 0, add;
+    int hidden = 0, nlist = 0, nlines = 0;
     int max = 0, i;
     VARARR(int, mlens, nmatches + 1);
 
@@ -1474,7 +1478,7 @@
                         if (!(m->flags & CMF_ROWS))
                             g->flags &= ~CGF_ROWS;
                     } else {
-                        l = niceztrlen(m->str);
+                        l = niceztrlen(m->str) + !!m->modec;
                         ndisp++;
                         if (l > glong)
                             glong = l;
@@ -1503,19 +1507,16 @@
 		e++;
 	    }
 	}
-        if (isset(LISTTYPES) && hasf) {
+        if (isset(LISTTYPES) && hasf)
             g->flags |= CGF_FILES;
-            add = 3;
-        } else
-            add = 2;
-	g->totl = totl + (ndisp * add);
+	g->totl = totl + (ndisp * CM_SPACE);
 	g->dcount = ndisp;
-	g->width = glong + add;
-	g->shortest = gshort + add;
+	g->width = glong + CM_SPACE;
+	g->shortest = gshort + CM_SPACE;
 	if ((g->cols = columns / g->width) > g->dcount)
 	    g->cols = g->dcount;
 	if (g->cols) {
-	    i = g->cols * g->width - add;
+	    i = g->cols * g->width - CM_SPACE;
 	    if (i > max)
 		max = i;
 	}
@@ -1525,7 +1526,6 @@
 	int *ws, tlines, tcols, width, glines;
 
 	for (g = amatches; g; g = g->next) {
-            add = 2 + !!(g->flags & CGF_FILES);
 	    glines = 0;
 
 	    zfree(g->widths, 0);
@@ -1536,7 +1536,8 @@
 		    if (g->cols) {
 			glines += (arrlen(pp) + g->cols - 1) / g->cols;
 			if (g->cols > 1)
-			    g->width += ((max - (g->width * g->cols - add)) /
+			    g->width += ((max - (g->width * g->cols -
+                                                 CM_SPACE)) /
                                          g->cols);
 		    } else {
 			g->cols = 1;
@@ -1550,7 +1551,8 @@
 		if (g->cols) {
 		    glines += (g->dcount + g->cols - 1) / g->cols;
 		    if (g->cols > 1)
-			g->width += (max - (g->width * g->cols - add)) / g->cols;
+			g->width += ((max - (g->width * g->cols - CM_SPACE)) /
+                                     g->cols);
 		} else if (!(g->flags & CGF_LINES)) {
 		    g->cols = 1;
 		    g->width = 0;
@@ -1573,8 +1575,6 @@
 	    if (!(g->flags & CGF_PACKED))
 		continue;
 
-            add = 2 + !!(g->flags & CGF_FILES);
-
 	    ws = g->widths = (int *) zalloc(columns * sizeof(int));
 	    memset(ws, 0, columns * sizeof(int));
 	    tlines = g->lins;
@@ -1587,12 +1587,13 @@
 		    VARARR(int, ylens, yl);
 
 		    for (i = 0; *pp; i++, pp++)
-			ylens[i] = ztrlen(*pp) + add;
+			ylens[i] = ztrlen(*pp) + CM_SPACE;
 
 		    if (g->flags & CGF_ROWS) {
                         int nth, tcol, len;
 
-                        for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                        for (tcols = columns / (g->shortest + CM_SPACE);
+                             tcols > g->cols;
                              tcols--) {
 
                             memset(ws, 0, tcols * sizeof(int));
@@ -1620,7 +1621,8 @@
 		    } else {
                         int nth, tcol, tline, len;
 
-                        for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                        for (tcols = columns / (g->shortest + CM_SPACE);
+                             tcols > g->cols;
                              tcols--) {
 
                             if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
@@ -1658,7 +1660,8 @@
 		if (g->flags & CGF_ROWS) {
                     int nth, tcol, len;
 
-                    for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                    for (tcols = columns / (g->shortest + CM_SPACE);
+                         tcols > g->cols;
                          tcols--) {
 
                         memset(ws, 0, tcols * sizeof(int));
@@ -1675,7 +1678,7 @@
                                 tlines++;
                             }
                             len = (mlens[m->gnum] +
-                                   (tcol == tcols - 1 ? 0 : add));
+                                   (tcol == tcols - 1 ? 0 : CM_SPACE));
 
                             if (len > ws[tcol]) {
                                 width += len - ws[tcol];
@@ -1688,7 +1691,8 @@
 		} else {
                     int nth, tcol, tline, len;
 
-                    for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                    for (tcols = columns / (g->shortest + CM_SPACE);
+                         tcols > g->cols;
                          tcols--) {
 
                         if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
@@ -1712,7 +1716,7 @@
                                 tlines++;
                             }
                             len = (mlens[m->gnum] +
-                                   (tcol == tcols - 1 ? 0 : add));
+                                   (tcol == tcols - 1 ? 0 : CM_SPACE));
 
                             if (len > ws[tcol]) {
                                 width += len - ws[tcol];
@@ -1737,20 +1741,19 @@
 		g->lins = tlines;
 		g->cols = tcols;
 		g->totl = width;
-		width -= add;
+		width -= CM_SPACE;
 		if (width > max)
 		    max = width;
 	    }
 	}
 	for (g = amatches; g; g = g->next) {
-            add = 2 + !!(g->flags & CGF_FILES);
 	    if (g->widths) {
-		int *p, a = (max - g->totl + add) / g->cols;
+		int *p, a = (max - g->totl + CM_SPACE) / g->cols;
 
 		for (i = g->cols, p = g->widths; i; i--, p++)
 		    *p += a;
 	    } else if (g->width && g->cols > 1)
-		g->width += (max - (g->width * g->cols - add)) / g->cols;
+		g->width += (max - (g->width * g->cols - CM_SPACE)) / g->cols;
 	}
     }
     listdat.valid = 1;
@@ -1949,7 +1952,7 @@
 			    }
 			}
 			printed++;
-			printm(g, p, 0, ml, 1, 0, NULL, NULL);
+			printm(g, p, 0, ml, 1, 0);
 			pnl = 1;
 		    }
 	    }
@@ -1970,25 +1973,10 @@
 		while (n && i--) {
 		    wid = (g->widths ? g->widths[mc] : g->width);
 		    if (!(m = *q)) {
-			printm(g, NULL, mc, ml, (!i), wid, NULL, NULL);
+			printm(g, NULL, mc, ml, (!i), wid);
 			break;
 		    }
-		    if (!m->disp && (m->flags & CMF_FILE) &&
-			m->str[0] && m->str[strlen(m->str) - 1] != '/') {
-			struct stat buf;
-			char *pb;
-
-			pb = (char *) zhalloc((m->prpre ? strlen(m->prpre) : 0) +
-					     3 + strlen(m->str));
-			sprintf(pb, "%s%s", (m->prpre ? m->prpre : "./"),
-				m->str);
-
-			if (ztat(pb, &buf, 1))
-			    printm(g, q, mc, ml, (!i), wid, NULL, NULL);
-			else
-			    printm(g, q, mc, ml, (!i), wid, pb, &buf);
-		    } else
-			printm(g, q, mc, ml, (!i), wid, NULL, NULL);
+                    printm(g, q, mc, ml, (!i), wid);
 
 		    printed++;
 
@@ -2000,7 +1988,7 @@
 		}
 		while (i-- > 0) {
 		    printm(g, NULL, mc, ml, (!i),
-			   (g->widths ? g->widths[mc] : g->width), NULL, NULL);
+			   (g->widths ? g->widths[mc] : g->width));
 		    mc++;
 		}
 		if (n) {
@@ -2091,8 +2079,7 @@
 
 /**/
 static void
-iprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
-	char *path, struct stat *buf)
+iprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width)
 {
     Cmatch m;
     int len = 0;
@@ -2114,8 +2101,8 @@
 	nicezputs(m->str, shout);
 	len = niceztrlen(m->str);
 
-	if ((g->flags & CGF_FILES) && buf) {
-	    putc(file_type(buf->st_mode), shout);
+	if ((g->flags & CGF_FILES) && m->modec) {
+	    putc(m->modec, shout);
 	    len++;
 	}
     }

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2002-05-21  8:06 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06  7:54 completion in quotes - " vs ' - no suffix added Borsenkow Andrej
2002-05-06 15:31 ` Bart Schaefer
2002-05-08  7:37   ` Sven Wischnowsky
2002-05-08  8:49     ` Borsenkow Andrej
2002-05-08 12:39       ` Sven Wischnowsky
2002-05-08 15:38         ` Bart Schaefer
2002-05-13  9:30           ` Sven Wischnowsky
2002-05-13 10:14             ` Borsenkow Andrej
2002-05-13 17:33               ` Bart Schaefer
2002-05-13 18:04                 ` Borsenkow Andrej
2002-05-14  7:44                   ` Sven Wischnowsky
2002-05-14 14:23                     ` Bart Schaefer
2002-05-14 14:31                       ` Bart Schaefer
2002-05-14 15:23                         ` Sven Wischnowsky
2002-05-14 15:35                           ` Borsenkow Andrej
2002-05-15  7:37                           ` Sven Wischnowsky
2002-05-21  8:06                     ` PATCH: " Sven Wischnowsky

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).