diff options
author | Slaven Rezic <slaven@rezic.de> | 2007-02-03 00:08:28 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-02-02 23:35:22 +0000 |
commit | 77348331ba668328554e7a9d261f69ef327189e7 (patch) | |
tree | f4e7580b7ceeb5f6b911124430d073e77fd6d78a /ext/File/Glob | |
parent | 6502358f02d6c4ea5159a32e117a91663131f6af (diff) | |
download | perl-77348331ba668328554e7a9d261f69ef327189e7.tar.gz |
Re: [perl #41421] glob() produces spurious results with brackets in braces
Message-ID: <87r6t81acj.fsf@biokovo.herceg.de>
Date: 02 Feb 2007 23:08:28 +0100
p4raw-id: //depot/perl@30103
Diffstat (limited to 'ext/File/Glob')
-rw-r--r-- | ext/File/Glob/bsd_glob.c | 6 | ||||
-rwxr-xr-x | ext/File/Glob/t/basic.t | 25 |
2 files changed, 27 insertions, 4 deletions
diff --git a/ext/File/Glob/bsd_glob.c b/ext/File/Glob/bsd_glob.c index 4d1e7f0695..c6fce1e205 100644 --- a/ext/File/Glob/bsd_glob.c +++ b/ext/File/Glob/bsd_glob.c @@ -431,7 +431,7 @@ globexp2(const Char *ptr, const Char *pattern, { 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 @@ globexp2(const Char *ptr, const Char *pattern, 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; diff --git a/ext/File/Glob/t/basic.t b/ext/File/Glob/t/basic.t index fc168b8ce7..cee453c5e9 100755 --- a/ext/File/Glob/t/basic.t +++ b/ext/File/Glob/t/basic.t @@ -13,7 +13,7 @@ BEGIN { 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 @@ rmdir "pteerslo"; # 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: $!"; +} |