diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-10-05 20:18:55 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-10-05 20:18:55 +0200 |
commit | 028e87cf0ed808cb24207e6334afb6fdc8031fcd (patch) | |
tree | 02f4d21fb804088dd21e8138d9bada7b0bab7f3a | |
parent | 5b9edabaf6ef8ebddfcbef0a647388576d5790cf (diff) |
sfeed: parsetime: weekday part in RFC822 time is optional
noticed in "RMS notes" RSS.
-rw-r--r-- | sfeed.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -434,7 +434,7 @@ parsetime(const char *s, time_t *tp) if (!isdigit((unsigned char)*s) && !isalpha((unsigned char)*s)) return -1; - if (isdigit((unsigned char)*s)) { + if (strspn(s, "0123456789") == 4) { /* format "%Y-%m-%d %H:%M:%S" or "%Y-%m-%dT%H:%M:%S" */ vi = 0; time: @@ -454,16 +454,16 @@ time: ; } end = s; - } else if (isalpha((unsigned char)*s)) { - /* format: "%a, %d %b %Y %H:%M:%S" */ - /* parse "%a, %d %b %Y " part, then use time parsing as above */ + } else { + /* format: "[%a, ]%d %b %Y %H:%M:%S" */ + /* parse "[%a, ]%d %b %Y " part, then use time parsing as above */ for (; *s && isalpha((unsigned char)*s); s++) ; for (; *s && isspace((unsigned char)*s); s++) ; - if (*s != ',') - return -1; - for (s++; *s && isspace((unsigned char)*s); s++) + if (*s == ',') + s++; + for (; *s && isspace((unsigned char)*s); s++) ; for (v = 0, i = 0; *s && i < 4 && isdigit((unsigned char)*s); s++, i++) v = (v * 10) + (*s - '0'); @@ -497,8 +497,6 @@ time: /* parse regular time, see above */ vi = 3; goto time; - } else { - return -1; } /* invalid range */ |