Change 30103 by [EMAIL PROTECTED] on 2007/02/02 23:35:22

        Subject: Re: [perl #41421] glob() produces spurious results with 
brackets in braces
        From: Slaven Rezic <[EMAIL PROTECTED]>
        Message-ID: <[EMAIL PROTECTED]>
        Date: 02 Feb 2007 23:08:28 +0100

Affected files ...

... //depot/perl/ext/File/Glob/bsd_glob.c#30 edit
... //depot/perl/ext/File/Glob/t/basic.t#10 edit

Differences ...

==== //depot/perl/ext/File/Glob/bsd_glob.c#30 (text) ====
Index: perl/ext/File/Glob/bsd_glob.c
--- perl/ext/File/Glob/bsd_glob.c#29~28730~     2006-08-16 10:44:44.000000000 
-0700
+++ perl/ext/File/Glob/bsd_glob.c       2007-02-02 15:35:22.000000000 -0800
@@ -431,7 +431,7 @@
 {
        int     i;
        Char   *lm, *ls;
-       const Char *pe, *pm, *pl;
+       const Char *pe, *pm, *pm1, *pl;
        Char    patbuf[MAXPATHLEN];
 
        /* copy part up to the brace */
@@ -471,14 +471,14 @@
                switch (*pm) {
                case BG_LBRACKET:
                        /* Ignore everything between [] */
-                       for (pl = pm++; *pm != BG_RBRACKET && *pm != BG_EOS; 
pm++)
+                       for (pm1 = pm++; *pm != BG_RBRACKET && *pm != BG_EOS; 
pm++)
                                ;
                        if (*pm == BG_EOS) {
                                /*
                                 * We could not find a matching BG_RBRACKET.
                                 * Ignore and just look for BG_RBRACE
                                 */
-                               pm = pl;
+                               pm = pm1;
                        }
                        break;
 

==== //depot/perl/ext/File/Glob/t/basic.t#10 (xtext) ====
Index: perl/ext/File/Glob/t/basic.t
--- perl/ext/File/Glob/t/basic.t#9~23584~       2004-12-01 05:44:24.000000000 
-0800
+++ perl/ext/File/Glob/t/basic.t        2007-02-02 15:35:22.000000000 -0800
@@ -13,7 +13,7 @@
         print "1..0\n";
         exit 0;
     }
-    print "1..12\n";
+    print "1..13\n";
 }
 END {
     print "not ok 1\n" unless $loaded;
@@ -187,3 +187,26 @@
 # this can panic if PL_glob_index gets passed as flags to bsd_glob
 <*>; <*>;
 print "ok 12\n";
+
+{
+    use File::Temp qw(tempdir);
+    use File::Spec qw();
+
+    my($dir) = tempdir(CLEANUP => 1)
+       or die "Could not create temporary directory";
+    for my $file (qw(a_dej a_ghj a_qej)) {
+       open my $fh, ">", File::Spec->catfile($dir, $file)
+           or die "Could not create file $dir/$file: $!";
+       close $fh;
+    }
+    my $cwd = Cwd::cwd();
+    chdir $dir
+       or die "Could not chdir to $dir: $!";
+    my(@glob_files) = glob("a*{d[e]}j");
+    if (!(@glob_files == 1 && "@glob_files" eq "a_dej")) {
+       print "not ";
+    }
+    print "ok 13\n";
+    chdir $cwd
+       or die "Could not chdir back to $cwd: $!";
+}
End of Patch.

Reply via email to