develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH] ExtUtils::Constant (was Re: funny numconvert test in perl@11006 (was Re: report on BS2000 wit h perl@11006))

Thread Next
From:
Nicholas Clark
Date:
July 10, 2001 15:17
Subject:
[PATCH] ExtUtils::Constant (was Re: funny numconvert test in perl@11006 (was Re: report on BS2000 wit h perl@11006))
Message ID:
20010710231742.B59620@plum.flirble.org
> > Von: 	Nicholas Clark[SMTP:nick@ccl4.org]
> > Gesendet: 	Samstag, 7. Juli 2001 00:35
> > An: 	Dorner Thomas
> > Betreff: 	Re: report on BS2000 with perl@11006
> > 
> > On Fri, Jul 06, 2001 at 02:16:22PM +0200, Dorner Thomas wrote:
> > > Hi,
> > > 
> > > lib/ExtUtils.t was mostly a space problem (disk full), now I only have
> > one
> > > nok for test 25 (before "#make = 'make clean'").
> > > 
> > > The differences between regen and expect are \177s instead of "s in the
> > > assignments to *pv_return:
> > 
> > > -      *pv_return = \177not ok 7\n\0ok 7\n\177;
> > > +      *pv_return = "not ok 7\n\0ok 7\n";
> > 
> > My stupid fault. \177 is DEL in ASCII, and I was trying to convert it to
> > octal. I've got a better idea about how to improve the regexps at the
> > top of ExtUtils::Constant.pm to fix this and work back to 5.005_03 (or
> > earlier) and will attempt a patch tomorrow.

Hmm. [:print:] and friends are 5.6 and later. Gets trickier on 5.005_03

The patched version should work on EBCDIC, and does test 100% on
bleadperl and 5.005_03. [both non-threads, but it should work elsewhere]
Is there an official File::Spec::Functions for 5.005_03? And is there
rel2abs in a File::Spec that works back to 5.005_03?

Does this actually do anything useful:

+  eval "use warnings; 1" or die $@;

If not, what's the best way to say use warnings if 5.006 or later?

Nicholas Clark

--- lib/ExtUtils/Constant.pm.orig	Fri Jun 22 14:18:36 2001
+++ lib/ExtUtils/Constant.pm	Tue Jul 10 22:45:29 2001
@@ -1,6 +1,6 @@
 package ExtUtils::Constant;
 use vars qw (@ISA $VERSION %XS_Constant %XS_TypeSet @EXPORT_OK %EXPORT_TAGS);
-$VERSION = '0.08';
+$VERSION = '0.09';
 
 =head1 NAME
 
@@ -92,8 +92,9 @@
 
 =cut
 
-require 5.006; # I think, for [:cntrl:] in REGEXP
-use warnings;
+if ($] >= 5.006) {
+  eval "use warnings; 1" or die $@;
+}
 use strict;
 use Carp;
 
@@ -154,8 +155,15 @@
   s/\t/\\t/g;
   s/\f/\\f/g;
   s/\a/\\a/g;
-  s/([[:cntrl:]])/sprintf "\\%03o", ord $1/ge;
-  s/\177/\\177/g;	# DEL doesn't seem to be a [:cntrl:]
+  unless ($] < 5.006) {
+    # This will elict a warning on 5.005_03 about [: :] being reserved unless
+    # I cheat
+    my $cheat = '([[:^print:]])';
+    s/$cheat/sprintf "\\%03o", ord $1/ge;
+  } else {
+    require POSIX;
+    s/([^A-Za-z0-9_])/POSIX::isprint($1) ? $1 : sprintf "\\%03o", ord $1/ge;
+  }
   $_;
 }
 
@@ -178,6 +186,12 @@
 
 #ifndef NVTYPE
 typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it.  */
+#endif
+#ifndef aTHX_
+#define aTHX_ /* 5.6 or later define this for threading support.  */
+#endif
+#ifndef pTHX_
+#define pTHX_ /* 5.6 or later define this for threading support.  */
 #endif
 EOT
 
--- lib/ExtUtils.t.orig	Wed Jul  4 15:48:47 2001
+++ lib/ExtUtils.t	Tue Jul 10 22:58:19 2001
@@ -7,7 +7,7 @@
     @INC = '../lib';
 }
 
-use warnings;
+# use warnings;
 use strict;
 use ExtUtils::MakeMaker;
 use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
@@ -15,7 +15,8 @@
 use File::Spec::Functions;
 use File::Spec;
 # Because were are going to be changing directory before running Makefile.PL
-my $perl = File::Spec->rel2abs( $^X );
+my $perl;
+$perl = rel2abs( $^X ) unless $] < 5.006; # Hack. Until 5.00503 has rel2abs
 # ExtUtils::Constant::C_constant uses $^X inside a comment, and we want to
 # compare output to ensure that it is the same. We were probably run as ./perl
 # whereas we will run the child with the full path in $perl. So make $^X for
@@ -45,7 +46,7 @@
 
 # Test the code that generates 1 and 2 letter name comparisons.
 my %compass = (
-N => 0, NE => 45, E => 90, SE => 135, S => 180, SW => 225, W => 270, NW => 315
+N => 0, 'NE' => 45, E => 90, SE => 135, S => 180, SW => 225, W => 270, NW => 315
 );
 
 my $parent_rfc1149 =
@@ -133,12 +134,14 @@
 print FH <<'EOT';
 
 use strict;
-use warnings;
+EOT
+printf FH "use warnings;\n" unless $] < 5.006;
+print FH <<'EOT';
 use Carp;
 
 require Exporter;
 require DynaLoader;
-use vars qw ($VERSION @ISA @EXPORT_OK);
+use vars qw ($VERSION @ISA @EXPORT_OK $AUTOLOAD);
 
 $VERSION = '0.01';
 @ISA = qw(Exporter DynaLoader);
@@ -292,7 +295,7 @@
 EOT
 
 while (my ($point, $bearing) = each %compass) {
-  print FH "$point => $bearing, "
+  print FH "'$point' => $bearing, "
 }
 
 print FH <<'EOT';

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About