Change 34173 by [EMAIL PROTECTED] on 2008/08/06 16:04:49
Better temporary file name generation. (Avoid using ++, avoid file
names clashing between different scripts, which may now be executing
in parallel)
Affected files ...
... //depot/perl/t/test.pl#85 edit
Differences ...
==== //depot/perl/t/test.pl#85 (text) ====
Index: perl/t/test.pl
--- perl/t/test.pl#84~34154~ 2008-07-23 09:33:21.000000000 -0700
+++ perl/t/test.pl 2008-08-06 09:04:49.000000000 -0700
@@ -619,9 +619,24 @@
}
}
+# 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);
+sub tempfile {
+ my $count = 0;
+ do {
+ my $temp = $count;
+ my $try = "tmp$$";
+ do {
+ $try .= $letters[$temp % 26];
+ $count = int ($temp / 26);
+ } while $temp;
+ return $try unless -e $try;
+ $count = $count + 1;
+ } while $count < 26 * 26;
+ die "Can't find temporary file name starting 'tmp$$'";
+}
-my $tmpfile = "misctmp000";
-1 while -f ++$tmpfile;
+my $tmpfile = tempfile();
END { unlink_all $tmpfile }
#
@@ -658,8 +673,8 @@
# Clean up the results into something a bit more predictable.
$results =~ s/\n+$//;
- $results =~ s/at\s+misctmp\d+\s+line/at - line/g;
- $results =~ s/of\s+misctmp\d+\s+aborted/of - aborted/g;
+ $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;
# bison says 'parse error' instead of 'syntax error',
# various yaccs may or may not capitalize 'syntax'.
End of Patch.