| 903 | */ |
| 904 | |
| 905 | subscript_t parse_subscript( char const * s ) |
| 906 | { |
| 907 | subscript_t result; |
| 908 | result.sub1 = 0; |
| 909 | result.sub2 = 0; |
| 910 | do /* so we can use "break" */ |
| 911 | { |
| 912 | /* Allow negative subscripts. */ |
| 913 | if ( !isdigit( *s ) && ( *s != '-' ) ) |
| 914 | { |
| 915 | result.sub2 = 0; |
| 916 | break; |
| 917 | } |
| 918 | result.sub1 = atoi( s ); |
| 919 | |
| 920 | /* Skip over the first symbol, which is either a digit or dash. */ |
| 921 | ++s; |
| 922 | while ( isdigit( *s ) ) ++s; |
| 923 | |
| 924 | if ( *s == '\0' ) |
| 925 | { |
| 926 | result.sub2 = result.sub1; |
| 927 | break; |
| 928 | } |
| 929 | |
| 930 | if ( *s != '-' ) |
| 931 | { |
| 932 | result.sub2 = 0; |
| 933 | break; |
| 934 | } |
| 935 | |
| 936 | ++s; |
| 937 | |
| 938 | if ( *s == '\0' ) |
| 939 | { |
| 940 | result.sub2 = -1; |
| 941 | break; |
| 942 | } |
| 943 | |
| 944 | if ( !isdigit( *s ) && ( *s != '-' ) ) |
| 945 | { |
| 946 | result.sub2 = 0; |
| 947 | break; |
| 948 | } |
| 949 | |
| 950 | /* First, compute the index of the last element. */ |
| 951 | result.sub2 = atoi( s ); |
| 952 | while ( isdigit( *++s ) ); |
| 953 | |
| 954 | if ( *s != '\0' ) |
| 955 | result.sub2 = 0; |
| 956 | |
| 957 | } while ( 0 ); |
| 958 | return result; |
| 959 | } |
| 960 | |
| 961 | static LIST * apply_subscript( STACK * s ) |
| 962 | { |
no outgoing calls
no test coverage detected