X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fimport%2Fcurl-util.c;h=313b04b0b82e57369bcbb0576dc8d42bbd0289cf;hb=4d858e7d9f39038713f760d7acc64acf7bba2aa7;hp=0c6c8673cc75742bfe268abee5f32056f2e344d2;hpb=c5285fbfcede2e0f54d2b5f14193041067cd2af6;p=elogind.git diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 0c6c8673c..313b04b0b 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -416,29 +416,31 @@ int curl_header_strdup(const void *contents, size_t sz, const char *field, char } int curl_parse_http_time(const char *t, usec_t *ret) { + const char *e; + locale_t loc; struct tm tm; time_t v; assert(t); assert(ret); - RUN_WITH_LOCALE(LC_TIME, "C") { - const char *e; - - /* RFC822 */ - e = strptime(t, "%a, %d %b %Y %H:%M:%S %Z", &tm); - if (!e || *e != 0) - /* RFC 850 */ - e = strptime(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm); - if (!e || *e != 0) - /* ANSI C */ - e = strptime(t, "%a %b %d %H:%M:%S %Y", &tm); - if (!e || *e != 0) - return -EINVAL; - - v = timegm(&tm); - } + loc = newlocale(LC_TIME_MASK, "C", (locale_t) 0); + if (loc == (locale_t) 0) + return -errno; + + /* RFC822 */ + e = strptime_l(t, "%a, %d %b %Y %H:%M:%S %Z", &tm, loc); + if (!e || *e != 0) + /* RFC 850 */ + e = strptime_l(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm, loc); + if (!e || *e != 0) + /* ANSI C */ + e = strptime_l(t, "%a %b %d %H:%M:%S %Y", &tm, loc); + freelocale(loc); + if (!e || *e != 0) + return -EINVAL; + v = timegm(&tm); if (v == (time_t) -1) return -EINVAL;