On Sat, 11 Oct 2008 22:47:52 +0900
Morita Sho <[EMAIL PROTECTED]> wrote:
> $~tmp1 expansion seems not working correctly for a pattern '\(\)Ą/*'.

Thanks for the clear analysis.

The pattern gets divided up into chunks because of the backslashed
characters, but we don't report that it wasn't a pure string on that
basis, so the directory trise to match the wrong string.  This was triggered
in this case because of the character in a range that zsh has to quote
internally to avoid clashing with tokens, which is why it occurred with
some forms of accent but not others.

I could optimise this better but this is a simple change for now.

Index: Src/pattern.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v
retrieving revision 1.47
diff -u -r1.47 pattern.c
--- Src/pattern.c       8 Jun 2008 17:53:55 -0000       1.47
+++ Src/pattern.c       11 Oct 2008 21:44:35 -0000
@@ -1446,7 +1446,13 @@
             * Marker for restoring a backslash in output:
             * does not match a character.
             */
-           return patcomppiece(flagp);
+           next = patcomppiece(flagp);
+           /*
+            * Can't match a pure string since we need to do this
+            * as multiple chunks.
+            */
+           *flagp &= ~P_PURESTR;
+           return next;
            break;
 #ifdef DEBUG
        default:
Index: Test/D07multibyte.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v
retrieving revision 1.25
diff -u -r1.25 D07multibyte.ztst
--- Test/D07multibyte.ztst      26 Mar 2008 15:26:20 -0000      1.25
+++ Test/D07multibyte.ztst      11 Oct 2008 21:44:35 -0000
@@ -395,3 +395,14 @@
 >OK
 >OK
 >OK
+
+  mkdir glob
+  mkdir glob/'()Ą' glob/'()Ā'
+  mkdir glob/'()Ą'/foo glob/'()Ā'/bar
+  tmp1=('glob/\(\)Ą/*')
+  print $~tmp1
+  tmp1=('glob/\(\)Ā/*')
+  print $~tmp1
+0:Backslashes and metafied characters in patterns
+>glob/()Ą/foo
+>glob/()Ā/bar



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to