import perl-constant-1.33-461.el9

c9 imports/c9/perl-constant-1.33-461.el9
CentOS Sources 3 years ago committed by MSVSphere Packaging Team
commit f081cbc5c9

1
.gitignore vendored

@ -0,0 +1 @@
SOURCES/constant-1.27.tar.gz

@ -0,0 +1 @@
54223c06f492cd9fff118d8613b973c524df13f6 SOURCES/constant-1.27.tar.gz

@ -0,0 +1,334 @@
diff -up constant-1.27/lib/constant.pm.127 constant-1.27/lib/constant.pm
--- constant-1.27/lib/constant.pm.127 2015-04-27 13:39:46.613767559 +0200
+++ constant-1.27/lib/constant.pm 2015-01-27 23:47:42.000000000 +0100
@@ -3,8 +3,8 @@ use 5.008;
use strict;
use warnings::register;
-use vars qw($VERSION %declared);
-$VERSION = '1.27';
+our $VERSION = '1.33';
+our %declared;
#=======================================================================
@@ -24,13 +24,24 @@ my $boolean = qr/^[01]?\z/;
BEGIN {
# We'd like to do use constant _CAN_PCS => $] > 5.009002
# but that's a bit tricky before we load the constant module :-)
- # By doing this, we save 1 run time check for *every* call to import.
- no strict 'refs';
+ # By doing this, we save several run time checks for *every* call
+ # to import.
my $const = $] > 5.009002;
- *_CAN_PCS = sub () {$const};
-
my $downgrade = $] < 5.015004; # && $] >= 5.008
- *_DOWNGRADE = sub () { $downgrade };
+ my $constarray = exists &_make_const;
+ if ($const) {
+ Internals::SvREADONLY($const, 1);
+ Internals::SvREADONLY($downgrade, 1);
+ $constant::{_CAN_PCS} = \$const;
+ $constant::{_DOWNGRADE} = \$downgrade;
+ $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray;
+ }
+ else {
+ no strict 'refs';
+ *{"_CAN_PCS"} = sub () {$const};
+ *{"_DOWNGRADE"} = sub () { $downgrade };
+ *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray };
+ }
}
#=======================================================================
@@ -46,13 +57,13 @@ sub import {
return unless @_; # Ignore 'use constant;'
my $constants;
my $multiple = ref $_[0];
- my $pkg = caller;
+ my $caller = caller;
my $flush_mro;
my $symtab;
if (_CAN_PCS) {
no strict 'refs';
- $symtab = \%{$pkg . '::'};
+ $symtab = \%{$caller . '::'};
};
if ( $multiple ) {
@@ -70,6 +81,20 @@ sub import {
}
foreach my $name ( keys %$constants ) {
+ my $pkg;
+ my $symtab = $symtab;
+ my $orig_name = $name;
+ if ($name =~ s/(.*)(?:::|')(?=.)//s) {
+ $pkg = $1;
+ if (_CAN_PCS && $pkg ne $caller) {
+ no strict 'refs';
+ $symtab = \%{$pkg . '::'};
+ }
+ }
+ else {
+ $pkg = $caller;
+ }
+
# Normal constant name
if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# Everything is okay
@@ -117,7 +142,7 @@ sub import {
my $full_name = "${pkg}::$name";
$declared{$full_name}++;
if ($multiple || @_ == 1) {
- my $scalar = $multiple ? $constants->{$name} : $_[0];
+ my $scalar = $multiple ? $constants->{$orig_name} : $_[0];
if (_DOWNGRADE) { # for 5.8 to 5.14
# Work around perl bug #31991: Sub names (actually glob
@@ -128,27 +153,50 @@ sub import {
# The constant serves to optimise this entire block out on
# 5.8 and earlier.
- if (_CAN_PCS && $symtab && !exists $symtab->{$name}) {
- # No typeglob yet, so we can use a reference as space-
- # efficient proxy for a constant subroutine
+ if (_CAN_PCS) {
+ # Use a reference as a proxy for a constant subroutine.
+ # If this is not a glob yet, it saves space. If it is
+ # a glob, we must still create it this way to get the
+ # right internal flags set, as constants are distinct
+ # from subroutines created with sub(){...}.
# The check in Perl_ck_rvconst knows that inlinable
# constants from cv_const_sv are read only. So we have to:
Internals::SvREADONLY($scalar, 1);
- $symtab->{$name} = \$scalar;
- ++$flush_mro;
+ if (!exists $symtab->{$name}) {
+ $symtab->{$name} = \$scalar;
+ ++$flush_mro->{$pkg};
+ }
+ else {
+ local $constant::{_dummy} = \$scalar;
+ *$full_name = \&{"_dummy"};
+ }
} else {
*$full_name = sub () { $scalar };
}
} elsif (@_) {
my @list = @_;
- *$full_name = sub () { @list };
+ if (_CAN_PCS_FOR_ARRAY) {
+ _make_const($list[$_]) for 0..$#list;
+ _make_const(@list);
+ if (!exists $symtab->{$name}) {
+ $symtab->{$name} = \@list;
+ $flush_mro->{$pkg}++;
+ }
+ else {
+ local $constant::{_dummy} = \@list;
+ *$full_name = \&{"_dummy"};
+ }
+ }
+ else { *$full_name = sub () { @list }; }
} else {
*$full_name = sub () { };
}
}
}
# Flush the cache exactly once if we make any direct symbol table changes.
- mro::method_changed_in($pkg) if _CAN_PCS && $flush_mro;
+ if (_CAN_PCS && $flush_mro) {
+ mro::method_changed_in($_) for keys %$flush_mro;
+ }
}
1;
@@ -190,7 +238,7 @@ This pragma allows you to declare consta
When you declare a constant such as C<PI> using the method shown
above, each machine your script runs upon can have as many digits
-of accuracy as it can use. Also, your program will be easier to
+of accuracy as it can use. Also, your program will be easier to
read, more likely to be maintained (and maintained correctly), and
far less likely to send a space probe to the wrong planet because
nobody noticed the one equation in which you wrote C<3.14195>.
@@ -203,7 +251,7 @@ away if the constant is false.
=head1 NOTES
As with all C<use> directives, defining a constant happens at
-compile time. Thus, it's probably not correct to put a constant
+compile time. Thus, it's probably not correct to put a constant
declaration inside of a conditional statement (like C<if ($foo)
{ use constant ... }>).
@@ -221,10 +269,6 @@ point to data which may be changed, as t
ARRAY->[1] = " be changed";
print ARRAY->[1];
-Dereferencing constant references incorrectly (such as using an array
-subscript on a constant hash reference, or vice versa) will be trapped at
-compile time.
-
Constants belong to the package they are defined in. To refer to a
constant defined in another package, specify the full package name, as
in C<Some::Package::CONSTANT>. Constants may be exported by modules,
@@ -233,11 +277,18 @@ as C<< Some::Package->CONSTANT >> or as
C<$obj> is an instance of C<Some::Package>. Subclasses may define
their own constants to override those in their base class.
+As of version 1.32 of this module, constants can be defined in packages
+other than the caller, by including the package name in the name of the
+constant:
+
+ use constant "OtherPackage::FWIBBLE" => 7865;
+ constant->import("Other::FWOBBLE",$value); # dynamically at run time
+
The use of all caps for constant names is merely a convention,
although it is recommended in order to make constants stand out
and to help avoid collisions with other barewords, keywords, and
-subroutine names. Constant names must begin with a letter or
-underscore. Names beginning with a double underscore are reserved. Some
+subroutine names. Constant names must begin with a letter or
+underscore. Names beginning with a double underscore are reserved. Some
poor choices for names will generate warnings, if warnings are enabled at
compile time.
@@ -312,15 +363,15 @@ constants without any problems.
=head1 TECHNICAL NOTES
In the current implementation, scalar constants are actually
-inlinable subroutines. As of version 5.004 of Perl, the appropriate
+inlinable subroutines. As of version 5.004 of Perl, the appropriate
scalar constant is inserted directly in place of some subroutine
-calls, thereby saving the overhead of a subroutine call. See
+calls, thereby saving the overhead of a subroutine call. See
L<perlsub/"Constant Functions"> for details about how and when this
happens.
In the rare case in which you need to discover at run time whether a
particular constant has been declared via this module, you may use
-this function to examine the hash C<%constant::declared>. If the given
+this function to examine the hash C<%constant::declared>. If the given
constant name does not include a package name, the current package is
used.
@@ -335,11 +386,12 @@ used.
=head1 CAVEATS
-In the current version of Perl, list constants are not inlined
-and some symbols may be redefined without generating a warning.
+List constants are not inlined unless you are using Perl v5.20 or higher.
+In v5.20 or higher, they are still not read-only, but that may change in
+future versions.
It is not possible to have a subroutine or a keyword with the same
-name as a constant in the same package. This is probably a Good Thing.
+name as a constant in the same package. This is probably a Good Thing.
A constant with a name in the list C<STDIN STDOUT STDERR ARGV ARGVOUT
ENV INC SIG> is not allowed anywhere but in package C<main::>, for
diff -up constant-1.27/t/constant.t.127 constant-1.27/t/constant.t
--- constant-1.27/t/constant.t.127 2013-03-21 01:48:49.000000000 +0100
+++ constant-1.27/t/constant.t 2015-01-24 16:02:08.000000000 +0100
@@ -9,7 +9,7 @@ END { @warnings && print STDERR join "\n
use strict;
-use Test::More tests => 96;
+use Test::More tests => 109;
my $TB = Test::More->builder;
BEGIN { use_ok('constant'); }
@@ -122,7 +122,7 @@ print $output CCODE->($curr_test+4);
$TB->current_test($curr_test+4);
eval q{ CCODE->{foo} };
-ok scalar($@ =~ /^Constant is not a HASH/);
+ok scalar($@ =~ /^Constant is not a HASH|Not a HASH reference/);
# Allow leading underscore
@@ -346,3 +346,78 @@ $kloong = 'schlozhauer';
eval 'use constant undef, 5; 1';
like $@, qr/\ACan't use undef as constant name at /;
}
+
+# Constants created by "use constant" should be read-only
+
+# This test will not test what we are trying to test if this glob entry
+# exists already, so test that, too.
+ok !exists $::{immutable};
+eval q{
+ use constant immutable => 23987423874;
+ for (immutable) { eval { $_ = 22 } }
+ like $@, qr/^Modification of a read-only value attempted at /,
+ 'constant created in empty stash slot is immutable';
+ eval { for (immutable) { ${\$_} = 432 } };
+ SKIP: {
+ require Config;
+ if ($Config::Config{useithreads}) {
+ skip "fails under threads", 1 if $] < 5.019003;
+ }
+ like $@, qr/^Modification of a read-only value attempted at /,
+ '... and immutable through refgen, too';
+ }
+};
+() = \&{"immutable"}; # reify
+eval 'for (immutable) { $_ = 42 }';
+like $@, qr/^Modification of a read-only value attempted at /,
+ '... and after reification';
+
+# Use an existing stash element this time.
+# This next line is sufficient to trigger a different code path in
+# constant.pm.
+() = \%::existing_stash_entry;
+use constant existing_stash_entry => 23987423874;
+for (existing_stash_entry) { eval { $_ = 22 } }
+like $@, qr/^Modification of a read-only value attempted at /,
+ 'constant created in existing stash slot is immutable';
+eval { for (existing_stash_entry) { ${\$_} = 432 } };
+SKIP: {
+ if ($Config::Config{useithreads}) {
+ skip "fails under threads", 1 if $] < 5.019003;
+ }
+ like $@, qr/^Modification of a read-only value attempted at /,
+ '... and immutable through refgen, too';
+}
+
+# Test that list constants are also immutable. This only works under
+# 5.19.3 and later.
+SKIP: {
+ skip "fails under 5.19.2 and earlier", 3 if $] < 5.019003;
+ local $TODO = "disabled for now; breaks CPAN; see perl #119045";
+ use constant constant_list => 1..2;
+ for (constant_list) {
+ my $num = $_;
+ eval { $_++ };
+ like $@, qr/^Modification of a read-only value attempted at /,
+ "list constant has constant elements ($num)";
+ }
+ undef $TODO;
+ # Whether values are modifiable or no, modifying them should not affect
+ # future return values.
+ my @values;
+ for(1..2) {
+ for ((constant_list)[0]) {
+ push @values, $_;
+ eval {$_++};
+ }
+ }
+ is $values[1], $values[0],
+ 'modifying list const elements does not affect future retavls';
+}
+
+use constant { "tahi" => 1, "rua::rua" => 2, "toru'toru" => 3 };
+use constant "wha::wha" => 4;
+is tahi, 1, 'unqualified constant declared with constants in other pkgs';
+is rua::rua, 2, 'constant declared with ::';
+is toru::toru, 3, "constant declared with '";
+is wha::wha, 4, 'constant declared by itself with ::';
diff -up constant-1.27/t/utf8.t.127 constant-1.27/t/utf8.t

@ -0,0 +1,191 @@
# Run optional test
%if ! (0%{?rhel})
%bcond_without perl_constant_enables_optional_test
%else
%bcond_with perl_constant_enables_optional_test
%endif
%global cpan_version 1.27
Name: perl-constant
Version: 1.33
Release: 461%{?dist}
Summary: Perl pragma to declare constants
License: GPL+ or Artistic
URL: https://metacpan.org/release/constant
Source0: https://cpan.metacpan.org/authors/id/S/SA/SAPER/constant-%{cpan_version}.tar.gz
# Update to 1.33
Patch0: constant-1.33-update.patch
BuildArch: noarch
BuildRequires: make
BuildRequires: perl-interpreter
BuildRequires: perl-generators
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(strict)
# Run-time:
BuildRequires: perl(Carp)
BuildRequires: perl(vars)
BuildRequires: perl(warnings::register)
# Tests:
BuildRequires: perl(Test::More)
BuildRequires: perl(utf8)
BuildRequires: perl(warnings)
%if %{with perl_constant_enables_optional_test} && !%{defined perl_bootstrap}
# Optional tests:
BuildRequires: perl(Test::Pod) >= 1.14
BuildRequires: perl(Test::Pod::Coverage) >= 1.04
%endif
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
Requires: perl(Carp)
%description
This pragma allows you to declare constants at compile-time:
use constant PI => 4 * atan2(1, 1);
When you declare a constant such as "PI" using the method shown above,
each machine your script runs upon can have as many digits of accuracy
as it can use. Also, your program will be easier to read, more likely
to be maintained (and maintained correctly), and far less likely to
send a space probe to the wrong planet because nobody noticed the one
equation in which you wrote 3.14195.
When a constant is used in an expression, Perl replaces it with its
value at compile time, and may then optimize the expression further.
In particular, any code in an "if (CONSTANT)" block will be optimized
away if the constant is false.
%prep
%setup -q -n constant-%{cpan_version}
%patch0 -p1
%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}
%install
make pure_install DESTDIR=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
%{_fixperms} $RPM_BUILD_ROOT/*
%check
make test
%files
%doc Changes eg README
%{perl_vendorlib}/*
%{_mandir}/man3/*
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.33-461
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.33-460
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-459
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-458
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jun 26 2020 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-457
- Perl 5.32 re-rebuild of bootstrapped packages
* Mon Jun 22 2020 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-456
- Increase release to favour standalone package
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-441
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-440
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Jun 02 2019 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-439
- Perl 5.30 re-rebuild of bootstrapped packages
* Thu May 30 2019 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-438
- Increase release to favour standalone package
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-419
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-418
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sun Jul 01 2018 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-417
- Perl 5.28 re-rebuild of bootstrapped packages
* Tue Jun 26 2018 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-416
- Increase release to favour standalone package
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-396
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-395
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Wed Jun 07 2017 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-394
- Perl 5.26 re-rebuild of bootstrapped packages
* Sat Jun 03 2017 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-393
- Perl 5.26 rebuild
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-368
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed May 18 2016 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-367
- Perl 5.24 re-rebuild of bootstrapped packages
* Sat May 14 2016 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-365
- Increase release to favour standalone package
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.33-348
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.33-347
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Wed Jun 10 2015 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-346
- Perl 5.22 re-rebuild of bootstrapped packages
* Thu Jun 04 2015 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-345
- Increase release to favour standalone package
* Wed Jun 03 2015 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-336
- Perl 5.22 rebuild
* Mon May 04 2015 Jitka Plesnikova <jplesnik@redhat.com> - 1.33-335
- Patched to provide the version 1.33 which is bundled in Perl 5.22
* Tue Sep 09 2014 Jitka Plesnikova <jplesnik@redhat.com> - 1.31-310
- Patched to provide the version 1.31 which is bundled in Perl 5.20
* Mon Sep 08 2014 Jitka Plesnikova <jplesnik@redhat.com> - 1.27-295
- Perl 5.20 re-rebuild of bootstrapped packages
* Wed Aug 27 2014 Jitka Plesnikova <jplesnik@redhat.com> - 1.27-294
- Perl 5.20 rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.27-293
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed Aug 14 2013 Jitka Plesnikova <jplesnik@redhat.com> - 1.27-292
- Perl 5.18 re-rebuild of bootstrapped packages
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.27-291
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Mon Jul 15 2013 Petr Pisar <ppisar@redhat.com> - 1.27-290
- Increase release to favour standalone package
* Fri Jul 12 2013 Petr Pisar <ppisar@redhat.com> - 1.27-3
- Link minimal build-root packages against libperl.so explicitly
* Fri Jul 12 2013 Petr Pisar <ppisar@redhat.com> - 1.27-2
- Migrate to ExtUtils::MakeMaker
- Do not run optional tests at boot-strap
* Thu Mar 21 2013 Petr Pisar <ppisar@redhat.com> - 1.27-1
- Specfile autogenerated by cpanspec 1.78.
Loading…
Cancel
Save