| 945 | } |
| 946 | |
| 947 | static int rightmatch( |
| 948 | const char *pattern, /* first char of pattern to match in text */ |
| 949 | const char *context) /* last char of text to be matched */ |
| 950 | { |
| 951 | const char *pat; |
| 952 | const char *text; |
| 953 | |
| 954 | if (*pattern == '\0') |
| 955 | /* null string matches any context */ |
| 956 | return 1; |
| 957 | |
| 958 | pat = pattern; |
| 959 | |
| 960 | text = context; |
| 961 | |
| 962 | for (pat = pattern; *pat != '\0'; pat++) |
| 963 | { |
| 964 | /* First check for simple text or space */ |
| 965 | if (isalpha(*pat) || *pat == '\'' || *pat == ' ') |
| 966 | { |
| 967 | if (*pat != *text) |
| 968 | { |
| 969 | return 0; |
| 970 | } |
| 971 | else |
| 972 | { |
| 973 | text++; |
| 974 | continue; |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | switch (*pat) |
| 979 | { |
| 980 | |
| 981 | case '#': /* One or more vowels */ |
| 982 | |
| 983 | if (!isvowel(*text)) |
| 984 | return 0; |
| 985 | |
| 986 | text++; |
| 987 | |
| 988 | while (isvowel(*text)) |
| 989 | text++; |
| 990 | |
| 991 | break; |
| 992 | |
| 993 | case ':': /* Zero or more consonants */ |
| 994 | while (isconsonant(*text)) |
| 995 | text++; |
| 996 | |
| 997 | break; |
| 998 | |
| 999 | case '^': /* One consonant */ |
| 1000 | if (!isconsonant(*text)) |
| 1001 | return 0; |
| 1002 | |
| 1003 | text++; |
| 1004 |
no test coverage detected