| 862 | */ |
| 863 | |
| 864 | subscript_t parse_subscript( char const * s ) |
| 865 | { |
| 866 | subscript_t result; |
| 867 | result.sub1 = 0; |
| 868 | result.sub2 = 0; |
| 869 | do /* so we can use "break" */ |
| 870 | { |
| 871 | /* Allow negative subscripts. */ |
| 872 | if ( !isdigit( *s ) && ( *s != '-' ) ) |
| 873 | { |
| 874 | result.sub2 = 0; |
| 875 | break; |
| 876 | } |
| 877 | result.sub1 = atoi( s ); |
| 878 | |
| 879 | /* Skip over the first symbol, which is either a digit or dash. */ |
| 880 | ++s; |
| 881 | while ( isdigit( *s ) ) ++s; |
| 882 | |
| 883 | if ( *s == '\0' ) |
| 884 | { |
| 885 | result.sub2 = result.sub1; |
| 886 | break; |
| 887 | } |
| 888 | |
| 889 | if ( *s != '-' ) |
| 890 | { |
| 891 | result.sub2 = 0; |
| 892 | break; |
| 893 | } |
| 894 | |
| 895 | ++s; |
| 896 | |
| 897 | if ( *s == '\0' ) |
| 898 | { |
| 899 | result.sub2 = -1; |
| 900 | break; |
| 901 | } |
| 902 | |
| 903 | if ( !isdigit( *s ) && ( *s != '-' ) ) |
| 904 | { |
| 905 | result.sub2 = 0; |
| 906 | break; |
| 907 | } |
| 908 | |
| 909 | /* First, compute the index of the last element. */ |
| 910 | result.sub2 = atoi( s ); |
| 911 | while ( isdigit( *++s ) ); |
| 912 | |
| 913 | if ( *s != '\0' ) |
| 914 | result.sub2 = 0; |
| 915 | |
| 916 | } while ( 0 ); |
| 917 | return result; |
| 918 | } |
| 919 | |
| 920 | static LIST * apply_subscript( STACK * s ) |
| 921 | { |
no outgoing calls
no test coverage detected