| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* vi: set ft=c : */ |
|
2
|
|
|
|
|
|
|
#ifndef sv_numcmp_flags |
|
3
|
|
|
|
|
|
|
# define sv_numcmp_flags(lhs, rhs, flags) S_sv_numcmp_flags(aTHX_ lhs, rhs, flags) |
|
4
|
30
|
|
|
|
|
|
static int S_sv_numcmp_flags(pTHX_ SV *lhs, SV *rhs, U32 flags) |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
30
|
50
|
|
|
|
|
if(flags & SV_GMAGIC) { |
|
7
|
0
|
0
|
|
|
|
|
if(lhs) |
|
8
|
0
|
|
|
|
|
|
SvGETMAGIC(lhs); |
|
9
|
0
|
0
|
|
|
|
|
if(rhs) |
|
10
|
0
|
|
|
|
|
|
SvGETMAGIC(rhs); |
|
11
|
|
|
|
|
|
|
} |
|
12
|
30
|
50
|
|
|
|
|
if(!lhs) |
|
13
|
|
|
|
|
|
|
lhs = &PL_sv_undef; |
|
14
|
30
|
50
|
|
|
|
|
if(!rhs) |
|
15
|
|
|
|
|
|
|
rhs = &PL_sv_undef; |
|
16
|
|
|
|
|
|
|
|
|
17
|
30
|
50
|
|
|
|
|
if (!(flags & SV_SKIP_OVERLOAD) && (SvAMAGIC(lhs) || SvAMAGIC(rhs))) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
SV *ret = amagic_call(lhs, rhs, ncmp_amg, 0); |
|
19
|
0
|
0
|
|
|
|
|
if (ret) |
|
20
|
0
|
|
|
|
|
|
return SvIV(ret); /* Assume return value is -1, 0, or 1 */ |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
/* We'd like to call Perl_do_ncmp, except that isn't an exported API function */ |
|
24
|
|
|
|
|
|
|
#ifndef HAVE_BOOL_SvIV_please_nomg |
|
25
|
|
|
|
|
|
|
/* Before perl 5.18, SvIV_please_nomg() was void-returning */ |
|
26
|
30
|
100
|
|
|
|
|
SvIV_please_nomg(lhs); |
|
|
|
50
|
|
|
|
|
|
|
27
|
30
|
100
|
|
|
|
|
SvIV_please_nomg(rhs); |
|
|
|
50
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#endif |
|
29
|
30
|
|
|
|
|
|
if( |
|
30
|
|
|
|
|
|
|
#ifdef HAVE_BOOL_SvIV_please_nomg |
|
31
|
|
|
|
|
|
|
SvIV_please_nomg(rhs) && SvIV_please_nomg(lhs) |
|
32
|
|
|
|
|
|
|
#else |
|
33
|
30
|
100
|
|
|
|
|
SvIOK(lhs) && SvIOK(rhs) |
|
|
|
50
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#endif |
|
35
|
|
|
|
|
|
|
) { |
|
36
|
|
|
|
|
|
|
/* Compare as integers */ |
|
37
|
36
|
50
|
|
|
|
|
switch((SvUOK(lhs) ? 1 : 0) | (SvUOK(rhs) ? 2 : 0)) { |
|
38
|
18
|
|
|
|
|
|
case 0: /* IV <=> IV */ |
|
39
|
18
|
|
|
|
|
|
return (SvIVX(lhs) > SvIVX(rhs)) - (SvIVX(lhs) < SvIVX(rhs)); |
|
40
|
0
|
|
|
|
|
|
case 1: /* UV <=> IV */ |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
|
const IV riv = SvUVX(rhs); |
|
43
|
0
|
0
|
|
|
|
|
if(riv < 0) |
|
44
|
|
|
|
|
|
|
return 1; |
|
45
|
0
|
|
|
|
|
|
return (SvUVX(lhs) > riv) - (SvUVX(lhs) < riv); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
0
|
|
|
|
|
|
case 2: /* IV <=> UV */ |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
0
|
|
|
|
|
|
const IV liv = SvUVX(lhs); |
|
50
|
0
|
0
|
|
|
|
|
if(liv < 0) |
|
51
|
|
|
|
|
|
|
return -1; |
|
52
|
0
|
|
|
|
|
|
return (liv > SvUVX(rhs)) - (liv < SvUVX(rhs)); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
|
|
|
|
|
case 3: /* UV <=> UV */ |
|
55
|
0
|
|
|
|
|
|
return (SvUVX(lhs) > SvUVX(rhs)) - (SvUVX(lhs) < SvUVX(rhs)); |
|
56
|
|
|
|
|
|
|
default: |
|
57
|
|
|
|
|
|
|
croak("unreachable"); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
else { |
|
61
|
|
|
|
|
|
|
/* Compare NVs */ |
|
62
|
12
|
|
|
|
|
|
NV const rnv = SvNV_nomg(rhs); |
|
63
|
12
|
|
|
|
|
|
NV const lnv = SvNV_nomg(lhs); |
|
64
|
12
|
|
|
|
|
|
return (lnv > rnv) - (lnv < rnv); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
#endif |
|
68
|
|
|
|
|
|
|
#ifndef sv_numcmp |
|
69
|
|
|
|
|
|
|
# define sv_numcmp(lhs, rhs) sv_numcmp_flags(lhs, rhs, 0) |
|
70
|
|
|
|
|
|
|
#endif |