From 87c0903113e795eec917464e3a0e70d6d9a3037f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 11 Feb 2010 10:04:51 +0000 Subject: * nlsfuncs.cc (initial_setlocale): Move check whether charset has changed from here... (internal_setlocale): ...to here, to avoid unnecessary work when invoked via CW_INT_SETLOCALE. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/nlsfuncs.cc | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3221fd1e2..39e72d4a7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2010-02-11 Andy Koppe + + * nlsfuncs.cc (initial_setlocale): Move check whether charset has + changed from here... + (internal_setlocale): ...to here, to avoid unnecessary work when invoked + via CW_INT_SETLOCALE. + 2010-02-10 Corinna Vinschen * nlsfuncs.cc (__set_charset_from_locale): Allow "@euro" modifier only diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc index 5fa767b84..8444768b6 100644 --- a/winsup/cygwin/nlsfuncs.cc +++ b/winsup/cygwin/nlsfuncs.cc @@ -1129,12 +1129,17 @@ internal_setlocale () /* FIXME: It could be necessary to convert the entire environment, not just PATH. */ tmp_pathbuf tp; - char *path = getenv ("PATH"); + char *path; wchar_t *w_path = NULL, *w_cwd; + /* Don't do anything if the charset hasn't actually changed. */ + if (strcmp (cygheap->locale.charset, __locale_charset ()) == 0) + return; + debug_printf ("Cygwin charset changed from %s to %s", cygheap->locale.charset, __locale_charset ()); /* Fetch PATH and CWD and convert to wchar_t in previous charset. */ + path = getenv ("PATH"); if (path && *path) /* $PATH can be potentially unset. */ { w_path = tp.w_get (); @@ -1175,8 +1180,7 @@ void initial_setlocale () { char *ret = _setlocale_r (_REENT, LC_CTYPE, ""); - if (ret && check_codepage (ret) - && strcmp (cygheap->locale.charset, __locale_charset ()) != 0) + if (ret && check_codepage (ret)) internal_setlocale (); } -- cgit v1.2.3