line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ifndef EASYXS_NUMERIC_H |
2
|
|
|
|
|
|
|
#define EASYXS_NUMERIC_H 1 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include "init.h" |
5
|
|
|
|
|
|
|
|
6
|
19
|
|
|
|
|
|
UV _easyxs_SvUV (pTHX_ SV* sv) { |
7
|
19
|
50
|
|
|
|
|
if (!SvOK(sv)) _EASYXS_CROAK_UNDEF("unsigned integer"); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
19
|
50
|
|
|
|
|
if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv); |
10
|
|
|
|
|
|
|
|
11
|
19
|
50
|
|
|
|
|
if (SvUOK(sv)) return SvUV(sv); |
|
|
0
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
19
|
50
|
|
|
|
|
if (SvIOK(sv)) { |
14
|
19
|
50
|
|
|
|
|
IV myiv = SvIV(sv); |
15
|
|
|
|
|
|
|
|
16
|
19
|
50
|
|
|
|
|
if (myiv >= 0) return myiv; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
|
|
|
|
|
|
STRLEN pvlen; |
20
|
0
|
0
|
|
|
|
|
const char* pv = SvPVbyte(sv, pvlen); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
UV myuv; |
23
|
0
|
|
|
|
|
|
int grokked = grok_number(pv, pvlen, &myuv); |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if (grokked & (IS_NUMBER_IN_UV | !IS_NUMBER_NEG)) { |
26
|
0
|
|
|
|
|
|
const char* uvstr = form("%" UVuf, myuv); |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if (strlen(uvstr) == pvlen && strEQ(uvstr, pv)) return myuv; |
|
|
0
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
croak("`%" SVf "` given where unsigned integer expected!", sv); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#define exs_SvUV(sv) _easyxs_SvUV(aTHX_ sv) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#endif |