| 1251 | }; |
| 1252 | |
| 1253 | static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm *now, int *num, int *touched) |
| 1254 | { |
| 1255 | const struct typelen *tl; |
| 1256 | const struct special *s; |
| 1257 | const char *end = date; |
| 1258 | int i; |
| 1259 | |
| 1260 | while (isalpha(*++end)) |
| 1261 | ; |
| 1262 | |
| 1263 | for (i = 0; i < 12; i++) { |
| 1264 | int match = match_string(date, month_names[i]); |
| 1265 | if (match >= 3) { |
| 1266 | tm->tm_mon = i; |
| 1267 | *touched = 1; |
| 1268 | return end; |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | for (s = special; s->name; s++) { |
| 1273 | size_t len = strlen(s->name); |
| 1274 | if (match_string(date, s->name) == len) { |
| 1275 | s->fn(tm, now, num); |
| 1276 | *touched = 1; |
| 1277 | return end; |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | if (!*num) { |
| 1282 | for (i = 1; i < 11; i++) { |
| 1283 | size_t len = strlen(number_name[i]); |
| 1284 | if (match_string(date, number_name[i]) == len) { |
| 1285 | *num = i; |
| 1286 | *touched = 1; |
| 1287 | return end; |
| 1288 | } |
| 1289 | } |
| 1290 | if (match_string(date, "last") == 4) { |
| 1291 | *num = 1; |
| 1292 | *touched = 1; |
| 1293 | } |
| 1294 | return end; |
| 1295 | } |
| 1296 | |
| 1297 | tl = typelen; |
| 1298 | while (tl->type) { |
| 1299 | size_t len = strlen(tl->type); |
| 1300 | if (match_string(date, tl->type) >= len-1) { |
| 1301 | update_tm(tm, now, tl->length * *num); |
| 1302 | *num = 0; |
| 1303 | *touched = 1; |
| 1304 | return end; |
| 1305 | } |
| 1306 | tl++; |
| 1307 | } |
| 1308 | |
| 1309 | for (i = 0; i < 7; i++) { |
| 1310 | int match = match_string(date, weekday_names[i]); |
no test coverage detected