I don't want to write a patch because I am tired and lazy, but the various
places in the source that test $^O =~ /win/i unfortunately catch Darwin and Mac
OS X, which have the osname "darwin".
Please change the tests to either eq "Win32" or =~ /^(?:Win32|cygwin)$/ or
something. I am not sure if you want to catch cygwin, either. Then there's the
issue of OS2 and DOS.
Really, many of these should use other facilities, like File::Spec. For
example:
elsif (($name =~ m[^/]) || (($^O =~ /win/i) && ($name =~ m[^(\w:)?/]))) {
# absolute paths (starting '/') allowed if ABSOLUTE set
This could be rewritten as:
require File::Spec;
# ...
elsif (File::Spec->file_name_is_absolute($name)) {
Come to think of it, I might as well do a patch. Here it is. Someone please
check my assumptions. I basically assume that MSWin32 is the osname for
Windows. It is the only one I know of that uses Windows filespecs and matches
/win/i.
I also added File::Spec to Provider.pm. It is included with perl back to 5.005
IIRC, and is available on CPAN, of course.
--Chris
--- Template-Toolkit-2.04f/Makefile.PL Mon Sep 10 05:24:07 2001
+++ Template-Toolkit-2.04f.new/Makefile.PL Mon Sep 10 23:05:11 2001
@@ -20,7 +20,7 @@
# check O/S to set sensible defaults
my ($WIN32, $FLAVOUR, $PREFIX, $IMAGES, $MAKE);
-if ($^O =~ /win/i) {
+if ($^O eq 'MSWin32') { # any others also?
$WIN32 = 1;
$FLAVOUR = 'Win32';
$PREFIX = 'C:/Program Files/Template Toolkit 2';
--- Template-Toolkit-2.04f/lib/Template/Context.pm Mon Sep 10 05:37:49 2001
+++ Template-Toolkit-2.04f.new/lib/Template/Context.pm Mon Sep 10 23:04:38 2001
@@ -102,7 +102,7 @@
# prefix is specified to indicate the desired provider set.
$prefix = undef;
- if ($^O =~ /win/i) {
+ if ($^O eq 'MSWin32') {
$prefix = $1 # let C:/foo through
if $name =~ s/^(\w{2,})://o;
}
--- Template-Toolkit-2.04f/lib/Template/Filters.pm Mon Sep 10 05:37:49 2001
+++ Template-Toolkit-2.04f.new/lib/Template/Filters.pm Mon Sep 10 23:08:59 2001
@@ -562,7 +562,7 @@
# do on other OSs
#
my $LaTeX_arg = "\\nonstopmode\\input{$texDoc}";
- $LaTeX_arg = "'$LaTeX_arg'" if ( $^O !~ /win/i );
+ $LaTeX_arg = "'$LaTeX_arg'" if ( $^O ne 'MSWin32' );
if ( system("$LaTeXPath $LaTeX_arg"
. " 1>$devnull 2>$devnull 0<$devnull") ) {
my $texErrs = "";
--- Template-Toolkit-2.04f/lib/Template/Provider.pm Mon Sep 10 05:37:49 2001
+++ Template-Toolkit-2.04f.new/lib/Template/Provider.pm Mon Sep 10 23:08:34 2001
@@ -42,6 +42,7 @@
use Template::Constants;
use Template::Document;
use File::Basename;
+use File::Spec;
$VERSION = sprintf("%d.%02d", q$Revision: 2.24 $ =~ /(\d+)\.(\d+)/);
@@ -96,7 +97,7 @@
$data = $data->{ data }
unless $error;
}
- elsif (($name =~ m[^/]) || (($^O =~ /win/i) && ($name =~ m[^(\w:)?/]))) {
+ elsif (File::Spec->file_name_is_absolute($name)) {
# absolute paths (starting '/') allowed if ABSOLUTE set
($data, $error) = $self->{ ABSOLUTE }
? $self->_fetch($name)
@@ -156,7 +157,7 @@
my ($data, $error);
my $path = $name;
- if (($name =~ m[^/]) || (($^O =~ /win/i) && ($name =~ m[^(\w:)?/]))) {
+ if (File::Spec->file_name_is_absolute($name)) {
# absolute paths (starting '/') allowed if ABSOLUTE set
$error = "$name: absolute paths are not allowed (set ABSOLUTE option)"
unless $self->{ ABSOLUTE };
@@ -267,7 +268,7 @@
# tweak delim to ignore C:/
unless (defined $dlim) {
- $dlim = ($^O =~ /win/i) ? ':(?!\\/)' : ':';
+ $dlim = ($^O eq 'MSWin32') ? ':(?!\\/)' : ':';
}
# coerce INCLUDE_PATH to an array ref, if not already so
@@ -305,7 +306,7 @@
require File::Path;
foreach my $dir (@$path) {
my $wdir = $dir;
- $wdir =~ s[:][]g if ($^O =~ /win/i);
+ $wdir =~ s[:][]g if $^O eq 'MSWin32';
&File::Path::mkpath("$cdir/$wdir");
}
# ensure $cdir is terminated with '/' for subsequent path building
@@ -490,7 +491,7 @@
$path = $file;
$path =~ /^(.+)$/s or die "invalid filename: $path";
- $path =~ s[:][]g if $^O =~ /win/i;
+ $path =~ s[:][]g if $^O eq 'MSWin32';
$compiled = "$compdir$path$compext";
$compiled =~ s[//][/]g;
--- Template-Toolkit-2.04f/t/compile5.t Sat Aug 4 05:49:29 2001
+++ Template-Toolkit-2.04f.new/t/compile5.t Mon Sep 10 23:09:49 2001
@@ -37,7 +37,7 @@
};
# check compiled template files exist
-my ($foo, $bar, $blam) = map { $dir =~ s[:][]g if ($^O =~ /win/i);
+my ($foo, $bar, $blam) = map { $dir =~ s[:][]g if $^O eq 'MSWin32';
"$cdir/$dir/src/$_.ttc" } qw( foo complex blam );
$blam =~ s[/+][/]g;
--- Template-Toolkit-2.04f/t/directry.t Thu Jun 14 09:20:12 2001
+++ Template-Toolkit-2.04f.new/t/directry.t Mon Sep 10 23:09:24 2001
@@ -21,7 +21,7 @@
use Cwd;
$^W = 1;
-if ($^O =~ /win/i) {
+if ($^O eq 'MSWin32') {
print "1..0\n";
exit(0);
}
--- Template-Toolkit-2.04f/t/file.t Wed Aug 29 04:48:37 2001
+++ Template-Toolkit-2.04f.new/t/file.t Mon Sep 10 23:10:04 2001
@@ -21,7 +21,7 @@
use Template::Plugin::File;
$^W = 1;
-if ($^O =~ /win/i) {
+if ($^O eq 'MSWin32') {
print "1..0\n";
exit(0);
}
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/