Change 34179 by [EMAIL PROTECTED] on 2008/08/07 10:12:09
Fix bug in counting in tempfile().
Also we need to note file names we give out, as some callers don't
create them before calling us a second time.
Add a regexp that matches the tempfile() names, for tests that want to
munge output.
Affected files ...
... //depot/perl/t/test.pl#87 edit
Differences ...
==== //depot/perl/t/test.pl#87 (text) ====
Index: perl/t/test.pl
--- perl/t/test.pl#86~34178~ 2008-08-07 01:23:13.000000000 -0700
+++ perl/t/test.pl 2008-08-07 03:12:09.000000000 -0700
@@ -619,8 +619,11 @@
}
}
-my @tmpfiles;
-END { unlink_all @tmpfiles }
+my %tmpfiles;
+END { unlink_all keys %tmpfiles }
+
+# A regexp that matches the tempfile names
+$::tempfile_regexp = 'tmp\d+[A-Z][A-Z]?';
# Avoid ++, avoid ranges, avoid split //
my @letters = qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
@@ -631,11 +634,13 @@
my $try = "tmp$$";
do {
$try .= $letters[$temp % 26];
- $count = int ($temp / 26);
+ $temp = int ($temp / 26);
} while $temp;
- if (!-e $try) {
+ # Need to note all the file names we allocated, as a second request may
+ # come before the first is created.
+ if (!-e $try && !$tmpfiles{$try}) {
# We have a winner
- push @tmpfiles, $try;
+ $tmpfiles{$try}++;
return $try;
}
$count = $count + 1;
@@ -680,8 +685,8 @@
# Clean up the results into something a bit more predictable.
$results =~ s/\n+$//;
- $results =~ s/at\s+tmp\d+[A-Z][A-Z]?\s+line/at - line/g;
- $results =~ s/of\s+tmp\d+[A-Z][A-Z]?\s+aborted/of - aborted/g;
+ $results =~ s/at\s+$::tempfile_regexp\s+line/at - line/g;
+ $results =~ s/of\s+$::tempfile_regexp\s+aborted/of - aborted/g;
# bison says 'parse error' instead of 'syntax error',
# various yaccs may or may not capitalize 'syntax'.
End of Patch.