From: Peter Kümmel Date: Sat, 10 Jun 2006 07:05:21 +0000 (+0000) Subject: fix crash on startup under windows by avoiding the call X-Git-Tag: 1.6.10~13129 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=df04880e55cc07568271f638728700412058e827;p=features.git fix crash on startup under windows by avoiding the call setlocale(LC_MESSAGES, ... scons tests on LC_MESSAGES there is also an m4 file for LC_MESSAGES so I think all build systems handle HAVE_LC_MESSAGES. Index: src/messages.C =================================================================== --- src/messages.C (revision 14066) +++ src/messages.C (working copy) @@ -90,7 +90,10 @@ : lang_(l) { if ( lang_.empty() ) { - char const * lc_msgs = setlocale(LC_MESSAGES, NULL); + char const * lc_msgs = 0; +#ifdef HAVE_LC_MESSAGES + lc_msgs = setlocale(LC_MESSAGES, NULL); +#endif lang_ = lc_msgs ? lc_msgs : ""; } // strip off any encoding suffix, i.e., assume 8-bit po files @@ -117,8 +120,9 @@ lang = "C"; } } - +#ifdef HAVE_LC_MESSAGES char const * lc_msgs = setlocale(LC_MESSAGES, lang_.c_str()); +#endif // setlocale fails (returns NULL) if the corresponding locale // is not installed. // On windows (mingw) it always returns NULL. @@ -164,7 +168,9 @@ boost::smatch sub; if (regex_match(translated, sub, reg)) translated = sub.str(1); +#ifdef HAVE_LC_MESSAGES setlocale(LC_MESSAGES, lang.c_str()); +#endif setlocale(LC_CTYPE, oldCTYPE.c_str()); return translated; } git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14067 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/messages.C b/src/messages.C index 6afef3c0d9..fbab556bcb 100644 --- a/src/messages.C +++ b/src/messages.C @@ -90,7 +90,10 @@ public: : lang_(l) { if ( lang_.empty() ) { - char const * lc_msgs = setlocale(LC_MESSAGES, NULL); + char const * lc_msgs = 0; +#ifdef HAVE_LC_MESSAGES + lc_msgs = setlocale(LC_MESSAGES, NULL); +#endif lang_ = lc_msgs ? lc_msgs : ""; } // strip off any encoding suffix, i.e., assume 8-bit po files @@ -117,8 +120,9 @@ public: lang = "C"; } } - +#ifdef HAVE_LC_MESSAGES char const * lc_msgs = setlocale(LC_MESSAGES, lang_.c_str()); +#endif // setlocale fails (returns NULL) if the corresponding locale // is not installed. // On windows (mingw) it always returns NULL. @@ -164,7 +168,9 @@ public: boost::smatch sub; if (regex_match(translated, sub, reg)) translated = sub.str(1); +#ifdef HAVE_LC_MESSAGES setlocale(LC_MESSAGES, lang.c_str()); +#endif setlocale(LC_CTYPE, oldCTYPE.c_str()); return translated; }