Front page | perl.perl5.porters |
Postings from October 2003
Expose PERL_PATCHLEVEL [PATCH]
Thread Previous
|
Thread Next
From:
Gisle Aas
Date:
October 17, 2003 04:22
Subject:
Expose PERL_PATCHLEVEL [PATCH]
Message ID:
lrbrsgyus4.fsf_-_@caliper.activestate.com
Yitzchak Scott-Thoennes <sthoenna@efn.org> writes:
> That's no fix.
How about this patch then. It exposes PERL_PATCHLEVEL from config.h
so that XS code can put conditions on it and also make $] and $^V
include it. With a bleadperl patched like this I get:
$ perl -v
This is perl, v5.9.0.21473 built for i686-linux
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2003, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
$ perl -le 'print $]'
5.00900021473
Official releases will not have PERL_PATCHLEVEL defined and will have
$] and $^V as before. With this we can also stop putting strings like
"DEVEL21398" as a "Locally applied patches" for blead and snapshots.
If integrated over to the 5.8.x branch you should also get the
patch number added to those build in between official releases.
Regards,
Gisle
diff -ru perl-current/config_h.SH perl-hack/config_h.SH
--- perl-current/config_h.SH 2003-08-25 10:03:31.000000000 -0700
+++ perl-hack/config_h.SH 2003-10-17 01:59:19.000000000 -0700
@@ -3429,6 +3429,20 @@
#define PERL_XS_APIVERSION "$xs_apiversion"
#define PERL_PM_APIVERSION "$pm_apiversion"
+/* PERL_PATCHLEVEL:
+ * This is the Perl patch level, a numeric change identifier,
+ * as defined by whichever source code maintenance system
+ * is used to maintain the patches; currently Perforce.
+ * It does not correlate with the Perl version numbers or
+ * the maintenance versus development dichotomy except
+ * by also being increasing.
+ */
+#define PERL_PATCHLEVEL $perl_patchlevel
+
+#if PERL_PATCHLEVEL + 0 == 0
+ #undef PERL_PATCHLEVEL
+#endif
+
/* HAS_DRAND48_PROTO:
* This symbol, if defined, indicates that the system provides
* a prototype for the drand48() function. Otherwise, it is up
diff -ru perl-current/gv.c perl-hack/gv.c
--- perl-current/gv.c 2003-09-21 03:08:11.000000000 -0700
+++ perl-hack/gv.c 2003-10-17 02:17:43.000000000 -0700
@@ -1050,7 +1050,9 @@
SV *sv = GvSV(gv);
(void)SvUPGRADE(sv, SVt_PVNV);
Perl_sv_setpvf(aTHX_ sv,
-#if defined(PERL_SUBVERSION) && (PERL_SUBVERSION > 0)
+#if defined(PERL_PATCHLEVEL)
+ "%13.11"
+#elif defined(PERL_SUBVERSION) && (PERL_SUBVERSION > 0)
"%8.6"
#else
"%5.3"
diff -ru perl-current/lib/h2xs.t perl-hack/lib/h2xs.t
--- perl-current/lib/h2xs.t 2003-08-12 02:46:53.000000000 -0700
+++ perl-hack/lib/h2xs.t 2003-10-17 03:39:17.000000000 -0700
@@ -50,9 +50,13 @@
my $name = 'h2xst';
my $header = "$name.h";
my $thisversion = sprintf "%vd", $^V;
+$thisversion =~ s/\.\d+$// if ($thisversion =~ tr/.//) == 3; # drop patchlevel
+my $thisversion_num = $];
+$thisversion_num =~ s/^(\d+\.\d{6})\d+/$1/ && # drop patchlevel
+ $thisversion_num =~ s/000$//; # drop subsubversion
my @tests = (
-"-f -n $name", $], <<"EOXSFILES",
+"-f -n $name", $thisversion_num, <<"EOXSFILES",
Defaulting to backwards compatibility with perl $thisversion
If you intend this module to be compatible with earlier perl versions, please
specify a minimum perl version with the -b option.
@@ -69,7 +73,7 @@
Writing $name/MANIFEST
EOXSFILES
-"-f -n $name -b $thisversion", $], <<"EOXSFILES",
+"-f -n $name -b $thisversion", $thisversion_num, <<"EOXSFILES",
Writing $name/ppport.h
Writing $name/lib/$name.pm
Writing $name/$name.xs
@@ -108,7 +112,7 @@
Writing $name/MANIFEST
EOXSFILES
-"\"-X\" -f -n $name -b $thisversion", $], <<"EONOXSFILES",
+"\"-X\" -f -n $name -b $thisversion", $thisversion_num, <<"EONOXSFILES",
Writing $name/lib/$name.pm
Writing $name/Makefile.PL
Writing $name/README
@@ -117,7 +121,7 @@
Writing $name/MANIFEST
EONOXSFILES
-"-f -n $name $header -b $thisversion", $], <<"EOXSFILES",
+"-f -n $name $header -b $thisversion", $thisversion_num, <<"EOXSFILES",
Writing $name/ppport.h
Writing $name/lib/$name.pm
Writing $name/$name.xs
diff -ru perl-current/lib/Pod/Man.pm perl-hack/lib/Pod/Man.pm
--- perl-current/lib/Pod/Man.pm 2003-03-31 03:17:12.000000000 -0800
+++ perl-hack/lib/Pod/Man.pm 2003-10-17 03:53:26.000000000 -0700
@@ -330,7 +330,7 @@
# Work a little magic to handle subversions correctly under both the
# pre-5.6 and the post-5.6 version numbering schemes.
if (!defined $$self{release}) {
- my @version = ($] =~ /^(\d+)\.(\d{3})(\d{0,3})$/);
+ my @version = ($] =~ /^(\d+)\.(\d{3})(\d{0,3})/);
$version[2] ||= 0;
$version[2] *= 10 ** (3 - length $version[2]);
for (@version) { $_ += 0 }
diff -ru perl-current/perl.c perl-hack/perl.c
--- perl-current/perl.c 2003-10-16 15:25:43.000000000 -0700
+++ perl-hack/perl.c 2003-10-17 02:14:32.000000000 -0700
@@ -220,6 +220,14 @@
SvNVX(PL_patchlevel) = (NV)PERL_REVISION +
((NV)PERL_VERSION / (NV)1000) +
((NV)PERL_SUBVERSION / (NV)1000000);
+#if defined(PERL_PATCHLEVEL)
+ SvGROW(PL_patchlevel, SvCUR(PL_patchlevel) + UTF8_MAXLEN + 1);
+ s = SvEND(PL_patchlevel);
+ s = uvchr_to_utf8(s, (UV)PERL_PATCHLEVEL);
+ *s = '\0';
+ SvCUR_set(PL_patchlevel, s - (U8*)SvPVX(PL_patchlevel));
+ SvNVX(PL_patchlevel) += (NV)PERL_PATCHLEVEL / (NV)100000000000;
+#endif
SvNOK_on(PL_patchlevel); /* dual valued */
SvUTF8_on(PL_patchlevel);
SvREADONLY_on(PL_patchlevel);
diff -ru perl-current/t/op/ver.t perl-hack/t/op/ver.t
--- perl-current/t/op/ver.t 2003-07-09 02:07:13.000000000 -0700
+++ perl-hack/t/op/ver.t 2003-10-17 02:36:54.000000000 -0700
@@ -203,13 +203,15 @@
is(v200, eval("+v200"), 'v200 eq eval("+v200")' );
# Tests for string/numeric value of $] itself
-my ($revision,$version,$subversion) = split '\.', sprintf("%vd",$^V);
+my ($revision,$version,$subversion,$patchlevel) = split '\.', sprintf("%vd",$^V);
print "# revision = '$revision'\n";
print "# version = '$version'\n";
print "# subversion = '$subversion'\n";
+print "# patchlevel = '$patchlevel'\n" if defined $patchlevel;
my $v = sprintf("%d.%.3d%.3d",$revision,$version,$subversion);
+$v .= sprintf("%.5d",$patchlevel) if defined $patchlevel;
print "# v = '$v'\n";
print "# ] = '$]'\n";
@@ -221,6 +223,7 @@
ok( $v eq "$]", qq{\$^V eq "\$]"});
$v = $revision + $version/1000 + $subversion/1000000;
+$v += $patchlevel / 100000000000 if $patchlevel;
ok( $v == $], "\$^V == \$] (numeric)" );
diff -ru perl-current/utils/h2xs.PL perl-hack/utils/h2xs.PL
--- perl-current/utils/h2xs.PL 2003-08-13 11:31:22.000000000 -0700
+++ perl-hack/utils/h2xs.PL 2003-10-17 03:38:38.000000000 -0700
@@ -496,6 +496,8 @@
my $TEMPLATE_VERSION = '0.01';
my @ARGS = @ARGV;
my $compat_version = $];
+$compat_version =~ s/^(\d+\.\d{6})\d+/$1/ && # drop patchlevel
+ $compat_version =~ s/000$//; # drop subsubversion
use Getopt::Long;
use Config;
Thread Previous
|
Thread Next