anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / interpreters / perl / cross.patch
blobe0f05ede90d02e50c84df6fb57737f6db18845b1
1 From: =?UTF-8?q?Christian=20K=C3=B6gler?= <ck3d@gmx.de>
2 Date: Mon, 10 Apr 2023 22:12:24 +0200
3 Subject: [PATCH] miniperl compatible modules
5 CPAN::Meta
6 ExtUtils::MakeMaker
7 JSON::PP
8 Data::Dumper
10 Updated for perl v5.38.0 by stig@stig.io
12 ---
14 diff --git a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
15 index b0e83b0d2d..dab4907704 100644
16 --- a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
17 +++ b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
18 @@ -86,21 +86,7 @@ sub new {
19 # from version::vpp
20 sub _find_magic_vstring {
21 my $value = shift;
22 - my $tvalue = '';
23 - require B;
24 - my $sv = B::svref_2object(\$value);
25 - my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef;
26 - while ( $magic ) {
27 - if ( $magic->TYPE eq 'V' ) {
28 - $tvalue = $magic->PTR;
29 - $tvalue =~ s/^v?(.+)$/v$1/;
30 - last;
31 - }
32 - else {
33 - $magic = $magic->MOREMAGIC;
34 - }
35 - }
36 - return $tvalue;
37 + return version::->parse($value)->stringify;
40 # safe if given an unblessed reference
41 diff --git a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
42 index 746abd63bc..c55d7cd2d0 100644
43 --- a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
44 +++ b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
45 @@ -1,6 +1,7 @@
46 use 5.008001; # sane UTF-8 support
47 use strict;
48 use warnings;
49 +no warnings 'experimental::builtin';
50 package CPAN::Meta::YAML; # git description: v1.68-2-gcc5324e
51 # XXX-INGY is 5.8.1 too old/broken for utf8?
52 # XXX-XDG Lancaster consensus was that it was sufficient until
53 @@ -650,27 +651,29 @@ sub _dump_string {
54 join '', map { "$_\n" } @lines;
57 -sub _has_internal_string_value {
58 +# taken from cpan/JSON-PP/lib/JSON/PP.pm
59 +sub _looks_like_number {
60 my $value = shift;
61 - my $b_obj = B::svref_2object(\$value); # for round trip problem
62 - return $b_obj->FLAGS & B::SVf_POK();
63 + no warnings 'numeric';
64 + # if the utf8 flag is on, it almost certainly started as a string
65 + return if utf8::is_utf8($value);
66 + # detect numbers
67 + # string & "" -> ""
68 + # number & "" -> 0 (with warning)
69 + # nan and inf can detect as numbers, so check with * 0
70 + return unless length((my $dummy = "") & $value);
71 + return unless 0 + $value eq $value;
72 + return 1 if $value * 0 == 0;
73 + return -1; # inf/nan
76 sub _dump_scalar {
77 my $string = $_[1];
78 my $is_key = $_[2];
79 - # Check this before checking length or it winds up looking like a string!
80 - my $has_string_flag = _has_internal_string_value($string);
81 return '~' unless defined $string;
82 return "''" unless length $string;
83 - if (Scalar::Util::looks_like_number($string)) {
84 - # keys and values that have been used as strings get quoted
85 - if ( $is_key || $has_string_flag ) {
86 - return qq['$string'];
87 - }
88 - else {
89 - return $string;
90 - }
91 + if (_looks_like_number($string)) {
92 + return qq['$string'];
94 if ( $string =~ /[\x00-\x09\x0b-\x0d\x0e-\x1f\x7f-\x9f\'\n]/ ) {
95 $string =~ s/\\/\\\\/g;
96 @@ -800,9 +803,6 @@ sub errstr {
97 # Helper functions. Possibly not needed.
100 -# Use to detect nv or iv
101 -use B;
103 # XXX-INGY Is flock CPAN::Meta::YAML's responsibility?
104 # Some platforms can't flock :-(
105 # XXX-XDG I think it is. When reading and writing files, we ought
106 @@ -822,35 +822,8 @@ sub _can_flock {
111 -# XXX-INGY Is this core in 5.8.1? Can we remove this?
112 -# XXX-XDG Scalar::Util 1.18 didn't land until 5.8.8, so we need this
113 -#####################################################################
114 -# Use Scalar::Util if possible, otherwise emulate it
116 -use Scalar::Util ();
117 BEGIN {
118 - local $@;
119 - if ( eval { Scalar::Util->VERSION(1.18); } ) {
120 - *refaddr = *Scalar::Util::refaddr;
122 - else {
123 - eval <<'END_PERL';
124 -# Scalar::Util failed to load or too old
125 -sub refaddr {
126 - my $pkg = ref($_[0]) or return undef;
127 - if ( !! UNIVERSAL::can($_[0], 'can') ) {
128 - bless $_[0], 'Scalar::Util::Fake';
129 - } else {
130 - $pkg = undef;
132 - "$_[0]" =~ /0x(\w+)/;
133 - my $i = do { no warnings 'portable'; hex $1 };
134 - bless $_[0], $pkg if defined $pkg;
135 - $i;
137 -END_PERL
139 + *refaddr = *builtin::refaddr;
142 delete $CPAN::Meta::YAML::{refaddr};
143 diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm
144 index 3604eae402..991f69d275 100644
145 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm
146 +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm
147 @@ -1,12 +1,13 @@
148 use strict;
149 use warnings;
150 +no warnings 'experimental::builtin';
152 package CPAN::Meta::Merge;
154 our $VERSION = '2.150010';
156 use Carp qw/croak/;
157 -use Scalar::Util qw/blessed/;
158 +use builtin qw/blessed/;
159 use CPAN::Meta::Converter 2.141170;
161 sub _is_identical {
162 diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm
163 index d4e93fd8a5..809da68d02 100644
164 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm
165 +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm
166 @@ -1,6 +1,7 @@
167 use 5.006;
168 use strict;
169 use warnings;
170 +no warnings 'experimental::builtin';
171 package CPAN::Meta::Prereqs;
173 our $VERSION = '2.150010';
174 @@ -14,7 +15,6 @@ our $VERSION = '2.150010';
175 #pod =cut
177 use Carp qw(confess);
178 -use Scalar::Util qw(blessed);
179 use CPAN::Meta::Requirements 2.121;
181 #pod =method new
182 @@ -168,7 +168,12 @@ sub types_in {
183 sub with_merged_prereqs {
184 my ($self, $other) = @_;
186 - my @other = blessed($other) ? $other : @$other;
187 + eval 'require Scalar::Util';
188 + my @other = unless($@){
189 + Scalar::Util::blessed($other) ? $other : @$other;
190 + }else{
191 + builtin::blessed($other) ? $other : @$other;
194 my @prereq_objs = ($self, @other);
196 diff --git a/cpan/JSON-PP/lib/JSON/PP.pm b/cpan/JSON-PP/lib/JSON/PP.pm
197 index fc8fcbc8f0..cda7b90c65 100644
198 --- a/cpan/JSON-PP/lib/JSON/PP.pm
199 +++ b/cpan/JSON-PP/lib/JSON/PP.pm
200 @@ -4,6 +4,7 @@ package JSON::PP;
202 use 5.008;
203 use strict;
204 +no warnings 'experimental::builtin';
206 use Exporter ();
207 BEGIN { our @ISA = ('Exporter') }
208 diff --git a/dist/Data-Dumper/Dumper.pm b/dist/Data-Dumper/Dumper.pm
209 index bb6d3caedb..0c2fde4743 100644
210 --- a/dist/Data-Dumper/Dumper.pm
211 +++ b/dist/Data-Dumper/Dumper.pm
212 @@ -11,6 +11,7 @@ package Data::Dumper;
214 use strict;
215 use warnings;
216 +no warnings 'experimental::builtin';
218 #$| = 1;
220 @@ -125,8 +126,7 @@ sub new {
221 # Packed numeric addresses take less memory. Plus pack is faster than sprintf
223 sub format_refaddr {
224 - require Scalar::Util;
225 - pack "J", Scalar::Util::refaddr(shift);
226 + pack "J", builtin::refaddr(shift);
230 @@ -282,9 +282,8 @@ sub _dump {
231 warn "WARNING(Freezer method call failed): $@" if $@;
234 - require Scalar::Util;
235 - my $realpack = Scalar::Util::blessed($val);
236 - my $realtype = $realpack ? Scalar::Util::reftype($val) : ref $val;
237 + my $realpack = builtin::blessed($val);
238 + my $realtype = $realpack ? builtin::reftype($val) : ref $val;
239 $id = format_refaddr($val);
241 # Note: By this point $name is always defined and of non-zero length.
242 @@ -576,7 +575,7 @@ sub _dump {
243 # here generates a different result. So there are actually "three" different
244 # implementations of Data::Dumper (kind of sort of) but we only test two.
245 elsif (!defined &_vstring
246 - and ref $ref eq 'VSTRING' || eval{Scalar::Util::isvstring($val)}) {
247 + and ref $ref eq 'VSTRING') {
248 $out .= sprintf "v%vd", $val;
250 # \d here would treat "1\x{660}" as a safe decimal number