mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
w32: Fix strftime problem on Windows.
* common/gettime.c: Include locale.h. (asctimestamp): Increase buffer. On Windows use setlocale. -- GnuPG-bug-id: 5073 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d1f2a6d9f7
commit
e8aae18b99
@ -31,6 +31,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#ifdef HAVE_LOCALE_H
|
||||||
|
#include <locale.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_LANGINFO_H
|
#ifdef HAVE_LANGINFO_H
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#endif
|
#endif
|
||||||
@ -679,9 +682,9 @@ isotimestamp (u32 stamp)
|
|||||||
const char *
|
const char *
|
||||||
asctimestamp (u32 stamp)
|
asctimestamp (u32 stamp)
|
||||||
{
|
{
|
||||||
static char buffer[50];
|
static char buffer[80];
|
||||||
#if defined (HAVE_STRFTIME) && defined (HAVE_NL_LANGINFO)
|
#if defined (HAVE_STRFTIME) && defined (HAVE_NL_LANGINFO)
|
||||||
static char fmt[50];
|
static char fmt[80];
|
||||||
#endif
|
#endif
|
||||||
struct tm *tp;
|
struct tm *tp;
|
||||||
time_t atime = stamp;
|
time_t atime = stamp;
|
||||||
@ -707,6 +710,32 @@ asctimestamp (u32 stamp)
|
|||||||
zone at all. */
|
zone at all. */
|
||||||
strftime (buffer, DIM(buffer)-1, "%c", tp);
|
strftime (buffer, DIM(buffer)-1, "%c", tp);
|
||||||
# else
|
# else
|
||||||
|
# if HAVE_W32_SYSTEM
|
||||||
|
{
|
||||||
|
static int done;
|
||||||
|
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
/* The locale names as used by Windows are in the form
|
||||||
|
* "German_Germany.1252" or "German_Austria.1252" with
|
||||||
|
* alternate names similar to Unix, e.g. "de-DE". However
|
||||||
|
* that is the theory. On current Windows and Mingw the
|
||||||
|
* alternate names do not work. We would need a table to map
|
||||||
|
* them from the short names as provided by gpgrt to the long
|
||||||
|
* names and append some code page. For now we use "" and
|
||||||
|
* take the locale from the user's system settings. Thus the
|
||||||
|
* standard Unix envvars don't work for time and may mismatch
|
||||||
|
* with the string translations. The new UCRT available since
|
||||||
|
* 2018 has a lot of additional support but that will for sure
|
||||||
|
* break other things. We should move to ISO strings to get
|
||||||
|
* rid of such problems. */
|
||||||
|
setlocale (LC_TIME, "");
|
||||||
|
done = 1;
|
||||||
|
/* log_debug ("LC_ALL now '%s'\n", setlocale (LC_ALL, NULL)); */
|
||||||
|
/* log_debug ("LC_TIME now '%s'\n", setlocale (LC_TIME, NULL)); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
/* FIXME: we should check whether the locale appends a " %Z" These
|
/* FIXME: we should check whether the locale appends a " %Z" These
|
||||||
* locales from glibc don't put the " %Z": fi_FI hr_HR ja_JP lt_LT
|
* locales from glibc don't put the " %Z": fi_FI hr_HR ja_JP lt_LT
|
||||||
* lv_LV POSIX ru_RU ru_SU sv_FI sv_SE zh_CN. */
|
* lv_LV POSIX ru_RU ru_SU sv_FI sv_SE zh_CN. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user