diff options
Diffstat (limited to 'winsup/utils/tzset.c')
-rw-r--r-- | winsup/utils/tzset.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/winsup/utils/tzset.c b/winsup/utils/tzset.c index a3abe315e..45f3f1655 100644 --- a/winsup/utils/tzset.c +++ b/winsup/utils/tzset.c @@ -1,6 +1,6 @@ /* tzset.c: Convert current Windows timezone to POSIX timezone information. - Copyright 2012 Red Hat, Inc. + Copyright 2012, 2013 Red Hat, Inc. This file is part of Cygwin. @@ -10,6 +10,7 @@ details. */ #include <errno.h> #include <stdio.h> +#include <inttypes.h> #include <wchar.h> #include <locale.h> #include <getopt.h> @@ -518,8 +519,8 @@ reg_open (HKEY pkey, PCWSTR path, const char *msg) if (ret == ERROR_SUCCESS) return hkey; if (msg) - fprintf (stderr, "%s: cannot open registry %s, error code %ld\n", - program_invocation_short_name, msg, ret); + fprintf (stderr, "%s: cannot open registry %s, error code %" PRIu32 "\n", + program_invocation_short_name, msg, (unsigned int) ret); return NULL; } @@ -536,8 +537,8 @@ reg_query (HKEY hkey, PCWSTR value, PWCHAR buf, DWORD size, const char *msg) if (ret == ERROR_SUCCESS) return TRUE; if (msg) - fprintf (stderr, "%s: cannot query registry %s, error code %ld\n", - program_invocation_short_name, msg, ret); + fprintf (stderr, "%s: cannot query registry %s, error code %" PRIu32 "\n", + program_invocation_short_name, msg, (unsigned int) ret); return FALSE; } @@ -709,10 +710,12 @@ main (int argc, char **argv) } idx = gotit; } - /* Got one. Print it. */ - spc = wcschr (tzmap[idx].posix_tzid, ' '); - if (spc) - *spc = L'\0'; - printf ("%ls\n", tzmap[idx].posix_tzid); + /* Got one. Print it. + Note: The tzmap array is in the R/O data section on x86_64. Don't + try to overwrite the space, as the code did originally. */ + spc = wcschr (tzmap[idx].posix_tzid, L' '); + if (!spc) + spc = wcschr (tzmap[idx].posix_tzid, L'\0'); + printf ("%.*ls\n", (int) (spc - tzmap[idx].posix_tzid), tzmap[idx].posix_tzid); return 0; } |