line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
91
|
|
|
|
|
|
SV* _scalar_type(SV* argument) { |
6
|
|
|
|
|
|
|
SV* rval; |
7
|
|
|
|
|
|
|
static char num_as_str[100]; /* potential buffer overflow on 256-bit machines :-) */ |
8
|
|
|
|
|
|
|
|
9
|
91
|
100
|
|
|
|
|
if(SvIOK(argument)) { |
10
|
24
|
100
|
|
|
|
|
if(SvPOK(argument)) { |
11
|
|
|
|
|
|
|
/* int is also a string, better see if it's not int-ified 007 */ |
12
|
5
|
100
|
|
|
|
|
sprintf( |
|
|
100
|
|
|
|
|
|
13
|
|
|
|
|
|
|
num_as_str, |
14
|
5
|
|
|
|
|
|
(SvIsUV(argument) ? "%" UVuf : "%" IVdf), |
15
|
10
|
|
|
|
|
|
(SvIsUV(argument) ? SvUVX(argument) : SvIVX(argument)) |
16
|
|
|
|
|
|
|
); |
17
|
5
|
|
|
|
|
|
rval = ( |
18
|
5
|
|
|
|
|
|
(strcmp(SvPVX(argument), num_as_str)) == 0 |
19
|
|
|
|
|
|
|
? newSVpv("INTEGER", 7) |
20
|
5
|
100
|
|
|
|
|
: newSVpv("SCALAR", 6) |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} else { |
23
|
24
|
|
|
|
|
|
rval = newSVpv("INTEGER", 7); |
24
|
|
|
|
|
|
|
} |
25
|
67
|
100
|
|
|
|
|
} else if(SvNOK(argument)) { |
26
|
46
|
100
|
|
|
|
|
if(SvPOK(argument)) { |
27
|
|
|
|
|
|
|
/* float is also a string, better see if it's not float-ified 007.5 */ |
28
|
4
|
|
|
|
|
|
sprintf(num_as_str, "%" NVgf, SvNVX(argument)); |
29
|
4
|
|
|
|
|
|
rval = ( |
30
|
4
|
|
|
|
|
|
(strcmp(SvPVX(argument), num_as_str)) == 0 |
31
|
|
|
|
|
|
|
? newSVpv("NUMBER", 6) |
32
|
4
|
100
|
|
|
|
|
: newSVpv("SCALAR", 6) |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} else { |
35
|
46
|
|
|
|
|
|
rval = newSVpv("NUMBER", 6); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} else { |
38
|
21
|
|
|
|
|
|
rval = newSVpv("SCALAR", 6); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
91
|
|
|
|
|
|
return rval; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
MODULE = Scalar::Type PACKAGE = Scalar::Type |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
SV * |
50
|
|
|
|
|
|
|
_scalar_type (argument) |
51
|
|
|
|
|
|
|
SV * argument |
52
|
|
|
|
|
|
|
|