CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 27 Jul 2025 15:24:39 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20220126212658
location: https://web.archive.org/web/20220126212658/https://perl5.git.perl.org/perl5.git/commitdiff/HEAD
server-timing: captures_list;dur=0.550764, exclusion.robots;dur=0.020389, exclusion.robots.policy;dur=0.009399, esindex;dur=0.013694, cdx.remote;dur=81.087563, LoadShardBlock;dur=131.658595, PetaboxLoader3.datanode;dur=51.439330
x-app-server: wwwb-app218
x-ts: 302
x-tr: 241
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app218; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 27 Jul 2025 15:24:42 GMT
content-type: application/xhtml+xml; charset=utf-8
x-archive-orig-date: Wed, 26 Jan 2022 21:26:58 GMT
x-archive-orig-server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
x-archive-orig-keep-alive: timeout=5, max=100
x-archive-orig-connection: Keep-Alive
x-archive-orig-x-crawler-transfer-encoding: chunked
x-archive-orig-content-length: 16422
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Wed, 26 Jan 2022 21:26:58 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sun, 17 Jan 2021 10:11:08 GMT", ; rel="prev memento"; datetime="Sun, 17 Jan 2021 10:11:08 GMT", ; rel="memento"; datetime="Wed, 26 Jan 2022 21:26:58 GMT", ; rel="next memento"; datetime="Mon, 30 Jan 2023 01:44:02 GMT", ; rel="last memento"; datetime="Mon, 30 Jan 2023 01:44:02 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: CC-MAIN-2022-05-1642320304961.89-0014/CC-MAIN-20220126192506-20220126222506-00280.warc.gz
server-timing: captures_list;dur=0.697436, exclusion.robots;dur=0.022886, exclusion.robots.policy;dur=0.010861, esindex;dur=0.013536, cdx.remote;dur=1621.443087, LoadShardBlock;dur=114.252200, PetaboxLoader3.datanode;dur=123.334546, load_resource;dur=176.469442, PetaboxLoader3.resolve;dur=131.120071
x-app-server: wwwb-app218
x-ts: 200
x-tr: 1975
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
perl5.git.perl.org Git - perl5.git/commitdiff
This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1dd43bc)
raw | patch | inline | side by side (parent: 1dd43bc)
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | |
Tue, 14 Sep 2021 20:30:42 +0000 (21:30 +0100) | ||
committer | Paul Evans <leonerd@leonerd.org.uk> | |
Wed, 26 Jan 2022 21:02:05 +0000 (21:02 +0000) |
ext/XS-APItest/Makefile.PL | patch | blob | blame | history | |
ext/XS-APItest/t/sv_numeq.t | patch | blob | blame | history | |
sv.c | patch | blob | blame | history |
G_SCALAR G_LIST G_VOID G_DISCARD G_EVAL G_NOARGS
G_KEEPERR G_NODEBUG G_METHOD G_FAKINGEVAL G_RETHROW
GV_NOADD_NOINIT
- SV_GMAGIC
+ SV_GMAGIC SV_SKIP_OVERLOAD
IS_NUMBER_IN_UV IS_NUMBER_GREATER_THAN_UV_MAX
IS_NUMBER_NOT_INT IS_NUMBER_NEG IS_NUMBER_INFINITY
IS_NUMBER_NAN IS_NUMBER_TRAILING PERL_SCAN_TRAILING
#!perl
-use Test::More tests => 6;
+use Test::More tests => 9;
use XS::APItest;
my $four = 4;
"10" =~ m/(\d+)/;
ok !sv_numeq_flags($1, 10, 0), 'sv_numeq_flags with no flags does not GETMAGIC';
ok sv_numeq_flags($1, 10, SV_GMAGIC), 'sv_numeq_flags with SV_GMAGIC does';
+
+# overloading
+{
+ package AlwaysTen {
+ use overload
+ '==' => sub { return $_[1] == 10 },
+ '0+' => sub { 123456 };
+ }
+
+ ok sv_numeq(bless([], "AlwaysTen"), 10), 'AlwaysTen is 10';
+ ok !sv_numeq(bless([], "AlwaysTen"), 11), 'AlwaysTen is not 11';
+
+ ok !sv_numeq_flags(bless([], "AlwaysTen"), 10, SV_SKIP_OVERLOAD), 'AlwaysTen is not 10 with SV_SKIP_OVERLOAD'
+}
--- a/sv.c
+++ b/sv.c
get-magic too. Will coerce its args to numbers if necessary. Treats
C<NULL> as undef.
+If flags does not have the C<SV_SKIP_OVERLOAD> set, an attempt to use C<==>
+overloading will be made. If such overloading does not exist or the flag is
+set, then regular numerical comparison will be used instead.
+
=for apidoc sv_numeq
A convenient shortcut for calling C<sv_numeq_flags> with the C<SV_GMAGIC>
if(!sv2)
sv2 = &PL_sv_undef;
+ if(!(flags & SV_SKIP_OVERLOAD) &&
+ (SvAMAGIC(sv1) || SvAMAGIC(sv2))) {
+ SV *ret = amagic_call(sv1, sv2, eq_amg, 0);
+ if(ret)
+ return SvTRUE(ret);
+ }
+
return do_ncmp(sv1, sv2) == 0;
}