line |
stmt |
bran |
cond |
sub |
time |
code |
1
|
|
|
|
|
|
/* inline_invlist.c |
2
|
|
|
|
|
|
* |
3
|
|
|
|
|
|
* Copyright (C) 2012 by Larry Wall and others |
4
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
* You may distribute under the terms of either the GNU General Public |
6
|
|
|
|
|
|
* License or the Artistic License, as specified in the README file. |
7
|
|
|
|
|
|
*/ |
8
|
|
|
|
|
|
|
9
|
|
|
|
|
|
#if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) |
10
|
|
|
|
|
|
|
11
|
|
|
|
|
|
/* An element is in an inversion list iff its index is even numbered: 0, 2, 4, |
12
|
|
|
|
|
|
* etc */ |
13
|
|
|
|
|
|
#define ELEMENT_RANGE_MATCHES_INVLIST(i) (! ((i) & 1)) |
14
|
|
|
|
|
|
#define PREV_RANGE_MATCHES_INVLIST(i) (! ELEMENT_RANGE_MATCHES_INVLIST(i)) |
15
|
|
|
|
|
|
|
16
|
|
|
|
|
|
/* This converts to/from our UVs to what the SV code is expecting: bytes. */ |
17
|
|
|
|
|
|
#define TO_INTERNAL_SIZE(x) ((x) * sizeof(UV)) |
18
|
|
|
|
|
|
#define FROM_INTERNAL_SIZE(x) ((x)/ sizeof(UV)) |
19
|
|
|
|
|
|
|
20
|
|
|
|
|
|
PERL_STATIC_INLINE bool* |
21
|
700708
|
|
|
|
|
S_get_invlist_offset_addr(pTHX_ SV* invlist) |
22
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
/* Return the address of the field that says whether the inversion list is |
24
|
|
|
|
|
|
* offset (it contains 1) or not (contains 0) */ |
25
|
|
|
|
|
|
|
26
|
700833
|
|
|
|
|
PERL_ARGS_ASSERT_GET_INVLIST_OFFSET_ADDR; |
27
|
|
|
|
|
|
|
28
|
1401520
|
|
|
|
|
assert(SvTYPE(invlist) == SVt_INVLIST); |
29
|
|
|
|
|
|
|
30
|
718722
|
|
|
|
|
return &(((XINVLIST*) SvANY(invlist))->is_offset); |
31
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
33
|
|
|
|
|
|
PERL_STATIC_INLINE UV |
34
|
718719
|
|
|
|
|
S__invlist_len(pTHX_ SV* const invlist) |
35
|
|
|
|
|
|
{ |
36
|
|
|
|
|
|
/* Returns the current number of elements stored in the inversion list's |
37
|
|
|
|
|
|
* array */ |
38
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
PERL_ARGS_ASSERT__INVLIST_LEN; |
40
|
|
|
|
|
|
|
41
|
18
|
|
|
|
|
assert(SvTYPE(invlist) == SVt_INVLIST); |
42
|
|
|
|
|
|
|
43
|
36
|
|
|
|
|
return (SvCUR(invlist) == 0) |
44
|
|
|
|
|
|
? 0 |
45
|
18
|
|
|
|
|
: FROM_INTERNAL_SIZE(SvCUR(invlist)) - *get_invlist_offset_addr(invlist); |
46
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
48
|
|
|
|
|
|
PERL_STATIC_INLINE bool |
49
|
0
|
|
|
|
|
S__invlist_contains_cp(pTHX_ SV* const invlist, const UV cp) |
50
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
/* Does contain code point as part of the set? */ |
52
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
IV index = _invlist_search(invlist, cp); |
54
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
PERL_ARGS_ASSERT__INVLIST_CONTAINS_CP; |
56
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
return index >= 0 && ELEMENT_RANGE_MATCHES_INVLIST(index); |
58
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
60
|
|
|
|
|
|
# if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGEXEC_C) |
61
|
|
|
|
|
|
|
62
|
|
|
|
|
|
/* These symbols are only needed later in regcomp.c */ |
63
|
|
|
|
|
|
# undef TO_INTERNAL_SIZE |
64
|
|
|
|
|
|
# undef FROM_INTERNAL_SIZE |
65
|
|
|
|
|
|
# endif |
66
|
|
|
|
|
|
|
67
|
|
|
|
|
|
#endif |