pick "", "a ", or "an " as article for 'str'; used by an() and doname() */
| 2106 | |
| 2107 | /* pick "", "a ", or "an " as article for 'str'; used by an() and doname() */ |
| 2108 | char * |
| 2109 | just_an(char *outbuf, const char *str) |
| 2110 | { |
| 2111 | char c0; |
| 2112 | |
| 2113 | *outbuf = '\0'; |
| 2114 | c0 = lowc(*str); |
| 2115 | if (!str[1] || str[1] == ' ') { |
| 2116 | /* single letter; might be used for named fruit or a musical note */ |
| 2117 | Strcpy(outbuf, strchr("aefhilmnosx", c0) ? "an " : "a "); |
| 2118 | } else if (!strncmpi(str, "the ", 4) |
| 2119 | /* these probably shouldn't be handled here because doing so |
| 2120 | impacts inventory when using them for named fruit */ |
| 2121 | || !strcmpi(str, "molten lava") |
| 2122 | || !strcmpi(str, "iron bars") |
| 2123 | || !strcmpi(str, "ice") |
| 2124 | ) { |
| 2125 | ; /* no article */ |
| 2126 | } else { |
| 2127 | /* normal case is "an <vowel>" or "a <consonant>" */ |
| 2128 | if ((strchr(vowels, c0) /* some exceptions warranting "a <vowel>" */ |
| 2129 | /* 'wun' initial sound */ |
| 2130 | && (strncmpi(str, "one", 3) || (str[3] && !strchr("-_ ", str[3]))) |
| 2131 | /* long 'u' initial sound */ |
| 2132 | && strncmpi(str, "eu", 2) /* "eucalyptus leaf" */ |
| 2133 | && strncmpi(str, "uke", 3) && strncmpi(str, "ukulele", 7) |
| 2134 | && strncmpi(str, "unicorn", 7) && strncmpi(str, "uranium", 7) |
| 2135 | && strncmpi(str, "useful", 6)) /* "useful tool" */ |
| 2136 | || (c0 == 'x' && !strchr(vowels, lowc(str[1])))) |
| 2137 | Strcpy(outbuf, "an "); |
| 2138 | else |
| 2139 | Strcpy(outbuf, "a "); |
| 2140 | } |
| 2141 | return outbuf; |
| 2142 | } |
| 2143 | |
| 2144 | char * |
| 2145 | an(const char *str) |
no test coverage detected