From 41d184bb62b3960530c93a98a876eb2896f98d7b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 14 Jan 2010 18:56:24 +0000 Subject: [PATCH] * dcrt0.cc (dll_crt0_1): Reset locale to "C" at the last moment before calling the application's main. * syscalls.cc (internal_setlocale): Don't reset locale to "C here. Change comment accordingly. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/dcrt0.cc | 2 ++ winsup/cygwin/syscalls.cc | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 438de2dde..142044f2c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2010-01-14 Corinna Vinschen + + * dcrt0.cc (dll_crt0_1): Reset locale to "C" at the last moment before + calling the application's main. + * syscalls.cc (internal_setlocale): Don't reset locale to "C here. + Change comment accordingly. + 2010-01-14 Corinna Vinschen * cygwin.din (dup3): Export. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 663b9f93d..f1f904ac7 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -940,6 +940,8 @@ dll_crt0_1 (void *) do this for noncygwin case since the signal thread is blocked due to LoadLibrary serialization. */ ld_preload (); + /* Per POSIX set the default application locale back to "C". */ + _setlocale_r (_REENT, LC_CTYPE, "C"); if (user_data->main) cygwin_exit (user_data->main (__argc, __argv, *user_data->envptr)); __asm__ (" \n\ diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index bd3308a42..fb39a5d77 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -4362,10 +4362,11 @@ internal_setlocale () } } -/* Called from dll_crt0_1, before calling the application's main(). +/* Called from dll_crt0_1, before fetching the command line from Windows. Set the internal charset according to the environment locale settings. Check if a required codepage is available, and only switch internal - charset if so. Afterwards, reset application locale to "C" per POSIX. */ + charset if so. + Make sure to reset the application locale to "C" per POSIX. */ void initial_setlocale () { @@ -4373,7 +4374,6 @@ initial_setlocale () if (ret && check_codepage (ret) && strcmp (cygheap->locale.charset, __locale_charset ()) != 0) internal_setlocale (); - _setlocale_r (_REENT, LC_CTYPE, "C"); } /* Like newlib's setlocale, but additionally check if the charset needs -- 2.43.5