zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-workers@sunsite.dk
Subject: Re: completion in quotes - " vs ' - no suffix added
Date: Wed, 15 May 2002 09:37:48 +0200	[thread overview]
Message-ID: <15586.4172.587990.806826@wischnow.berkom.de> (raw)
In-Reply-To: <15585.11254.373249.131932@wischnow.berkom.de>


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


  parent reply	other threads:[~2002-05-15  7:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-06  7:54 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 [this message]
2002-05-21  8:06                     ` PATCH: " Sven Wischnowsky

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=15586.4172.587990.806826@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --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).