| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
|
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
3
|
|
|
|
|
|
|
#include "perl.h" |
|
4
|
|
|
|
|
|
|
#include "XSUB.h" |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#include "scalar_kind.h" |
|
7
|
|
|
|
|
|
|
|
|
8
|
2066
|
|
|
|
|
|
int looks_stringy(SV *val) { |
|
9
|
2066
|
50
|
|
|
|
|
return SvOK(val) && SvPOK(val) && !SvIOK(val) && !SvNOK(val); |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
/* "[+-]?digits" (no exponent, no decimal point). */ |
|
13
|
69
|
|
|
|
|
|
int looks_like_int_str(const char *s, STRLEN len) { |
|
14
|
69
|
|
|
|
|
|
STRLEN i = 0; |
|
15
|
69
|
50
|
|
|
|
|
if (len == 0) return 0; |
|
16
|
69
|
50
|
|
|
|
|
if (s[0] == '+' || s[0] == '-') i = 1; |
|
|
|
50
|
|
|
|
|
|
|
17
|
69
|
50
|
|
|
|
|
if (i >= len) return 0; |
|
18
|
332
|
100
|
|
|
|
|
for (; i < len; i++) if (s[i] < '0' || s[i] > '9') return 0; |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
|
return 1; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
/* "[+-]?digits[.digits]?" - no exponent, integer-with-dot allowed. */ |
|
23
|
11
|
|
|
|
|
|
int looks_like_number_str(const char *s, STRLEN len) { |
|
24
|
11
|
|
|
|
|
|
STRLEN i = 0; |
|
25
|
11
|
|
|
|
|
|
int seen_digit = 0, seen_dot = 0; |
|
26
|
11
|
50
|
|
|
|
|
if (len == 0) return 0; |
|
27
|
11
|
50
|
|
|
|
|
if (s[0] == '+' || s[0] == '-') i = 1; |
|
|
|
50
|
|
|
|
|
|
|
28
|
88
|
100
|
|
|
|
|
for (; i < len; i++) { |
|
29
|
85
|
100
|
|
|
|
|
if (s[i] == '.') { |
|
30
|
3
|
50
|
|
|
|
|
if (seen_dot) return 0; |
|
31
|
3
|
|
|
|
|
|
seen_dot = 1; |
|
32
|
82
|
100
|
|
|
|
|
} else if (s[i] >= '0' && s[i] <= '9') { |
|
|
|
50
|
|
|
|
|
|
|
33
|
74
|
|
|
|
|
|
seen_digit = 1; |
|
34
|
8
|
|
|
|
|
|
} else return 0; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
3
|
|
|
|
|
|
return seen_digit; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
/* YYYY-MM-DD prefix - validates digit shape only; range checks happen |
|
40
|
|
|
|
|
|
|
* in parse_date_string so out-of-range components produce informative |
|
41
|
|
|
|
|
|
|
* messages with the offending value. */ |
|
42
|
48
|
|
|
|
|
|
int looks_like_date(const char *s, STRLEN len) { |
|
43
|
|
|
|
|
|
|
int i; |
|
44
|
48
|
100
|
|
|
|
|
if (len < 10) return 0; |
|
45
|
235
|
50
|
|
|
|
|
for (i = 0; i < 4; i++) if (s[i] < '0' || s[i] > '9') return 0; |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
46
|
47
|
100
|
|
|
|
|
if (s[4] != '-') return 0; |
|
47
|
46
|
50
|
|
|
|
|
if (s[5] < '0' || s[5] > '9' || s[6] < '0' || s[6] > '9') return 0; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
48
|
46
|
50
|
|
|
|
|
if (s[7] != '-') return 0; |
|
49
|
46
|
50
|
|
|
|
|
if (s[8] < '0' || s[8] > '9' || s[9] < '0' || s[9] > '9') return 0; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
50
|
46
|
|
|
|
|
|
return 1; |
|
51
|
|
|
|
|
|
|
} |