New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
glob() produces spurious results with brackets in braces #8759
Comments
From @pjscottglob() is listing files that I don't think it should in this example $ ls -1 $ perl -le 'print for glob "a*{d[ef],g[hi]}j"' $ ls -1 a*{d[ef],g[hi]}j This is with at least 5.8.8 and blead. Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Characteristics of this binary (from libperl): |
From @esertePeter Scott (via RT) <perlbug-followup@perl.org> writes:
I compared the bsd_glob.c with FreeBSD 6.1's lib/libc/gen/glob.c and Regards, |
From @esertefile-glob.patch#
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -up 'bleedperl/ext/File/Glob/bsd_glob.c' 'bleedperl2/ext/File/Glob/bsd_glob.c'
Index: ./ext/File/Glob/bsd_glob.c
Prereq: 8.3
--- ./ext/File/Glob/bsd_glob.c Wed Aug 16 19:45:11 2006
+++ ./ext/File/Glob/bsd_glob.c Fri Feb 2 22:05:52 2007
@@ -431,7 +431,7 @@ globexp2(const Char *ptr, const Char *pa
{
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 *pa
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 -up 'bleedperl/ext/File/Glob/t/basic.t' 'bleedperl2/ext/File/Glob/t/basic.t'
Index: ./ext/File/Glob/t/basic.t
--- ./ext/File/Glob/t/basic.t Tue Jun 13 21:29:07 2006
+++ ./ext/File/Glob/t/basic.t Fri Feb 2 22:18:42 2007
@@ -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: $!";
+}
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Fri Feb 2 22:19:37 2007
# Generated by : makepatch 2.03
# Recurse directories : Yes
# Excluded files : (\A|/).*\~\Z
# (\A|/).*\.a\Z
# (\A|/).*\.bak\Z
# (\A|/).*\.BAK\Z
# (\A|/).*\.elc\Z
# (\A|/).*\.exe\Z
# (\A|/).*\.gz\Z
# (\A|/).*\.ln\Z
# (\A|/).*\.o\Z
# (\A|/).*\.obj\Z
# (\A|/).*\.olb\Z
# (\A|/).*\.old\Z
# (\A|/).*\.orig\Z
# (\A|/).*\.rej\Z
# (\A|/).*\.so\Z
# (\A|/).*\.Z\Z
# (\A|/)\.del\-.*\Z
# (\A|/)\.make\.state\Z
# (\A|/)\.nse_depinfo\Z
# (\A|/)core\Z
# (\A|/)tags\Z
# (\A|/)TAGS\Z
# v 'patchlevel.h' 4732 1160388693 33060
# p 'ext/File/Glob/bsd_glob.c' 33190 1170450352 0100444
# p 'ext/File/Glob/t/basic.t' 4491 1170451122 0100555
#### End of ApplyPatch data ####
#### End of Patch kit [created: Fri Feb 2 22:19:37 2007] ####
#### Patch checksum: 107 3431 27532 ####
#### Checksum: 125 4056 13566 ####
|
From @eserte-- Berlin Perl Mongers - http://berlin.pm.org |
The RT System itself - Status changed from 'new' to 'open' |
From @nwc10On Fri, Feb 02, 2007 at 11:08:28PM +0100, Slaven Rezic wrote:
Thanks, applied (change 30103) Nicholas Clark |
@smpeters - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#41421 (status was 'resolved')
Searchable as RT41421$
The text was updated successfully, but these errors were encountered: