- 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;