| 32 | */ |
| 33 | |
| 34 | LIST * regex_split( FRAME * frame, int flags ) |
| 35 | { |
| 36 | LIST * args = lol_get( frame->args, 0 ); |
| 37 | OBJECT * s; |
| 38 | OBJECT * separator; |
| 39 | regexp * re; |
| 40 | const char * pos; |
| 41 | LIST * result = L0; |
| 42 | LISTITER iter = list_begin( args ); |
| 43 | s = list_item( iter ); |
| 44 | separator = list_item( list_next( iter ) ); |
| 45 | |
| 46 | re = regex_compile( separator ); |
| 47 | |
| 48 | pos = object_str( s ); |
| 49 | while ( regexec( re, pos ) ) |
| 50 | { |
| 51 | result = list_push_back( result, object_new_range( pos, re->startp[ 0 ] - pos ) ); |
| 52 | pos = re->endp[ 0 ]; |
| 53 | } |
| 54 | |
| 55 | result = list_push_back( result, object_new( pos ) ); |
| 56 | |
| 57 | return result; |
| 58 | } |
| 59 | |
| 60 | /* |
| 61 | rule replace ( |
nothing calls this directly
no test coverage detected