| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #include "INLINE.h" |
| 5 |
|
| |
| 6 |
|
| |
| 7 |
|
| // The transition. There are no explicit states, just linked |
| 8 |
|
| // lists of transitions. |
| 9 |
|
| typedef struct TRANS *trans; |
| 10 |
|
| typedef struct TRANS { |
| 11 |
|
| char splitchar; |
| 12 |
|
| trans next_trans; |
| 13 |
|
| trans next_state; |
| 14 |
|
| } Trans; |
| 15 |
|
| |
| 16 |
|
| typedef struct FSM *fsm; |
| 17 |
|
| typedef struct FSM { |
| 18 |
|
| trans root; |
| 19 |
|
| int terminals; |
| 20 |
|
| int transitions; |
| 21 |
|
| int states; |
| 22 |
|
| int maxpath; |
| 23 |
|
| char* ignore; |
| 24 |
|
| char* boundary; |
| 25 |
|
| char* inclboundary ; |
| 26 |
|
| char* charclasses; |
| 27 |
|
| char* wild; // all chars which match a wildcard |
| 28 |
|
| AV* found_keys; |
| 29 |
|
| AV* found_offsets; |
| 30 |
|
| AV* found_vals; |
| 31 |
|
| int position; |
| 32 |
|
| bool use_wildcards; |
| 33 |
|
| bool squeezeblanks; |
| 34 |
|
| char* s; // string on which to match |
| 35 |
|
| } Fsm; |
| 36 |
|
| |
| 37 |
|
| |
| 38 |
|
| // function declarations (prototypes) necessary for |
| 39 |
|
| // mutually recursive functions |
| 40 |
|
| int _eat_wild_chars(fsm this, int matchlen, trans p); |
| 41 |
|
| int _find_match(fsm this, int matchlen, trans p); |
| 42 |
|
| |
| 43 |
|
| |
| 44 |
|
| // For vector records |
| 45 |
|
| #define BIT_ON(vec, offset, pos) \ |
| 46 |
|
| ( *(vec + \ |
| 47 |
|
| ((unsigned char) offset*32) + \ |
| 48 |
|
| (unsigned char)pos/8) |= \ |
| 49 |
|
| (1 << ((unsigned char)pos % 8)) \ |
| 50 |
|
| ) |
| 51 |
|
| |
| 52 |
|
| #define IS_BIT_ON(vec, offset, pos) \ |
| 53 |
|
| ( *(vec+((unsigned char) offset*32) + \ |
| 54 |
|
| (unsigned char)pos/8) & \ |
| 55 |
|
| (1 << ((unsigned char)pos % 8)) \ |
| 56 |
|
| ) |
| 57 |
|
| |
| 58 |
|
| |
| 59 |
|
| |
| 60 |
73 |
| _malloc(fsm m) { |
| 61 |
73 |
| av_clear(m->found_keys); |
| 62 |
73 |
| av_clear(m->found_offsets); |
| 63 |
73 |
| av_clear(m->found_vals); |
| 64 |
73 |
| } |
| 65 |
|
| |
| 66 |
|
| |
| 67 |
|
| // Place the top transition where it belongs (in the order \0,*,[others]) |
| 68 |
7612 |
| trans _demote(trans parent){ |
| 69 |
|
| |
| 70 |
7612 |
| trans child, top = parent; |
| 71 |
|
| |
| 72 |
7612 |
▶ | if( !(child = parent->next_trans) ) return top; |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(child = parent->next_trans) ) return top; |
6894 |
718 |
7612 |
|
| 73 |
718 |
▶ | if( !parent->splitchar ) return top; |
Branch: 1 branch
| Branch | True | False | Total |
| if( !parent->splitchar ) return top; |
14 |
704 |
718 |
|
| 74 |
704 |
▶ | if( !child->splitchar ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( !child->splitchar ){ |
88 |
616 |
704 |
|
| 75 |
88 |
| parent->next_trans = child->next_trans; |
| 76 |
88 |
| child->next_trans = parent; |
| 77 |
88 |
| top = child; |
| 78 |
|
| } |
| 79 |
704 |
▶ | if( !(child = parent->next_trans) ) return top; |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(child = parent->next_trans) ) return top; |
88 |
616 |
704 |
|
| 80 |
|
| |
| 81 |
616 |
▶ | if( child->splitchar == '*' ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( child->splitchar == '*' ){ |
0 |
616 |
616 |
|
| 82 |
0 |
| parent->next_trans = child->next_trans; |
| 83 |
0 |
| child->next_trans = parent; |
| 84 |
0 |
▶ | if( top != parent ) top->next_trans = child; |
Branch: 1 branch
| Branch | True | False | Total |
| if( top != parent ) top->next_trans = child; |
0 |
0 |
0 |
|
| 85 |
0 |
| else top = child; |
| 86 |
|
| } |
| 87 |
616 |
| return top; |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
|
| |
| 91 |
|
| |
| 92 |
9473 |
| trans _insert_(fsm m, trans p, char *s, SV* val) { |
| 93 |
|
| |
| 94 |
9473 |
| trans t = p; |
| 95 |
|
| |
| 96 |
|
| // going to be a new state with one transition. |
| 97 |
|
| //if (p == 0 && *s) m->states++; |
| 98 |
9473 |
▶ | if(p == 0) m->states++; |
Branch: 1 branch
| Branch | True | False | Total |
| if(p == 0) m->states++; |
6894 |
2579 |
9473 |
|
| 99 |
|
| |
| 100 |
|
| // search for *s in transition list (state) t |
| 101 |
11504 |
▶ | while(t){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(t){ |
3892 |
7612 |
11504 |
|
| 102 |
|
| // if(*s == t->splitchar) break; |
| 103 |
3892 |
▶ | if(IS_BIT_ON(m->charclasses, *s, t->splitchar)) break; |
Branch: 1 branch
| Branch | True | False | Total |
| if(IS_BIT_ON(m->charclasses, *s, t->splitchar)) break; |
1861 |
2031 |
3892 |
|
| 104 |
2031 |
| else t = t->next_trans; |
| 105 |
|
| } |
| 106 |
|
| |
| 107 |
|
| // *s transition not in current state? Make a new one, place |
| 108 |
|
| // it at the top of the list. (but keep terminals, wilds at top) |
| 109 |
9473 |
▶ | if(!t){ |
Branch: 1 branch
| Branch | True | False | Total |
| if(!t){ |
7612 |
1861 |
9473 |
|
| 110 |
7612 |
| m->transitions++; |
| 111 |
7612 |
| t = (trans) malloc(sizeof(Trans)); |
| 112 |
7612 |
| t->splitchar = *s; |
| 113 |
7612 |
| t->next_state = 0; |
| 114 |
7612 |
| t->next_trans = p; |
| 115 |
|
| // flip terminal state and/or wildcard p to top |
| 116 |
7612 |
| p = _demote(t); |
| 117 |
|
| } |
| 118 |
|
| |
| 119 |
|
| // continue inserting the rest of the string. If there is no more |
| 120 |
|
| // string, place the SV* val into this termination transition. |
| 121 |
9473 |
▶ | if(*s){ |
Branch: 1 branch
| Branch | True | False | Total |
| if(*s){ |
8714 |
759 |
9473 |
|
| 122 |
8714 |
| t->next_state = _insert_(m, t->next_state, ++s, val); |
| 123 |
|
| } |
| 124 |
|
| else { |
| 125 |
759 |
▶ | if(t->next_state) |
Branch: 1 branch
| Branch | True | False | Total |
| if(t->next_state) |
7 |
752 |
759 |
|
| 126 |
7 |
| sv_2mortal((SV*)t->next_state); |
| 127 |
|
| else |
| 128 |
752 |
| m->terminals++; |
| 129 |
759 |
| t->next_state = (trans) val; |
| 130 |
|
| } |
| 131 |
|
| |
| 132 |
9473 |
| return p; |
| 133 |
|
| } |
| 134 |
|
| |
| 135 |
|
| |
| 136 |
|
| // unused, too slow |
| 137 |
|
| /* |
| 138 |
|
| void _cleanup_(trans p) { |
| 139 |
|
| |
| 140 |
|
| if (p) { |
| 141 |
|
| |
| 142 |
|
| _cleanup_(p->next_trans); |
| 143 |
|
| |
| 144 |
|
| if(!p->splitchar){ |
| 145 |
|
| sv_2mortal( (SV*) p->next_state); |
| 146 |
|
| } |
| 147 |
|
| else |
| 148 |
|
| _cleanup_(p->next_state); |
| 149 |
|
| } |
| 150 |
|
| //free(p); |
| 151 |
|
| } |
| 152 |
|
| */ |
| 153 |
|
| |
| 154 |
|
| |
| 155 |
6 |
| int _search(trans root, char *s) { |
| 156 |
|
| |
| 157 |
6 |
| trans p = root; |
| 158 |
35 |
▶ | while (p) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p) { |
35 |
0 |
35 |
|
| 159 |
43 |
▶ | while(p) |
Branch: 1 branch
| Branch | True | False | Total |
| while(p) |
39 |
4 |
43 |
|
| 160 |
39 |
▶ | if(p->splitchar == *s) break; |
Branch: 1 branch
| Branch | True | False | Total |
| if(p->splitchar == *s) break; |
31 |
8 |
39 |
|
| 161 |
8 |
| else p = p->next_trans; |
| 162 |
35 |
▶ | if(!p) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if(!p) return 0; |
4 |
31 |
35 |
|
| 163 |
31 |
▶ | if(!p->splitchar) return 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if(!p->splitchar) return 1; |
2 |
29 |
31 |
|
| 164 |
29 |
| p = p->next_state; |
| 165 |
29 |
| s++; |
| 166 |
|
| } |
| 167 |
0 |
| return 0; |
| 168 |
|
| } |
| 169 |
|
| |
| 170 |
|
| |
| 171 |
|
| // Return the node representing the char s, if it exists, from this list. |
| 172 |
188535 |
| trans _bsearch( char* vec, char s, trans q ){ |
| 173 |
|
| |
| 174 |
1564281 |
▶ | while(q){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(q){ |
1503278 |
61003 |
1564281 |
|
| 175 |
1503278 |
▶ | if(IS_BIT_ON(vec, s, q->splitchar)) |
Branch: 1 branch
| Branch | True | False | Total |
| if(IS_BIT_ON(vec, s, q->splitchar)) |
127532 |
1375746 |
1503278 |
|
| 176 |
127532 |
| break; |
| 177 |
|
| else |
| 178 |
1375746 |
| q = q->next_trans; |
| 179 |
|
| } |
| 180 |
188535 |
| return q; |
| 181 |
|
| } |
| 182 |
|
| |
| 183 |
1323 |
| void _record_match(fsm this, int matchlen, trans p){ |
| 184 |
|
| |
| 185 |
1323 |
| SV* val = (SV*) p->next_state; |
| 186 |
1323 |
| av_push(this->found_keys, newSVpvn(this->s,matchlen+1)); |
| 187 |
1323 |
| av_push(this->found_offsets, newSViv(this->position)); |
| 188 |
1323 |
| av_push(this->found_vals, val); |
| 189 |
1323 |
| SvREFCNT_inc(val); |
| 190 |
1323 |
| } |
| 191 |
|
| |
| 192 |
35 |
| int _eat_wild_chars(fsm this, int matchlen, trans p){ |
| 193 |
35 |
| char* t = this->s + matchlen; |
| 194 |
|
| |
| 195 |
35 |
| int wildlength = 0; |
| 196 |
|
| |
| 197 |
164 |
▶ | while( IS_BIT_ON( this->wild, 0, *t ) ){ |
Branch: 1 branch
| Branch | True | False | Total |
| while( IS_BIT_ON( this->wild, 0, *t ) ){ |
129 |
35 |
164 |
|
| 198 |
129 |
| t++; |
| 199 |
129 |
| wildlength++; |
| 200 |
129 |
▶ | if(wildlength > 256) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if(wildlength > 256) return 0; |
0 |
129 |
129 |
|
| 201 |
|
| } |
| 202 |
|
| |
| 203 |
35 |
| matchlen += wildlength; |
| 204 |
35 |
| p = p->next_state; |
| 205 |
35 |
| return _find_match(this, matchlen, p); |
| 206 |
|
| } |
| 207 |
|
| |
| 208 |
38226 |
| int _find_match(fsm this, int matchlen, trans p){ |
| 209 |
|
| |
| 210 |
|
| // These items are invariant through a complete recursive call. |
| 211 |
|
| //this->s (document to match) |
| 212 |
|
| //this->position (position in document where s starts) |
| 213 |
|
| //this->found_keys (perl list of found text) |
| 214 |
|
| //this->found_offsets (perl list of offsets for found text) |
| 215 |
|
| //this->found_vals (perl list of found values stored in fsm) |
| 216 |
|
| |
| 217 |
38226 |
| int depth = matchlen; |
| 218 |
38226 |
| char* t = this->s + matchlen; //starting point for this match |
| 219 |
|
| |
| 220 |
165853 |
▶ | while(p){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(p){ |
127627 |
38226 |
165853 |
|
| 221 |
|
| |
| 222 |
|
| // if this is a termination state |
| 223 |
127627 |
▶ | if(!p->splitchar){ |
Branch: 1 branch
| Branch | True | False | Total |
| if(!p->splitchar){ |
2004 |
125623 |
127627 |
|
| 224 |
|
| |
| 225 |
2004 |
▶ | if( IS_BIT_ON( this->boundary, 0, *t ) |
Branch: 1 branch
| Branch | True | False | Total |
| if( IS_BIT_ON( this->boundary, 0, *t ) |
684 |
1320 |
2004 |
|
| 226 |
684 |
▶ | || IS_BIT_ON( this->inclboundary,0,*t) |
Branch: 1 branch
| Branch | True | False | Total |
| || IS_BIT_ON( this->inclboundary,0,*t) |
3 |
681 |
684 |
|
| 227 |
|
| ){ |
| 228 |
1323 |
| matchlen = depth - 1; |
| 229 |
1323 |
| _record_match(this, matchlen, p); |
| 230 |
|
| } |
| 231 |
2004 |
| p = p->next_trans; |
| 232 |
|
| } |
| 233 |
|
| |
| 234 |
|
| |
| 235 |
|
| // ignore irrelevant chars |
| 236 |
127638 |
▶ | while( IS_BIT_ON(this->ignore, 0, *t) ){ |
Branch: 1 branch
| Branch | True | False | Total |
| while( IS_BIT_ON(this->ignore, 0, *t) ){ |
11 |
127627 |
127638 |
|
| 237 |
11 |
| t++; |
| 238 |
11 |
| depth += 1; |
| 239 |
|
| } |
| 240 |
|
| |
| 241 |
|
| // squeeze spaces cough cough |
| 242 |
127627 |
▶ | if(this->squeezeblanks && IS_BIT_ON(this->charclasses, ' ', *t)) |
Branch: 2 branches
| Branch | True | False | Total |
| if(this->squeezeblanks && IS_BIT_ON(this->charclasses, ' ', *t)) |
111 |
127516 |
127627 |
| if(this->squeezeblanks && IS_BIT_ON(this->charclasses, ' ', *t)) |
25 |
86 |
111 |
|
| 243 |
31 |
▶ | while(IS_BIT_ON(this->charclasses, ' ', *(t+1))){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(IS_BIT_ON(this->charclasses, ' ', *(t+1))){ |
6 |
25 |
31 |
|
| 244 |
6 |
| t++; |
| 245 |
6 |
| depth++; |
| 246 |
|
| } |
| 247 |
|
| |
| 248 |
|
| // find wildcard matches |
| 249 |
127627 |
▶ | if(p && p->splitchar == '*' && this->use_wildcards) |
Branch: 3 branches
| Branch | True | False | Total |
| if(p && p->splitchar == '*' && this->use_wildcards) |
127509 |
118 |
127627 |
| if(p && p->splitchar == '*' && this->use_wildcards) |
35 |
127474 |
127509 |
| if(p && p->splitchar == '*' && this->use_wildcards) |
35 |
0 |
35 |
|
| 250 |
35 |
| matchlen = _eat_wild_chars(this, depth, p); |
| 251 |
|
| |
| 252 |
|
| |
| 253 |
|
| // search for t |
| 254 |
127627 |
| p = _bsearch( this->charclasses, *t, p ); |
| 255 |
|
| |
| 256 |
127627 |
▶ | if(p){ |
Branch: 1 branch
| Branch | True | False | Total |
| if(p){ |
89401 |
38226 |
127627 |
|
| 257 |
89401 |
| t++; |
| 258 |
89401 |
| depth++; |
| 259 |
89401 |
| p = p->next_state; |
| 260 |
|
| } |
| 261 |
|
| } |
| 262 |
|
| |
| 263 |
38226 |
| return matchlen; |
| 264 |
|
| } |
| 265 |
|
| |
| 266 |
|
| |
| 267 |
60 |
| void _scan(fsm this, char *s) { |
| 268 |
|
| |
| 269 |
60 |
| int match = 0; |
| 270 |
60 |
| int position = 0; |
| 271 |
60 |
| int cue = 0; |
| 272 |
|
| |
| 273 |
38191 |
▶ | while(*s){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(*s){ |
38191 |
0 |
38191 |
|
| 274 |
38191 |
| this->s = s; |
| 275 |
38191 |
| this->position = position; |
| 276 |
38191 |
| match = _find_match(this, 0, this->root); |
| 277 |
|
| |
| 278 |
|
| // truncate s by single char to match everything possible |
| 279 |
38191 |
▶ | if(match){ s++; position++; } |
Branch: 1 branch
| Branch | True | False | Total |
| if(match){ s++; position++; } |
1287 |
36904 |
38191 |
|
| 280 |
|
| |
| 281 |
|
| // cue up the first possible match: |
| 282 |
|
| // [boundary][ignore]*[firstmatchchar]/ |
| 283 |
38191 |
▶ | if( cue = _cue(this, s) ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( cue = _cue(this, s) ){ |
38131 |
60 |
38191 |
|
| 284 |
38131 |
| position += cue; |
| 285 |
38131 |
| s += cue; } |
| 286 |
|
| else |
| 287 |
60 |
| break; |
| 288 |
|
| |
| 289 |
38131 |
| match = 0; |
| 290 |
|
| } |
| 291 |
60 |
| } |
| 292 |
|
| |
| 293 |
38191 |
| int _cue( fsm this, char *s ){ |
| 294 |
|
| |
| 295 |
38191 |
| int position = 0; |
| 296 |
|
| |
| 297 |
60968 |
▶ | while(*s){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(*s){ |
60908 |
60 |
60968 |
|
| 298 |
|
| |
| 299 |
|
| |
| 300 |
|
| //Move to the first boundary char |
| 301 |
|
| //or stop in case the char is an inclboundary |
| 302 |
|
| // When we are in a word, we dont want to skip the chars who |
| 303 |
|
| // could be included boundary |
| 304 |
|
| // But we still want to skip at least to the next char, |
| 305 |
|
| |
| 306 |
284279 |
▶ | while( ! IS_BIT_ON(this->boundary, 0, *s) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while( ! IS_BIT_ON(this->boundary, 0, *s) ) { |
223382 |
60897 |
284279 |
|
| 307 |
223382 |
| s++; position++; |
| 308 |
223382 |
▶ | if ( IS_BIT_ON(this->inclboundary,0,*s) ) { break ;} |
Branch: 1 branch
| Branch | True | False | Total |
| if ( IS_BIT_ON(this->inclboundary,0,*s) ) { break ;} |
11 |
223371 |
223382 |
|
| 309 |
|
| } |
| 310 |
|
| |
| 311 |
|
| // chop off the first boundary only if not an included boundary |
| 312 |
60908 |
▶ | if(*s != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| if(*s != 0 |
60863 |
45 |
60908 |
|
| 313 |
60863 |
▶ | && ! IS_BIT_ON(this->inclboundary,0,*s) |
Branch: 1 branch
| Branch | True | False | Total |
| && ! IS_BIT_ON(this->inclboundary,0,*s) |
60852 |
11 |
60863 |
|
| 314 |
60852 |
| ) { s++; position++; } |
| 315 |
|
| |
| 316 |
|
| |
| 317 |
|
| // move past any irrelevant chars |
| 318 |
60918 |
▶ | while( IS_BIT_ON(this->ignore, 0, *s) ) { s++; position++; } |
Branch: 1 branch
| Branch | True | False | Total |
| while( IS_BIT_ON(this->ignore, 0, *s) ) { s++; position++; } |
10 |
60908 |
60918 |
|
| 319 |
|
| |
| 320 |
|
| // found a starting match point? |
| 321 |
60908 |
▶ | if( (int) _bsearch(this->charclasses, *s, this->root) ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( (int) _bsearch(this->charclasses, *s, this->root) ){ |
38131 |
22777 |
60908 |
|
| 322 |
38131 |
| return position; |
| 323 |
|
| } |
| 324 |
|
| } |
| 325 |
60 |
| return 0; |
| 326 |
|
| } |
| 327 |
|
| |
| 328 |
|
| |
| 329 |
2117 |
| void _dump(fsm m, trans p, char* k, int depth) { |
| 330 |
|
| |
| 331 |
2117 |
▶ | if (!p) return; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!p) return; |
919 |
1198 |
2117 |
|
| 332 |
|
| |
| 333 |
1198 |
| _dump(m, p->next_trans, k, depth); |
| 334 |
|
| |
| 335 |
1198 |
▶ | if (p->splitchar){ |
Branch: 1 branch
| Branch | True | False | Total |
| if (p->splitchar){ |
906 |
292 |
1198 |
|
| 336 |
906 |
| *(k+depth) = p->splitchar; |
| 337 |
906 |
| _dump(m, p->next_state, k, depth+1); |
| 338 |
|
| } |
| 339 |
|
| else { |
| 340 |
292 |
| av_push(m->found_keys, newSVpvn(k, depth)); |
| 341 |
292 |
| av_push(m->found_vals, (SV*)p->next_state); |
| 342 |
292 |
| SvREFCNT_inc((SV*)p->next_state); |
| 343 |
|
| } |
| 344 |
|
| } |
| 345 |
|
| |
| 346 |
|
| |
| 347 |
38 |
| void _init_charclasses(char* vecs){ |
| 348 |
|
| int i; |
| 349 |
9766 |
▶ | for(i=0;i<256;i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for(i=0;i<256;i++){ |
9728 |
38 |
9766 |
|
| 350 |
|
| // For the ith 256-bit span, turn on bit i |
| 351 |
9728 |
| BIT_ON( vecs, i, i ); |
| 352 |
|
| } |
| 353 |
38 |
| } |
| 354 |
|
| |
| 355 |
|
| // Default pattern boundary is EOS (null) and space (' ') |
| 356 |
38 |
| void _init_boundary(char* vec){ |
| 357 |
38 |
| BIT_ON( vec, 0, 0 ); |
| 358 |
38 |
| BIT_ON( vec, 0, (int) ' ' ); |
| 359 |
38 |
| } |
| 360 |
|
| |
| 361 |
38 |
| void _init_inclboundary(char* vec ){ |
| 362 |
38 |
| } |
| 363 |
|
| |
| 364 |
|
| |
| 365 |
38 |
| void _init_wild(char* vec){ |
| 366 |
|
| int i; |
| 367 |
9728 |
▶ | for(i=1;i<256;i++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for(i=1;i<256;i++){ |
9690 |
38 |
9728 |
|
| 368 |
|
| // All non-space chars match wilds by default |
| 369 |
9690 |
▶ | if( !isspace(i) ) |
Branch: 1 branch
| Branch | True | False | Total |
| if( !isspace(i) ) |
9462 |
228 |
9690 |
|
| 370 |
9462 |
| BIT_ON( vec, 0, i ); |
| 371 |
|
| } |
| 372 |
|
| |
| 373 |
38 |
| } |
| 374 |
|
| |
| 375 |
38 |
| SV* new(char* class){ |
| 376 |
38 |
| fsm m = (fsm) malloc( sizeof(Fsm) ); |
| 377 |
38 |
| SV* obj_ref = newSViv(0); |
| 378 |
38 |
| SV* obj = newSVrv(obj_ref, class); |
| 379 |
|
| |
| 380 |
38 |
| m->root = 0; |
| 381 |
38 |
| m->terminals = 0; |
| 382 |
38 |
| m->transitions = 0; |
| 383 |
38 |
| m->states = 0; |
| 384 |
38 |
| m->maxpath = 0; |
| 385 |
|
| |
| 386 |
38 |
| m->ignore = (char*) calloc(256/sizeof(char), sizeof(char)); |
| 387 |
38 |
| m->boundary = (char*) calloc(256/sizeof(char), sizeof(char)); |
| 388 |
38 |
| m->wild = (char*) calloc(256/sizeof(char), sizeof(char)); |
| 389 |
38 |
| m->inclboundary = (char*) calloc(256/sizeof(char), sizeof(char)); |
| 390 |
38 |
| m->charclasses = (char*) calloc((256*256)/sizeof(char), sizeof(char)); |
| 391 |
|
| |
| 392 |
38 |
| _init_inclboundary(m->inclboundary); |
| 393 |
38 |
| _init_boundary(m->boundary); |
| 394 |
38 |
| _init_charclasses(m->charclasses); |
| 395 |
38 |
| _init_wild(m->wild); |
| 396 |
|
| |
| 397 |
38 |
| m->found_keys = (AV*) newAV(); |
| 398 |
38 |
| m->found_offsets = (AV*) newAV(); |
| 399 |
38 |
| m->found_vals = (AV*) newAV(); |
| 400 |
|
| |
| 401 |
38 |
| m->use_wildcards = FALSE; |
| 402 |
38 |
| m->squeezeblanks = FALSE; |
| 403 |
|
| |
| 404 |
38 |
| sv_setiv(obj, (IV)m); |
| 405 |
38 |
| SvREADONLY_on(obj); |
| 406 |
38 |
| return obj_ref; |
| 407 |
|
| } |
| 408 |
|
| |
| 409 |
38 |
| void DESTROY(SV* obj){ |
| 410 |
38 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 411 |
|
| |
| 412 |
|
| // takes *far* too long compared to OS garbage collection. |
| 413 |
|
| // _cleanup_(m->root); |
| 414 |
|
| // free(m->charclasses); |
| 415 |
|
| // free(m->ignore); |
| 416 |
|
| // free(m); |
| 417 |
38 |
| } |
| 418 |
|
| |
| 419 |
8 |
| void usewild(SV* obj){ |
| 420 |
8 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 421 |
8 |
| m->use_wildcards = TRUE; |
| 422 |
8 |
| } |
| 423 |
|
| |
| 424 |
1 |
| void squeezeblanks(SV* obj){ |
| 425 |
1 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 426 |
1 |
| m->squeezeblanks = TRUE; |
| 427 |
1 |
| } |
| 428 |
|
| |
| 429 |
|
| |
| 430 |
|
| // This must be called before any insert(), but may be called |
| 431 |
|
| // any number of times. |
| 432 |
58 |
| void charclass(SV* obj, char* vecstring){ |
| 433 |
58 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 434 |
58 |
| char* i = vecstring; |
| 435 |
58 |
| char* j = vecstring; |
| 436 |
58 |
| char* vec = m->charclasses; |
| 437 |
185 |
▶ | while(*i){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(*i){ |
127 |
58 |
185 |
|
| 438 |
448 |
▶ | while(*j){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(*j){ |
321 |
127 |
448 |
|
| 439 |
|
| // For the ith 256-bit span, turn on the jth bit |
| 440 |
321 |
| BIT_ON( vec, *i, *j); |
| 441 |
321 |
| j++; |
| 442 |
|
| } |
| 443 |
127 |
| j = vecstring; |
| 444 |
127 |
| i++; |
| 445 |
|
| } |
| 446 |
58 |
| } |
| 447 |
|
| |
| 448 |
10 |
| void ignore(SV* obj, char* vecstring){ |
| 449 |
10 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 450 |
10 |
| char* i = vecstring; |
| 451 |
146 |
▶ | for(; *i; i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for(; *i; i++ ) |
136 |
10 |
146 |
|
| 452 |
136 |
| BIT_ON( m->ignore, 0, *i); |
| 453 |
|
| |
| 454 |
|
| // "ignore" chars also count as boundaries |
| 455 |
10 |
| i = vecstring; |
| 456 |
146 |
▶ | for(; *i; i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for(; *i; i++ ) |
136 |
10 |
146 |
|
| 457 |
136 |
| BIT_ON( m->boundary, 0, *i ); |
| 458 |
|
| |
| 459 |
|
| // "ignore" chars also match wildcards |
| 460 |
10 |
| i = vecstring; |
| 461 |
146 |
▶ | for(; *i; i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for(; *i; i++ ) |
136 |
10 |
146 |
|
| 462 |
136 |
| BIT_ON( m->wild, 0, *i ); |
| 463 |
10 |
| } |
| 464 |
|
| |
| 465 |
2 |
| void ignorecase(SV* obj){ |
| 466 |
2 |
| charclass(obj, "Aa"); |
| 467 |
2 |
| charclass(obj, "Bb"); |
| 468 |
2 |
| charclass(obj, "Cc"); |
| 469 |
2 |
| charclass(obj, "Dd"); |
| 470 |
2 |
| charclass(obj, "Ee"); |
| 471 |
2 |
| charclass(obj, "Ff"); |
| 472 |
2 |
| charclass(obj, "Gg"); |
| 473 |
2 |
| charclass(obj, "Hh"); |
| 474 |
2 |
| charclass(obj, "Ii"); |
| 475 |
2 |
| charclass(obj, "Jj"); |
| 476 |
2 |
| charclass(obj, "Kk"); |
| 477 |
2 |
| charclass(obj, "Ll"); |
| 478 |
2 |
| charclass(obj, "Mm"); |
| 479 |
2 |
| charclass(obj, "Nn"); |
| 480 |
2 |
| charclass(obj, "Oo"); |
| 481 |
2 |
| charclass(obj, "Pp"); |
| 482 |
2 |
| charclass(obj, "Qq"); |
| 483 |
2 |
| charclass(obj, "Rr"); |
| 484 |
2 |
| charclass(obj, "Ss"); |
| 485 |
2 |
| charclass(obj, "Tt"); |
| 486 |
2 |
| charclass(obj, "Uu"); |
| 487 |
2 |
| charclass(obj, "Vv"); |
| 488 |
2 |
| charclass(obj, "Ww"); |
| 489 |
2 |
| charclass(obj, "Xx"); |
| 490 |
2 |
| charclass(obj, "Yy"); |
| 491 |
2 |
| charclass(obj, "Zz"); |
| 492 |
2 |
| } |
| 493 |
|
| |
| 494 |
|
| // define class of chars that qualify as beginning/ending of patterns |
| 495 |
|
| // meaning, what is allowed to occur right before or after pattern |
| 496 |
6 |
| void boundary(SV* obj, char* b){ |
| 497 |
6 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 498 |
|
| int i; |
| 499 |
|
| |
| 500 |
|
| // Reset boundary to none |
| 501 |
1542 |
▶ | for( i=0; i<(256/sizeof(char)); i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for( i=0; i<(256/sizeof(char)); i++ ) |
1536 |
6 |
1542 |
|
| 502 |
1536 |
| *(m->boundary + i) = 0; |
| 503 |
|
| |
| 504 |
6 |
| BIT_ON( m->boundary, 0, 0 ); |
| 505 |
|
| |
| 506 |
|
| // Special case: if null string specified, all chars are boundary |
| 507 |
6 |
▶ | if(!*b) |
Branch: 1 branch
| Branch | True | False | Total |
| if(!*b) |
1 |
5 |
6 |
|
| 508 |
257 |
▶ | for( i=0; i<256; i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for( i=0; i<256; i++ ) |
256 |
1 |
257 |
|
| 509 |
256 |
| BIT_ON( m->boundary, 0, i ); |
| 510 |
|
| |
| 511 |
|
| // Otherwise set the specified chars as boundary |
| 512 |
|
| else |
| 513 |
78 |
▶ | for(; *b; b++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for(; *b; b++ ) |
73 |
5 |
78 |
|
| 514 |
73 |
| BIT_ON( m->boundary, 0, *b ); |
| 515 |
|
| |
| 516 |
|
| |
| 517 |
6 |
| } |
| 518 |
|
| |
| 519 |
|
| |
| 520 |
1 |
| void inclboundary(SV* obj, char* b){ |
| 521 |
1 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 522 |
|
| int i; |
| 523 |
|
| |
| 524 |
|
| // Reset boundary to none |
| 525 |
257 |
▶ | for( i=0; i<(256/sizeof(char)); i++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for( i=0; i<(256/sizeof(char)); i++ ) |
256 |
1 |
257 |
|
| 526 |
256 |
| *(m->inclboundary + i) = 0; |
| 527 |
|
| |
| 528 |
1 |
▶ | if(!*b){ return ; } |
Branch: 1 branch
| Branch | True | False | Total |
| if(!*b){ return ; } |
0 |
1 |
1 |
|
| 529 |
|
| |
| 530 |
17 |
▶ | for(; *b; b++ ) |
Branch: 1 branch
| Branch | True | False | Total |
| for(; *b; b++ ) |
16 |
1 |
17 |
|
| 531 |
16 |
| BIT_ON( m->inclboundary, 0, *b ); |
| 532 |
|
| |
| 533 |
|
| } |
| 534 |
|
| |
| 535 |
|
| |
| 536 |
761 |
| int insert(SV* obj, SV* key, SV* val) { |
| 537 |
761 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 538 |
|
| |
| 539 |
|
| //Don't make a copy of the key, but do make one of the value |
| 540 |
761 |
| SV* v = newSVsv( val ); |
| 541 |
761 |
| char* s = SvPV_nolen( key ); |
| 542 |
761 |
| int keylen = strlen(s); |
| 543 |
761 |
▶ | if(keylen > m->maxpath) m->maxpath = keylen; |
Branch: 1 branch
| Branch | True | False | Total |
| if(keylen > m->maxpath) m->maxpath = keylen; |
72 |
689 |
761 |
|
| 544 |
761 |
▶ | if(keylen == 0) return 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if(keylen == 0) return 1; |
2 |
759 |
761 |
|
| 545 |
759 |
| m->root = _insert_(m, m->root, s, v); |
| 546 |
759 |
| return 1; |
| 547 |
|
| } |
| 548 |
|
| |
| 549 |
|
| |
| 550 |
6 |
| int has(SV* obj, char *s) { |
| 551 |
6 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 552 |
6 |
| return _search(m->root, s); |
| 553 |
|
| } |
| 554 |
|
| |
| 555 |
0 |
| SV* val(SV* obj, char *s) { |
| 556 |
0 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 557 |
0 |
| trans p = m->root; |
| 558 |
0 |
▶ | while (p) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (p) { |
0 |
0 |
0 |
|
| 559 |
0 |
▶ | while(p) |
Branch: 1 branch
| Branch | True | False | Total |
| while(p) |
0 |
0 |
0 |
|
| 560 |
0 |
▶ | if(p->splitchar == *s) break; |
Branch: 1 branch
| Branch | True | False | Total |
| if(p->splitchar == *s) break; |
0 |
0 |
0 |
|
| 561 |
0 |
| else p = p->next_trans; |
| 562 |
0 |
▶ | if(!p) return &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| if(!p) return &PL_sv_undef; |
0 |
0 |
0 |
|
| 563 |
0 |
▶ | if(!p->splitchar) return newSVsv((SV*) p->next_state); |
Branch: 1 branch
| Branch | True | False | Total |
| if(!p->splitchar) return newSVsv((SV*) p->next_state); |
0 |
0 |
0 |
|
| 564 |
0 |
| p = p->next_state; |
| 565 |
0 |
| s++; |
| 566 |
|
| } |
| 567 |
0 |
| return &PL_sv_undef; |
| 568 |
|
| } |
| 569 |
|
| |
| 570 |
|
| |
| 571 |
3 |
| void dump(SV* obj){ |
| 572 |
3 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 573 |
|
| int i; |
| 574 |
|
| SV** ptr; |
| 575 |
|
| char *k; |
| 576 |
3 |
| INLINE_STACK_VARS; |
| 577 |
|
| |
| 578 |
3 |
| k = (char*) malloc(sizeof(char) * m->maxpath); |
| 579 |
3 |
| _malloc(m); |
| 580 |
3 |
| _dump(m, m->root, k, 0); |
| 581 |
3 |
| free(k); |
| 582 |
|
| |
| 583 |
3 |
| INLINE_STACK_RESET; |
| 584 |
39 |
▶ | for (i = 0; i <= av_len(m->found_keys); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_keys); i++) { |
36 |
3 |
39 |
|
| 585 |
36 |
| ptr = av_fetch(m->found_keys, i, 0); |
| 586 |
36 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
36 |
36 |
|
| 587 |
36 |
| ptr = av_fetch(m->found_vals, i, 0); |
| 588 |
36 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
36 |
36 |
|
| 589 |
|
| } |
| 590 |
3 |
| INLINE_STACK_DONE; |
| 591 |
3 |
| } |
| 592 |
|
| |
| 593 |
6 |
| void keys(SV* obj){ |
| 594 |
6 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 595 |
|
| int i; |
| 596 |
|
| SV** ptr; |
| 597 |
|
| char *k; |
| 598 |
6 |
| INLINE_STACK_VARS; |
| 599 |
|
| |
| 600 |
6 |
| k = (char*) malloc(sizeof(char) * m->maxpath); |
| 601 |
6 |
| _malloc(m); |
| 602 |
6 |
| _dump(m, m->root, k, 0); |
| 603 |
6 |
| free(k); |
| 604 |
|
| |
| 605 |
6 |
| INLINE_STACK_RESET; |
| 606 |
180 |
▶ | for (i = 0; i <= av_len(m->found_keys); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_keys); i++) { |
174 |
6 |
180 |
|
| 607 |
174 |
| ptr = av_fetch(m->found_keys, i, 0); |
| 608 |
174 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
174 |
174 |
|
| 609 |
|
| } |
| 610 |
6 |
| INLINE_STACK_DONE; |
| 611 |
6 |
| } |
| 612 |
|
| |
| 613 |
4 |
| void values(SV* obj){ |
| 614 |
4 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 615 |
|
| int i; |
| 616 |
|
| SV** ptr; |
| 617 |
|
| char *k; |
| 618 |
4 |
| INLINE_STACK_VARS; |
| 619 |
|
| |
| 620 |
4 |
| k = (char*) malloc(sizeof(char) * m->maxpath); |
| 621 |
4 |
| _malloc(m); |
| 622 |
4 |
| _dump(m, m->root, k, 0); |
| 623 |
4 |
| free(k); |
| 624 |
|
| |
| 625 |
4 |
| INLINE_STACK_RESET; |
| 626 |
86 |
▶ | for (i = 0; i <= av_len(m->found_vals); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_vals); i++) { |
82 |
4 |
86 |
|
| 627 |
82 |
| ptr = av_fetch(m->found_vals, i, 0); |
| 628 |
82 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
82 |
82 |
|
| 629 |
|
| } |
| 630 |
4 |
| INLINE_STACK_DONE; |
| 631 |
|
| |
| 632 |
4 |
| } |
| 633 |
|
| |
| 634 |
15 |
| int states(SV* obj){ |
| 635 |
15 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 636 |
15 |
| return m->states; |
| 637 |
|
| } |
| 638 |
|
| |
| 639 |
15 |
| int transitions(SV* obj){ |
| 640 |
15 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 641 |
15 |
| return m->transitions; |
| 642 |
|
| } |
| 643 |
|
| |
| 644 |
18 |
| int terminals(SV* obj){ |
| 645 |
18 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 646 |
18 |
| return m->terminals; |
| 647 |
|
| } |
| 648 |
|
| |
| 649 |
|
| |
| 650 |
|
| |
| 651 |
49 |
| void scan(SV* obj, char *s) { |
| 652 |
49 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 653 |
|
| int i; |
| 654 |
|
| SV** ptr; |
| 655 |
49 |
| INLINE_STACK_VARS; |
| 656 |
|
| |
| 657 |
49 |
| _malloc(m); |
| 658 |
49 |
| _scan(m, s); |
| 659 |
|
| |
| 660 |
49 |
| INLINE_STACK_RESET; |
| 661 |
997 |
▶ | for (i = 0; i <= av_len(m->found_keys); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_keys); i++) { |
948 |
49 |
997 |
|
| 662 |
948 |
| ptr = av_fetch(m->found_keys, i, 0); |
| 663 |
948 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
948 |
948 |
|
| 664 |
948 |
| ptr = av_fetch(m->found_vals, i, 0); |
| 665 |
948 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
948 |
948 |
|
| 666 |
|
| } |
| 667 |
49 |
| INLINE_STACK_DONE; |
| 668 |
49 |
| } |
| 669 |
|
| |
| 670 |
3 |
| void mindex(SV* obj, char *s) { |
| 671 |
3 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 672 |
|
| int i; |
| 673 |
|
| SV** ptr; |
| 674 |
3 |
| INLINE_STACK_VARS; |
| 675 |
|
| |
| 676 |
3 |
| _malloc(m); |
| 677 |
3 |
| _scan(m, s); |
| 678 |
|
| |
| 679 |
3 |
| INLINE_STACK_RESET; |
| 680 |
191 |
▶ | for (i = 0; i <= av_len(m->found_keys); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_keys); i++) { |
188 |
3 |
191 |
|
| 681 |
188 |
| ptr = av_fetch(m->found_keys, i, 0); |
| 682 |
188 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
188 |
188 |
|
| 683 |
188 |
| ptr = av_fetch(m->found_offsets, i, 0); |
| 684 |
188 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newSVsv(*ptr))); |
0 |
188 |
188 |
|
| 685 |
|
| } |
| 686 |
3 |
| INLINE_STACK_DONE; |
| 687 |
3 |
| } |
| 688 |
|
| |
| 689 |
8 |
| void multiscan(SV* obj, char *s) { |
| 690 |
8 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 691 |
|
| int i; |
| 692 |
|
| SV** ptr; |
| 693 |
|
| AV* result; // holds one result (3-item array) |
| 694 |
8 |
| INLINE_STACK_VARS; |
| 695 |
|
| |
| 696 |
8 |
| _malloc(m); |
| 697 |
8 |
| _scan(m, s); |
| 698 |
|
| |
| 699 |
8 |
| INLINE_STACK_RESET; |
| 700 |
195 |
▶ | for (i = 0; i <= av_len(m->found_keys); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i <= av_len(m->found_keys); i++) { |
187 |
8 |
195 |
|
| 701 |
|
| |
| 702 |
187 |
| result = (AV*) newAV(); |
| 703 |
|
| |
| 704 |
187 |
| ptr = av_fetch(m->found_keys, i, 0); |
| 705 |
187 |
| av_push(result, (SV*) newSVsv(*ptr)); |
| 706 |
|
| |
| 707 |
187 |
| ptr = av_fetch(m->found_offsets, i, 0); |
| 708 |
187 |
| av_push(result, (SV*) newSVsv(*ptr)); |
| 709 |
|
| |
| 710 |
187 |
| ptr = av_fetch(m->found_vals, i, 0); |
| 711 |
187 |
| av_push(result, (SV*) newSVsv(*ptr)); |
| 712 |
|
| |
| 713 |
187 |
▶ | INLINE_STACK_PUSH(sv_2mortal(newRV_noinc((SV*)result))); |
Branch: 1 branch
| Branch | True | False | Total |
| INLINE_STACK_PUSH(sv_2mortal(newRV_noinc((SV*)result))); |
0 |
187 |
187 |
|
| 714 |
|
| } |
| 715 |
8 |
| INLINE_STACK_DONE; |
| 716 |
8 |
| } |
| 717 |
|
| |
| 718 |
|
| |
| 719 |
|
| |
| 720 |
|
| // This inline uses variables in context |
| 721 |
|
| #define RECORD_STATE \ |
| 722 |
|
| i = 1; \ |
| 723 |
|
| if(front->splitchar == 0){ \ |
| 724 |
|
| s = (char *)SvPV_nolen( (SV*)front->next_state ); \ |
| 725 |
|
| len = strlen(s); \ |
| 726 |
|
| PerlIO_write( valfp, &len, sizeof(unsigned int)); \ |
| 727 |
|
| PerlIO_write( valfp, s, sizeof(char) * len); \ |
| 728 |
|
| } \ |
| 729 |
|
| while(front->next_trans){ \ |
| 730 |
|
| *(tlist+i) = front->splitchar; \ |
| 731 |
|
| i++; \ |
| 732 |
|
| front = front->next_trans; \ |
| 733 |
|
| pos++; \ |
| 734 |
|
| } \ |
| 735 |
|
| *(tlist+i) = front->splitchar; \ |
| 736 |
|
| *tlist = i; \ |
| 737 |
|
| PerlIO_write(statefp, tlist, sizeof(char) * (size_t) i+1); \ |
| 738 |
|
| |
| 739 |
|
| |
| 740 |
|
| // Record the trie and its values to disk, to be reloaded |
| 741 |
|
| // at another time. For this to work, all values must be either |
| 742 |
|
| // numbers or strings, ie Perl scalars but no references. |
| 743 |
|
| // tlist - String to record the transition list for each state |
| 744 |
|
| // tvector - bit vector of transition positions, to record the |
| 745 |
|
| // end-of-state position so the trie can be recreated. |
| 746 |
1 |
| int _serialize(SV* obj, char *triename, char *valsname){ |
| 747 |
1 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 748 |
|
| trans front, back; |
| 749 |
|
| PerlIO *statefp, *valfp; |
| 750 |
|
| int pos, len, i; |
| 751 |
1 |
| char *tlist = (char*) malloc(sizeof(char) * 255); |
| 752 |
|
| char *tvector = |
| 753 |
1 |
| (char*) calloc((size_t)ceil(m->transitions/8), sizeof(char)); |
| 754 |
|
| char *s; |
| 755 |
|
| |
| 756 |
1 |
▶ | if( !(statefp = PerlIO_open(triename, "wb"))){ return errno; } |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(statefp = PerlIO_open(triename, "wb"))){ return errno; } |
0 |
1 |
1 |
|
| 757 |
1 |
▶ | if( !(valfp = PerlIO_open(valsname, "wb"))){ return errno; } |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(valfp = PerlIO_open(valsname, "wb"))){ return errno; } |
0 |
1 |
1 |
|
| 758 |
|
| |
| 759 |
1 |
| PerlIO_write( statefp, &m->terminals, sizeof(int)); |
| 760 |
1 |
| PerlIO_write( statefp, &m->transitions, sizeof(int)); |
| 761 |
1 |
| PerlIO_write( statefp, &m->states, sizeof(int)); |
| 762 |
1 |
| PerlIO_write( statefp, &m->maxpath, sizeof(int)); |
| 763 |
1 |
| PerlIO_write( statefp, &m->use_wildcards, sizeof(bool)); |
| 764 |
|
| |
| 765 |
|
| // execute breadth-first traversal of the trie |
| 766 |
|
| // recording the positions of state-ending transitions |
| 767 |
|
| // in the bit vector for later reconstruction. |
| 768 |
1 |
| front = back = m->root; |
| 769 |
1 |
| pos = 0; |
| 770 |
88 |
▶ | while( front ){ |
Branch: 1 branch
| Branch | True | False | Total |
| while( front ){ |
88 |
0 |
88 |
|
| 771 |
|
| // record state [and value if present] at front, |
| 772 |
|
| // move front to end of state. Increment pos by len of state |
| 773 |
179 |
▶ | RECORD_STATE; |
Branch: 2 branches
| Branch | True | False | Total |
| RECORD_STATE; |
46 |
42 |
88 |
| RECORD_STATE; |
45 |
88 |
133 |
|
| 774 |
88 |
| BIT_ON(tvector, 0, pos); |
| 775 |
|
| |
| 776 |
88 |
▶ | if(!back){ break; } //the end |
Branch: 1 branch
| Branch | True | False | Total |
| if(!back){ break; } //the end |
1 |
87 |
88 |
|
| 777 |
|
| |
| 778 |
87 |
| front->next_trans = back->next_state; |
| 779 |
87 |
| front = front->next_trans; |
| 780 |
87 |
| pos++; |
| 781 |
87 |
| back = back->next_trans; |
| 782 |
133 |
▶ | while(back && back->splitchar == 0){ |
Branch: 2 branches
| Branch | True | False | Total |
| while(back && back->splitchar == 0){ |
132 |
1 |
133 |
| while(back && back->splitchar == 0){ |
46 |
86 |
132 |
|
| 783 |
46 |
| back = back->next_trans; |
| 784 |
|
| } |
| 785 |
|
| } |
| 786 |
|
| |
| 787 |
|
| // Now repair the trie, severing horizontal links between states |
| 788 |
1 |
| front = m->root; |
| 789 |
134 |
▶ | for( pos=0; pos < m->transitions; pos++ ){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( pos=0; pos < m->transitions; pos++ ){ |
133 |
1 |
134 |
|
| 790 |
133 |
▶ | if(IS_BIT_ON(tvector, 0, pos)){ |
Branch: 1 branch
| Branch | True | False | Total |
| if(IS_BIT_ON(tvector, 0, pos)){ |
88 |
45 |
133 |
|
| 791 |
88 |
| back = front; |
| 792 |
88 |
| front = front->next_trans; |
| 793 |
88 |
| back->next_trans = 0; |
| 794 |
|
| } |
| 795 |
|
| else { |
| 796 |
45 |
| front = front->next_trans; |
| 797 |
|
| } |
| 798 |
|
| } |
| 799 |
|
| |
| 800 |
1 |
| PerlIO_close(statefp); |
| 801 |
1 |
| PerlIO_close(valfp); |
| 802 |
|
| |
| 803 |
1 |
| return 0; |
| 804 |
|
| } |
| 805 |
|
| |
| 806 |
|
| |
| 807 |
|
| // Add a value back into the trie. Called from restore() |
| 808 |
46 |
| void _restore_val(trans t, PerlIO* valfp){ |
| 809 |
46 |
| unsigned int len = 0; |
| 810 |
|
| char* s; |
| 811 |
|
| |
| 812 |
46 |
| PerlIO_read(valfp, &len, sizeof(unsigned int)); |
| 813 |
46 |
| s = (char*) malloc(len * sizeof(char)); |
| 814 |
46 |
| PerlIO_read(valfp, s, sizeof(char) * len); |
| 815 |
|
| |
| 816 |
46 |
| t->next_state = (trans) newSVpvn(s, len); |
| 817 |
46 |
| } |
| 818 |
|
| |
| 819 |
|
| // Restore the serialized trie. |
| 820 |
1 |
| int _restore( SV* obj, char *triename, char *valsname ){ |
| 821 |
1 |
| fsm m = (fsm)SvIV(SvRV(obj)); |
| 822 |
|
| trans front, back, last, linker, restorer; |
| 823 |
|
| PerlIO *statefp, *valfp; |
| 824 |
1 |
| int j, transitions = 0, states = 0, terminals = 0; |
| 825 |
|
| char len; |
| 826 |
|
| |
| 827 |
1 |
▶ | if( !(statefp = PerlIO_open(triename, "rb")) ){ return errno; } |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(statefp = PerlIO_open(triename, "rb")) ){ return errno; } |
0 |
1 |
1 |
|
| 828 |
1 |
▶ | if( !(valfp = PerlIO_open(valsname, "rb")) ){ return errno; } |
Branch: 1 branch
| Branch | True | False | Total |
| if( !(valfp = PerlIO_open(valsname, "rb")) ){ return errno; } |
0 |
1 |
1 |
|
| 829 |
|
| |
| 830 |
|
| |
| 831 |
|
| /* Read in metadata */ |
| 832 |
1 |
| PerlIO_read( statefp, &m->terminals, sizeof(int)); |
| 833 |
1 |
| PerlIO_read( statefp, &m->transitions, sizeof(int)); |
| 834 |
1 |
| PerlIO_read( statefp, &m->states, sizeof(int)); |
| 835 |
1 |
| PerlIO_read( statefp, &m->maxpath, sizeof(int)); |
| 836 |
1 |
| PerlIO_read( statefp, &m->use_wildcards, sizeof(bool)); |
| 837 |
|
| |
| 838 |
|
| // create transitions |
| 839 |
1 |
| m->root = (trans) malloc(sizeof(Trans)); |
| 840 |
1 |
| front = m->root; |
| 841 |
90 |
▶ | while( !PerlIO_eof(statefp) ){ |
Branch: 1 branch
| Branch | True | False | Total |
| while( !PerlIO_eof(statefp) ){ |
89 |
1 |
90 |
|
| 842 |
89 |
| states++; |
| 843 |
89 |
| PerlIO_read( statefp, &len, sizeof(char) ); |
| 844 |
223 |
▶ | for( j=0; j < len; j++ ){ |
Branch: 1 branch
| Branch | True | False | Total |
| for( j=0; j < len; j++ ){ |
134 |
89 |
223 |
|
| 845 |
134 |
| front->splitchar = (char) PerlIO_getc(statefp); |
| 846 |
134 |
| front->next_state = 0; |
| 847 |
134 |
| front->next_trans = (trans) malloc(sizeof(Trans)); |
| 848 |
134 |
| transitions++; |
| 849 |
134 |
| last = front; |
| 850 |
134 |
| front = front->next_trans; |
| 851 |
|
| } |
| 852 |
89 |
| front->next_trans = 0; |
| 853 |
89 |
| front->next_state = 0; |
| 854 |
89 |
| last->next_state = front; |
| 855 |
89 |
| last->next_trans = 0; |
| 856 |
|
| } |
| 857 |
1 |
| last->next_state = 0; |
| 858 |
1 |
| free(front); |
| 859 |
|
| |
| 860 |
|
| // link transitions appropriately |
| 861 |
1 |
| front = back = m->root; |
| 862 |
89 |
▶ | while(back){ |
Branch: 1 branch
| Branch | True | False | Total |
| while(back){ |
88 |
1 |
89 |
|
| 863 |
88 |
| linker = back; |
| 864 |
133 |
▶ | while(front->next_trans) |
Branch: 1 branch
| Branch | True | False | Total |
| while(front->next_trans) |
45 |
88 |
133 |
|
| 865 |
45 |
| front = front->next_trans; |
| 866 |
88 |
| front = front->next_state; |
| 867 |
|
| |
| 868 |
88 |
▶ | back = back->next_trans ? back->next_trans : back->next_state; |
Branch: 1 branch
| Branch | True | False | Total |
| back = back->next_trans ? back->next_trans : back->next_state; |
33 |
55 |
88 |
|
| 869 |
134 |
▶ | while(back && !back->splitchar){ |
Branch: 2 branches
| Branch | True | False | Total |
| while(back && !back->splitchar){ |
133 |
1 |
134 |
| while(back && !back->splitchar){ |
46 |
87 |
133 |
|
| 870 |
46 |
| restorer = back; |
| 871 |
46 |
▶ | back = back->next_trans ? back->next_trans : back->next_state; |
Branch: 1 branch
| Branch | True | False | Total |
| back = back->next_trans ? back->next_trans : back->next_state; |
12 |
34 |
46 |
|
| 872 |
46 |
| _restore_val(restorer, valfp); |
| 873 |
46 |
| terminals++; |
| 874 |
|
| } |
| 875 |
88 |
| linker->next_state = front; |
| 876 |
|
| } |
| 877 |
|
| |
| 878 |
1 |
| m->transitions = transitions - 1; |
| 879 |
1 |
| m->states = states - 1; |
| 880 |
1 |
| m->terminals = terminals; |
| 881 |
|
| |
| 882 |
1 |
| PerlIO_close(valfp); |
| 883 |
1 |
| PerlIO_close(statefp); |
| 884 |
|
| |
| 885 |
1 |
| return 0; |
| 886 |
|
| } |
| 887 |
|
| |
| 888 |
|
| |
| 889 |
|
| |
| 890 |
|
| |
| 891 |
|
| |
| 892 |
|
| |
| 893 |
|
| MODULE = Text::Scan PACKAGE = Text::Scan |
| 894 |
|
| |
| 895 |
|
| PROTOTYPES: DISABLE |
| 896 |
|
| |
| 897 |
|
| |
| 898 |
|
| void |
| 899 |
|
| _init_charclasses (vecs) |
| 900 |
|
| char * vecs |
| 901 |
|
| PREINIT: |
| 902 |
|
| I32* temp; |
| 903 |
|
| PPCODE: |
| 904 |
0 |
| temp = PL_markstack_ptr++; |
| 905 |
0 |
| _init_charclasses(vecs); |
| 906 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 907 |
|
| /* truly void, because dXSARGS not invoked */ |
| 908 |
0 |
| PL_markstack_ptr = temp; |
| 909 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 910 |
|
| } |
| 911 |
|
| /* must have used dXSARGS; list context implied */ |
| 912 |
0 |
| return; /* assume stack size is correct */ |
| 913 |
|
| |
| 914 |
|
| void |
| 915 |
|
| _init_boundary (vec) |
| 916 |
|
| char * vec |
| 917 |
|
| PREINIT: |
| 918 |
|
| I32* temp; |
| 919 |
|
| PPCODE: |
| 920 |
0 |
| temp = PL_markstack_ptr++; |
| 921 |
0 |
| _init_boundary(vec); |
| 922 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 923 |
|
| /* truly void, because dXSARGS not invoked */ |
| 924 |
0 |
| PL_markstack_ptr = temp; |
| 925 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 926 |
|
| } |
| 927 |
|
| /* must have used dXSARGS; list context implied */ |
| 928 |
0 |
| return; /* assume stack size is correct */ |
| 929 |
|
| |
| 930 |
|
| void |
| 931 |
|
| _init_inclboundary (vec) |
| 932 |
|
| char * vec |
| 933 |
|
| PREINIT: |
| 934 |
|
| I32* temp; |
| 935 |
|
| PPCODE: |
| 936 |
0 |
| temp = PL_markstack_ptr++; |
| 937 |
0 |
| _init_inclboundary(vec); |
| 938 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 939 |
|
| /* truly void, because dXSARGS not invoked */ |
| 940 |
0 |
| PL_markstack_ptr = temp; |
| 941 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 942 |
|
| } |
| 943 |
|
| /* must have used dXSARGS; list context implied */ |
| 944 |
0 |
| return; /* assume stack size is correct */ |
| 945 |
|
| |
| 946 |
|
| void |
| 947 |
|
| _init_wild (vec) |
| 948 |
|
| char * vec |
| 949 |
|
| PREINIT: |
| 950 |
|
| I32* temp; |
| 951 |
|
| PPCODE: |
| 952 |
0 |
| temp = PL_markstack_ptr++; |
| 953 |
0 |
| _init_wild(vec); |
| 954 |
0 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
0 |
0 |
|
| 955 |
|
| /* truly void, because dXSARGS not invoked */ |
| 956 |
0 |
| PL_markstack_ptr = temp; |
| 957 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 958 |
|
| } |
| 959 |
|
| /* must have used dXSARGS; list context implied */ |
| 960 |
0 |
| return; /* assume stack size is correct */ |
| 961 |
|
| |
| 962 |
|
| SV * |
| 963 |
|
| new (class) |
| 964 |
|
| char * class |
| 965 |
|
| |
| 966 |
|
| void |
| 967 |
|
| DESTROY (obj) |
| 968 |
|
| SV * obj |
| 969 |
|
| PREINIT: |
| 970 |
|
| I32* temp; |
| 971 |
|
| PPCODE: |
| 972 |
38 |
| temp = PL_markstack_ptr++; |
| 973 |
38 |
| DESTROY(obj); |
| 974 |
38 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
38 |
0 |
38 |
|
| 975 |
|
| /* truly void, because dXSARGS not invoked */ |
| 976 |
38 |
| PL_markstack_ptr = temp; |
| 977 |
38 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 978 |
|
| } |
| 979 |
|
| /* must have used dXSARGS; list context implied */ |
| 980 |
0 |
| return; /* assume stack size is correct */ |
| 981 |
|
| |
| 982 |
|
| void |
| 983 |
|
| usewild (obj) |
| 984 |
|
| SV * obj |
| 985 |
|
| PREINIT: |
| 986 |
|
| I32* temp; |
| 987 |
|
| PPCODE: |
| 988 |
8 |
| temp = PL_markstack_ptr++; |
| 989 |
8 |
| usewild(obj); |
| 990 |
8 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
8 |
0 |
8 |
|
| 991 |
|
| /* truly void, because dXSARGS not invoked */ |
| 992 |
8 |
| PL_markstack_ptr = temp; |
| 993 |
8 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 994 |
|
| } |
| 995 |
|
| /* must have used dXSARGS; list context implied */ |
| 996 |
0 |
| return; /* assume stack size is correct */ |
| 997 |
|
| |
| 998 |
|
| void |
| 999 |
|
| squeezeblanks (obj) |
| 1000 |
|
| SV * obj |
| 1001 |
|
| PREINIT: |
| 1002 |
|
| I32* temp; |
| 1003 |
|
| PPCODE: |
| 1004 |
1 |
| temp = PL_markstack_ptr++; |
| 1005 |
1 |
| squeezeblanks(obj); |
| 1006 |
1 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
1 |
0 |
1 |
|
| 1007 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1008 |
1 |
| PL_markstack_ptr = temp; |
| 1009 |
1 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1010 |
|
| } |
| 1011 |
|
| /* must have used dXSARGS; list context implied */ |
| 1012 |
0 |
| return; /* assume stack size is correct */ |
| 1013 |
|
| |
| 1014 |
|
| void |
| 1015 |
|
| charclass (obj, vecstring) |
| 1016 |
|
| SV * obj |
| 1017 |
|
| char * vecstring |
| 1018 |
|
| PREINIT: |
| 1019 |
|
| I32* temp; |
| 1020 |
|
| PPCODE: |
| 1021 |
6 |
| temp = PL_markstack_ptr++; |
| 1022 |
6 |
| charclass(obj, vecstring); |
| 1023 |
6 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
6 |
0 |
6 |
|
| 1024 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1025 |
6 |
| PL_markstack_ptr = temp; |
| 1026 |
6 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1027 |
|
| } |
| 1028 |
|
| /* must have used dXSARGS; list context implied */ |
| 1029 |
0 |
| return; /* assume stack size is correct */ |
| 1030 |
|
| |
| 1031 |
|
| void |
| 1032 |
|
| ignore (obj, vecstring) |
| 1033 |
|
| SV * obj |
| 1034 |
|
| char * vecstring |
| 1035 |
|
| PREINIT: |
| 1036 |
|
| I32* temp; |
| 1037 |
|
| PPCODE: |
| 1038 |
10 |
| temp = PL_markstack_ptr++; |
| 1039 |
10 |
| ignore(obj, vecstring); |
| 1040 |
10 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
10 |
0 |
10 |
|
| 1041 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1042 |
10 |
| PL_markstack_ptr = temp; |
| 1043 |
10 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1044 |
|
| } |
| 1045 |
|
| /* must have used dXSARGS; list context implied */ |
| 1046 |
0 |
| return; /* assume stack size is correct */ |
| 1047 |
|
| |
| 1048 |
|
| void |
| 1049 |
|
| ignorecase (obj) |
| 1050 |
|
| SV * obj |
| 1051 |
|
| PREINIT: |
| 1052 |
|
| I32* temp; |
| 1053 |
|
| PPCODE: |
| 1054 |
2 |
| temp = PL_markstack_ptr++; |
| 1055 |
2 |
| ignorecase(obj); |
| 1056 |
2 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
2 |
0 |
2 |
|
| 1057 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1058 |
2 |
| PL_markstack_ptr = temp; |
| 1059 |
2 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1060 |
|
| } |
| 1061 |
|
| /* must have used dXSARGS; list context implied */ |
| 1062 |
0 |
| return; /* assume stack size is correct */ |
| 1063 |
|
| |
| 1064 |
|
| void |
| 1065 |
|
| boundary (obj, b) |
| 1066 |
|
| SV * obj |
| 1067 |
|
| char * b |
| 1068 |
|
| PREINIT: |
| 1069 |
|
| I32* temp; |
| 1070 |
|
| PPCODE: |
| 1071 |
6 |
| temp = PL_markstack_ptr++; |
| 1072 |
6 |
| boundary(obj, b); |
| 1073 |
6 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
6 |
0 |
6 |
|
| 1074 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1075 |
6 |
| PL_markstack_ptr = temp; |
| 1076 |
6 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1077 |
|
| } |
| 1078 |
|
| /* must have used dXSARGS; list context implied */ |
| 1079 |
0 |
| return; /* assume stack size is correct */ |
| 1080 |
|
| |
| 1081 |
|
| void |
| 1082 |
|
| inclboundary (obj, b) |
| 1083 |
|
| SV * obj |
| 1084 |
|
| char * b |
| 1085 |
|
| PREINIT: |
| 1086 |
|
| I32* temp; |
| 1087 |
|
| PPCODE: |
| 1088 |
1 |
| temp = PL_markstack_ptr++; |
| 1089 |
1 |
| inclboundary(obj, b); |
| 1090 |
1 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
1 |
0 |
1 |
|
| 1091 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1092 |
1 |
| PL_markstack_ptr = temp; |
| 1093 |
1 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1094 |
|
| } |
| 1095 |
|
| /* must have used dXSARGS; list context implied */ |
| 1096 |
0 |
| return; /* assume stack size is correct */ |
| 1097 |
|
| |
| 1098 |
|
| int |
| 1099 |
|
| insert (obj, key, val) |
| 1100 |
|
| SV * obj |
| 1101 |
|
| SV * key |
| 1102 |
|
| SV * val |
| 1103 |
|
| |
| 1104 |
|
| int |
| 1105 |
|
| has (obj, s) |
| 1106 |
|
| SV * obj |
| 1107 |
|
| char * s |
| 1108 |
|
| |
| 1109 |
|
| SV * |
| 1110 |
|
| val (obj, s) |
| 1111 |
|
| SV * obj |
| 1112 |
|
| char * s |
| 1113 |
|
| |
| 1114 |
|
| void |
| 1115 |
|
| dump (obj) |
| 1116 |
|
| SV * obj |
| 1117 |
|
| PREINIT: |
| 1118 |
|
| I32* temp; |
| 1119 |
|
| PPCODE: |
| 1120 |
3 |
| temp = PL_markstack_ptr++; |
| 1121 |
3 |
| dump(obj); |
| 1122 |
3 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
3 |
3 |
|
| 1123 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1124 |
0 |
| PL_markstack_ptr = temp; |
| 1125 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1126 |
|
| } |
| 1127 |
|
| /* must have used dXSARGS; list context implied */ |
| 1128 |
3 |
| return; /* assume stack size is correct */ |
| 1129 |
|
| |
| 1130 |
|
| void |
| 1131 |
|
| keys (obj) |
| 1132 |
|
| SV * obj |
| 1133 |
|
| PREINIT: |
| 1134 |
|
| I32* temp; |
| 1135 |
|
| PPCODE: |
| 1136 |
6 |
| temp = PL_markstack_ptr++; |
| 1137 |
6 |
| keys(obj); |
| 1138 |
6 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
6 |
6 |
|
| 1139 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1140 |
0 |
| PL_markstack_ptr = temp; |
| 1141 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1142 |
|
| } |
| 1143 |
|
| /* must have used dXSARGS; list context implied */ |
| 1144 |
6 |
| return; /* assume stack size is correct */ |
| 1145 |
|
| |
| 1146 |
|
| void |
| 1147 |
|
| values (obj) |
| 1148 |
|
| SV * obj |
| 1149 |
|
| PREINIT: |
| 1150 |
|
| I32* temp; |
| 1151 |
|
| PPCODE: |
| 1152 |
4 |
| temp = PL_markstack_ptr++; |
| 1153 |
4 |
| values(obj); |
| 1154 |
4 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
4 |
4 |
|
| 1155 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1156 |
0 |
| PL_markstack_ptr = temp; |
| 1157 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1158 |
|
| } |
| 1159 |
|
| /* must have used dXSARGS; list context implied */ |
| 1160 |
4 |
| return; /* assume stack size is correct */ |
| 1161 |
|
| |
| 1162 |
|
| int |
| 1163 |
|
| states (obj) |
| 1164 |
|
| SV * obj |
| 1165 |
|
| |
| 1166 |
|
| int |
| 1167 |
|
| transitions (obj) |
| 1168 |
|
| SV * obj |
| 1169 |
|
| |
| 1170 |
|
| int |
| 1171 |
|
| terminals (obj) |
| 1172 |
|
| SV * obj |
| 1173 |
|
| |
| 1174 |
|
| void |
| 1175 |
|
| scan (obj, s) |
| 1176 |
|
| SV * obj |
| 1177 |
|
| char * s |
| 1178 |
|
| PREINIT: |
| 1179 |
|
| I32* temp; |
| 1180 |
|
| PPCODE: |
| 1181 |
49 |
| temp = PL_markstack_ptr++; |
| 1182 |
49 |
| scan(obj, s); |
| 1183 |
49 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
49 |
49 |
|
| 1184 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1185 |
0 |
| PL_markstack_ptr = temp; |
| 1186 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1187 |
|
| } |
| 1188 |
|
| /* must have used dXSARGS; list context implied */ |
| 1189 |
49 |
| return; /* assume stack size is correct */ |
| 1190 |
|
| |
| 1191 |
|
| void |
| 1192 |
|
| mindex (obj, s) |
| 1193 |
|
| SV * obj |
| 1194 |
|
| char * s |
| 1195 |
|
| PREINIT: |
| 1196 |
|
| I32* temp; |
| 1197 |
|
| PPCODE: |
| 1198 |
3 |
| temp = PL_markstack_ptr++; |
| 1199 |
3 |
| mindex(obj, s); |
| 1200 |
3 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
3 |
3 |
|
| 1201 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1202 |
0 |
| PL_markstack_ptr = temp; |
| 1203 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1204 |
|
| } |
| 1205 |
|
| /* must have used dXSARGS; list context implied */ |
| 1206 |
3 |
| return; /* assume stack size is correct */ |
| 1207 |
|
| |
| 1208 |
|
| void |
| 1209 |
|
| multiscan (obj, s) |
| 1210 |
|
| SV * obj |
| 1211 |
|
| char * s |
| 1212 |
|
| PREINIT: |
| 1213 |
|
| I32* temp; |
| 1214 |
|
| PPCODE: |
| 1215 |
8 |
| temp = PL_markstack_ptr++; |
| 1216 |
8 |
| multiscan(obj, s); |
| 1217 |
8 |
▶ | if (PL_markstack_ptr != temp) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (PL_markstack_ptr != temp) { |
0 |
8 |
8 |
|
| 1218 |
|
| /* truly void, because dXSARGS not invoked */ |
| 1219 |
0 |
| PL_markstack_ptr = temp; |
| 1220 |
0 |
| XSRETURN_EMPTY; /* return empty stack */ |
| 1221 |
|
| } |
| 1222 |
|
| /* must have used dXSARGS; list context implied */ |
| 1223 |
8 |
| return; /* assume stack size is correct */ |
| 1224 |
|
| |
| 1225 |
|
| int |
| 1226 |
|
| _serialize (obj, triename, valsname) |
| 1227 |
|
| SV * obj |
| 1228 |
|
| char * triename |
| 1229 |
|
| char * valsname |
| 1230 |
|
| |
| 1231 |
|
| int |
| 1232 |
|
| _restore (obj, triename, valsname) |
| 1233 |
|
| SV * obj |
| 1234 |
|
| char * triename |
| 1235 |
|
| char * valsname |
| 1236 |
|
| |