| 990 | */ |
| 991 | |
| 992 | static void get_iters( subscript_t const subscript, LISTITER * const first, |
| 993 | LISTITER * const last, int const length ) |
| 994 | { |
| 995 | int start; |
| 996 | int size; |
| 997 | LISTITER iter; |
| 998 | LISTITER end; |
| 999 | { |
| 1000 | |
| 1001 | if ( subscript.sub1 < 0 ) |
| 1002 | start = length + subscript.sub1; |
| 1003 | else if ( subscript.sub1 > length ) |
| 1004 | start = length; |
| 1005 | else |
| 1006 | start = subscript.sub1 - 1; |
| 1007 | |
| 1008 | size = subscript.sub2 < 0 |
| 1009 | ? length + 1 + subscript.sub2 - start |
| 1010 | : subscript.sub2 - start; |
| 1011 | |
| 1012 | /* |
| 1013 | * HACK: When the first subscript is before the start of the list, it |
| 1014 | * magically becomes the beginning of the list. This is inconsistent, |
| 1015 | * but needed for backwards compatibility. |
| 1016 | */ |
| 1017 | if ( start < 0 ) |
| 1018 | start = 0; |
| 1019 | |
| 1020 | /* The "sub2 < 0" test handles the semantic error of sub2 < sub1. */ |
| 1021 | if ( size < 0 ) |
| 1022 | size = 0; |
| 1023 | |
| 1024 | if ( start + size > length ) |
| 1025 | size = length - start; |
| 1026 | } |
| 1027 | |
| 1028 | iter = *first; |
| 1029 | while ( start-- > 0 ) |
| 1030 | iter = list_next( iter ); |
| 1031 | |
| 1032 | end = iter; |
| 1033 | while ( size-- > 0 ) |
| 1034 | end = list_next( end ); |
| 1035 | |
| 1036 | *first = iter; |
| 1037 | *last = end; |
| 1038 | } |
| 1039 | |
| 1040 | static LIST * apply_modifiers_empty( LIST * result, string * buf, |
| 1041 | VAR_EDITS * edits, int n ) |
no outgoing calls
no test coverage detected