| 2155 | Return 0 if the name in S is not recognized. */ |
| 2156 | |
| 2157 | static int |
| 2158 | getmonth (char const *month, char **ea) |
| 2159 | { |
| 2160 | size_t lo = 0; |
| 2161 | size_t hi = MONTHS_PER_YEAR; |
| 2162 | |
| 2163 | while (blanks[to_uchar (*month)]) |
| 2164 | month++; |
| 2165 | |
| 2166 | do |
| 2167 | { |
| 2168 | size_t ix = (lo + hi) / 2; |
| 2169 | char const *m = month; |
| 2170 | char const *n = monthtab[ix].name; |
| 2171 | |
| 2172 | for (;; m++, n++) |
| 2173 | { |
| 2174 | if (!*n) |
| 2175 | { |
| 2176 | if (ea) |
| 2177 | *ea = (char *) m; |
| 2178 | return monthtab[ix].val; |
| 2179 | } |
| 2180 | if (to_uchar (fold_toupper[to_uchar (*m)]) < to_uchar (*n)) |
| 2181 | { |
| 2182 | hi = ix; |
| 2183 | break; |
| 2184 | } |
| 2185 | else if (to_uchar (fold_toupper[to_uchar (*m)]) > to_uchar (*n)) |
| 2186 | { |
| 2187 | lo = ix + 1; |
| 2188 | break; |
| 2189 | } |
| 2190 | } |
| 2191 | } |
| 2192 | while (lo < hi); |
| 2193 | |
| 2194 | return 0; |
| 2195 | } |
| 2196 | |
| 2197 | /* When using the OpenSSL implementation, dynamically link only if -R. |
| 2198 | This saves startup time in the usual (sans -R) case. */ |
no test coverage detected