mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Save and restore old locale when manipulating via setlocale
We shouldn't assume a frontend program didn't explicitly set the LC_TIME setting to a value not in the environment, which is what we previously assumed. Save the old locale before forcing the 'C' locale and restore it when we are done. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
62f828014f
commit
163c36bdcd
@ -1170,12 +1170,16 @@ alpm_time_t _alpm_parsedate(const char *line)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if(isalpha((unsigned char)line[0])) {
|
if(isalpha((unsigned char)line[0])) {
|
||||||
|
const char *oldlocale;
|
||||||
/* initialize to null in case of failure */
|
/* initialize to null in case of failure */
|
||||||
struct tm tmp_tm;
|
struct tm tmp_tm;
|
||||||
memset(&tmp_tm, 0, sizeof(struct tm));
|
memset(&tmp_tm, 0, sizeof(struct tm));
|
||||||
|
|
||||||
|
oldlocale = setlocale(LC_TIME, NULL);
|
||||||
setlocale(LC_TIME, "C");
|
setlocale(LC_TIME, "C");
|
||||||
strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm);
|
strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm);
|
||||||
setlocale(LC_TIME, "");
|
setlocale(LC_TIME, oldlocale);
|
||||||
|
|
||||||
return (alpm_time_t)mktime(&tmp_tm);
|
return (alpm_time_t)mktime(&tmp_tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user