diff options
author | Cristian RodrÃguez <crrodriguez@opensuse.org> | 2015-01-15 02:27:34 -0300 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2015-01-18 22:08:44 +0100 |
commit | 0193ad26ba121f3df259cc8b3bab54a99b8e5252 (patch) | |
tree | b30bd4d5785661534b0db293c7e7ef89f0b4635b /src/import/curl-util.c | |
parent | 43fcd650e5cb0836cfc9f667ed74b3bc0283a81c (diff) |
util: replace RUN_WITH_LOCALE with extended locale functions
There were two callers, one can use strtod_l() and the other strptime_l().
(David: fix up commit-msg and coding-style)
Diffstat (limited to 'src/import/curl-util.c')
-rw-r--r-- | src/import/curl-util.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 0c6c8673cc..313b04b0b8 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; |