| 949 | */ |
| 950 | |
| 951 | static void get_iters( subscript_t const subscript, LISTITER * const first, |
| 952 | LISTITER * const last, int const length ) |
| 953 | { |
| 954 | int start; |
| 955 | int size; |
| 956 | LISTITER iter; |
| 957 | LISTITER end; |
| 958 | { |
| 959 | |
| 960 | if ( subscript.sub1 < 0 ) |
| 961 | start = length + subscript.sub1; |
| 962 | else if ( subscript.sub1 > length ) |
| 963 | start = length; |
| 964 | else |
| 965 | start = subscript.sub1 - 1; |
| 966 | |
| 967 | size = subscript.sub2 < 0 |
| 968 | ? length + 1 + subscript.sub2 - start |
| 969 | : subscript.sub2 - start; |
| 970 | |
| 971 | /* |
| 972 | * HACK: When the first subscript is before the start of the list, it |
| 973 | * magically becomes the beginning of the list. This is inconsistent, |
| 974 | * but needed for backwards compatibility. |
| 975 | */ |
| 976 | if ( start < 0 ) |
| 977 | start = 0; |
| 978 | |
| 979 | /* The "sub2 < 0" test handles the semantic error of sub2 < sub1. */ |
| 980 | if ( size < 0 ) |
| 981 | size = 0; |
| 982 | |
| 983 | if ( start + size > length ) |
| 984 | size = length - start; |
| 985 | } |
| 986 | |
| 987 | iter = *first; |
| 988 | while ( start-- > 0 ) |
| 989 | iter = list_next( iter ); |
| 990 | |
| 991 | end = iter; |
| 992 | while ( size-- > 0 ) |
| 993 | end = list_next( end ); |
| 994 | |
| 995 | *first = iter; |
| 996 | *last = end; |
| 997 | } |
| 998 | |
| 999 | static LIST * apply_modifiers_empty( LIST * result, string * buf, |
| 1000 | VAR_EDITS * edits, int n ) |
no outgoing calls
no test coverage detected