From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14167 invoked from network); 18 Oct 2008 18:49:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Oct 2008 18:49:18 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 59196 invoked from network); 18 Oct 2008 18:49:06 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Oct 2008 18:49:06 -0000 Received: (qmail 24718 invoked by alias); 18 Oct 2008 18:48:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25912 Received: (qmail 24700 invoked from network); 18 Oct 2008 18:48:50 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 Oct 2008 18:48:50 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id B521680524C0 for ; Sat, 18 Oct 2008 20:48:46 +0200 (CEST) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.05.02.00 201-2174-114-20060621) with ESMTP id <20081018184846.TOTF2285.mtaout01-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com>; Sat, 18 Oct 2008 19:48:46 +0100 Received: from pws-pc ([81.107.43.40]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20081018184846.SAXU2093.aamtaout03-winn.ispmail.ntl.com@pws-pc>; Sat, 18 Oct 2008 19:48:46 +0100 Date: Sat, 18 Oct 2008 19:48:30 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Cc: 501851@bugs.debian.org Subject: Re: Bug#501851: zsh: Completion fails if a directory name contains '(', ')' and =?UTF-8?B?J8SE?= '. Message-ID: <20081018194830.125b5085@pws-pc> In-Reply-To: <48F572E7.3050600@inz.sakura.ne.jp> References: <20081010230611.23133.42221.reportbug@debian> <20081010231712.GA20915@scru.org> <48F0AE88.1020307@inz.sakura.ne.jp> <20081011225255.0df2e350@pws-pc> <48F2A515.1030203@inz.sakura.ne.jp> <2d460de70810122325r7e576759t204653bd537006b5@mail.gmail.com> <48F3F9F5.1040009@inz.sakura.ne.jp> <20081014130445.73a7033d@news01> <48F572E7.3050600@inz.sakura.ne.jp> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.12; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Cloudmark-Analysis: v=1.0 c=1 a=xwFHshQBCqYA:10 a=v66L8OmKkSMA:10 a=NLZqzBF-AAAA:8 a=IpqUY28YlkyPUDOSjBMA:9 a=3mLHB_5bu8Pd9E-70oAA:7 a=53Ps2A19sbd1Jc3aU7G8xLl3gBsA:4 a=_dQi-Dcv4p4A:10 a=LY0hPdMaydYA:10 X-Virus-Scanned: ClamAV 0.92.1/8443/Sat Oct 18 08:08:31 2008 on bifrost X-Virus-Status: Clean On Wed, 15 Oct 2008 13:34:47 +0900 Morita Sho wrote: > Thanks for detailed explanation! But I'm still confusing. Even with the o= ld > syntax, the completion =C4=84/[TAB] won't work. You're right. My explanation wasn't correct; it doesn't matter if you use the m:{[lower]}=3D{[upper]} syntax or the older one, so I've restored the advice that the newer one is preferable. > BTW, to find out why replacing _path_files with the old one solves the pr= oblem > for me, I put a debug output into _path_files as below to watch the value= of > $tmp1 before the $~tmp1 expansion. > print "DEBUG: LINENO=3D$LINENO tmp1=3D$tmp1" > /dev/stderr > tmp1=3D( $~tmp1 ) 2> /dev/null >=20 > When I type =C4=84/[TAB], I got this debug output. > DEBUG: LINENO=3D400 tmp1=3D=C4=83=EF=BF=BD*(-/) > DEBUG: LINENO=3D400 tmp1=3D=C4=83=EF=BF=BD*(-/) Thanks, this tells me that the compfiles utility isn't handling Meta characters properly when performing matching. Luckily this seems to be a local problem within that command that I think the patch addresses. Index: Doc/Zsh/compwid.yo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v retrieving revision 1.44 diff -u -r1.44 compwid.yo --- Doc/Zsh/compwid.yo 14 Oct 2008 12:59:04 -0000 1.44 +++ Doc/Zsh/compwid.yo 18 Oct 2008 18:44:08 -0000 @@ -942,16 +942,14 @@ completion you can use `tt(m:{[:lower:]}=3D{[:upper:]})'. Although the matching system does not yet handle multibyte characters, this is likely to be a future extension, at which point this syntax will handle -arbitrary alphabets; until then it is safer to use the older syntax -that only handles ASCII characters, `tt(m:{a-z}=3D{A-Z}) as this does -not have side effects in the case of multibyte characters. - -In other cases `tt([:)var(name)tt(:])' forms are allowed. If the two forms -on the left and right are the same, the characters must match exactly. In -remaining cases, the corresponding tests are applied to both characters, -but they are not otherwise constrained; any matching character in one set -goes with any matching character in the other set: this is equivalent to -the behaviour of ordinary character classes. +arbitrary alphabets; hence this form, rather than the use of explicit +ranges, is the recommended form. In other cases +`tt([:)var(name)tt(:])' forms are allowed. If the two forms on the left +and right are the same, the characters must match exactly. In remaining +cases, the corresponding tests are applied to both characters, but they +are not otherwise constrained; any matching character in one set goes +with any matching character in the other set: this is equivalent to the +behaviour of ordinary character classes. =20 The pattern var(tpat) may also be one or two stars, `tt(*)' or `tt(**)'. This means that the pattern on the command line can match Index: Src/Zle/computil.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v retrieving revision 1.110 diff -u -r1.110 computil.c --- Src/Zle/computil.c 14 Oct 2008 22:09:11 -0000 1.110 +++ Src/Zle/computil.c 18 Oct 2008 18:44:09 -0000 @@ -4024,7 +4024,7 @@ * management is difficult. */ for (;;) { - for (mp =3D ms; *add; add++, mp++) { + for (mp =3D ms; *add; ) { if (!(m =3D *mp)) { /* * No matcher, so just match the character @@ -4034,13 +4034,13 @@ * metacharacter? */ if (ret) { - if (imeta(*add)) { + if (*add =3D=3D Meta) { *p++ =3D Meta; - *p++ =3D *add ^ 32; + *p++ =3D add[1]; } else *p++ =3D *add; } else - len +=3D imeta(*add) ? 2 : 1; + len +=3D (*add =3D=3D Meta) ? 2 : 1; } else if (m->flags & CMF_RIGHT) { /* * Right-anchored: match anything followed @@ -4049,15 +4049,16 @@ if (ret) { *p++ =3D '*'; /* TODO: quote again? */ - if (imeta(*add)) { + if (*add =3D=3D Meta) { *p++ =3D Meta; - *p++ =3D *add ^ 32; + *p++ =3D add[1]; } else *p++ =3D *add; } else - len +=3D imeta(*add) ? 3 : 2; + len +=3D (*add =3D=3D Meta) ? 3 : 2; } else { /* The usual set of matcher possibilities. */ + int chr =3D (*add =3D=3D Meta) ? add[1] ^ 32 : *add; int ind; if (m->line->tp =3D=3D CPAT_EQUIV && m->word->tp =3D=3D CPAT_EQUIV) { @@ -4072,21 +4073,21 @@ */ if (ret) { *p++ =3D '['; - if (imeta(*add)) { + if (*add =3D=3D Meta) { *p++ =3D Meta; - *p++ =3D *add ^ 32; + *p++ =3D add[1]; } else *p++ =3D *add; } else - len +=3D imeta(*add) ? 3 : 2; - if (PATMATCHRANGE(m->line->u.str, CONVCAST(*add), + len +=3D (*add =3D=3D Meta) ? 3 : 2; + if (PATMATCHRANGE(m->line->u.str, CONVCAST(chr), &ind, &mt)) { /* * Find the equivalent match for ind in the * word pattern. */ if ((ind =3D pattern_match_equivalence - (m->word, ind, mt, CONVCAST(*add))) !=3D -1) { + (m->word, ind, mt, CONVCAST(chr))) !=3D -1) { if (ret) { if (imeta(ind)) { *p++ =3D Meta; @@ -4158,7 +4159,7 @@ * if *add is ] and ] is also the first * character in the range. */ - addadd =3D !pattern_match1(m->word, CONVCAST(*add), &mt); + addadd =3D !pattern_match1(m->word, CONVCAST(chr), &mt); if (addadd && *add =3D=3D ']') { if (ret) *p++ =3D *add; @@ -4218,6 +4219,13 @@ } } } + if (*add =3D=3D Meta) { + add +=3D 2; + mp +=3D 2; + } else { + add++; + mp++; + } } if (ret) { *p =3D '\0'; @@ -4236,19 +4244,19 @@ =20 if (m && m !=3D pcm_err) { char *tmp; - int al =3D strlen(add), tl; - VARARR(Cmatcher, ms, al); + int al =3D strlen(add), zl =3D ztrlen(add), tl, cl; + VARARR(Cmatcher, ms, zl); Cmatcher *mp; Cpattern stopp; int stopl =3D 0; =20 - memset(ms, 0, al * sizeof(Cmatcher)); + memset(ms, 0, zl * sizeof(Cmatcher)); =20 for (; m && *add; m =3D m->next) { stopp =3D NULL; if (!(m->flags & (CMF_LEFT|CMF_RIGHT))) { if (m->llen =3D=3D 1 && m->wlen =3D=3D 1) { - for (tmp =3D add, tl =3D al, mp =3D ms; tl; tl--, tmp++, mp++) { + for (tmp =3D add, tl =3D al, mp =3D ms; tl; ) { if (pattern_match(m->line, tmp, NULL, NULL)) { if (*mp) { *tmp =3D '\0'; @@ -4257,6 +4265,10 @@ } else *mp =3D m; } + cl =3D (*tmp =3D=3D Meta) ? 2 : 1; + tl -=3D cl; + tmp +=3D cl; + mp +=3D cl; } } else { stopp =3D m->line; @@ -4264,7 +4276,7 @@ } } else if (m->flags & CMF_RIGHT) { if (m->wlen < 0 && !m->llen && m->ralen =3D=3D 1) { - for (tmp =3D add, tl =3D al, mp =3D ms; tl; tl--, tmp++, mp++) { + for (tmp =3D add, tl =3D al, mp =3D ms; tl; ) { if (pattern_match(m->right, tmp, NULL, NULL)) { if (*mp || (tmp =3D=3D add && *tmp =3D=3D '.')) { *tmp =3D '\0'; @@ -4273,6 +4285,10 @@ } else *mp =3D m; } + cl =3D (*tmp =3D=3D Meta) ? 2 : 1; + tl -=3D cl; + tmp +=3D cl; + mp +=3D cl; } } else if (m->llen) { stopp =3D m->line; @@ -4289,12 +4305,16 @@ stopl =3D m->lalen; } if (stopp) - for (tmp =3D add, tl =3D al; tl >=3D stopl; tl--, tmp++) + for (tmp =3D add, tl =3D al; tl >=3D stopl; ) { if (pattern_match(stopp, tmp, NULL, NULL)) { *tmp =3D '\0'; al =3D tmp - add; break; } + cl =3D (*tmp =3D=3D Meta) ? 2 : 1; + tl -=3D cl; + tmp +=3D cl; + } } if (*add) return cfp_matcher_range(ms, add); --=20 Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/