|
From: <got...@us...> - 2009-09-26 14:45:50
|
Revision: 380
http://scstudio.svn.sourceforge.net/scstudio/?rev=380&view=rev
Author: gotthardp
Date: 2009-09-26 14:27:43 +0000 (Sat, 26 Sep 2009)
Log Message:
-----------
Bugfix: CRT locale was not synchronized with Windows locale. This caused error when exporting MSC to a directory with locale characters.
Modified Paths:
--------------
trunk/doc/help/algorithms.html
trunk/src/view/visio/addon/dllmodule.cpp
Modified: trunk/doc/help/algorithms.html
===================================================================
--- trunk/doc/help/algorithms.html 2009-09-26 12:40:09 UTC (rev 379)
+++ trunk/doc/help/algorithms.html 2009-09-26 14:27:43 UTC (rev 380)
@@ -8,7 +8,7 @@
<ul>
<li><a href="acyclic/acyclic.html">Acyclic property</a></li>
<li><a href="fifo/fifo.html">FIFO property</a></li>
-<li><a href="localChoice/localchoice.html">Nonlocal Choice</a></li>
+<li><a href="localchoice/localchoice.html">Nonlocal Choice</a></li>
<li><a href="membership/membership_documentation.html">Membership</a></li>
</ul>
</body>
Modified: trunk/src/view/visio/addon/dllmodule.cpp
===================================================================
--- trunk/src/view/visio/addon/dllmodule.cpp 2009-09-26 12:40:09 UTC (rev 379)
+++ trunk/src/view/visio/addon/dllmodule.cpp 2009-09-26 14:27:43 UTC (rev 380)
@@ -87,7 +87,6 @@
TCHAR szFileName[_MAX_PATH];
TCHAR szExt[_MAX_PATH];
std::basic_string<TCHAR> strDir;
- std::basic_string<TCHAR>::size_type uiPosition;
// get the full path including the Addon name
GetModuleFileName(GetModuleHandle(LoadStringResource(IDS_VSL_NAME).c_str()),
@@ -104,6 +103,40 @@
return strDir;
}
+// Creates a locale string acceptable for setlocale
+// see http://www.codeproject.com/KB/locale/CRTSynch.aspx
+// public domain, written by Chris Grimes
+LPCTSTR loadLocaleId(LCID lcid, _bstr_t& bstrRetBuf)
+{
+ TCHAR arcBuf[128];
+ memset(arcBuf, 0, sizeof(arcBuf));
+
+ // loading the English name fo the locale
+ GetLocaleInfo( lcid, LOCALE_SENGLANGUAGE, arcBuf, 127);
+ bstrRetBuf = arcBuf;
+ memset(arcBuf, 0, sizeof(arcBuf));
+
+ // loading the English name for the country/region
+ GetLocaleInfo( lcid, LOCALE_SENGCOUNTRY, arcBuf, 127);
+ if( *arcBuf )
+ {
+ bstrRetBuf += TEXT("_");
+ bstrRetBuf += arcBuf;
+ }
+
+ // loading the code page
+ memset(arcBuf, 0, sizeof(arcBuf));
+ if( (GetLocaleInfo( lcid, LOCALE_IDEFAULTANSICODEPAGE, arcBuf, 127)
+ || GetLocaleInfo( lcid, LOCALE_IDEFAULTCODEPAGE, arcBuf, 127))
+ && *arcBuf )
+ {
+ bstrRetBuf += TEXT(".");
+ bstrRetBuf += arcBuf;
+ }
+
+ return bstrRetBuf;
+}
+
class RegistryValueNotFound
{ };
@@ -185,6 +218,15 @@
//! DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID lpReserved)
{
+ // early initialization of our subsystems
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _bstr_t localeName;
+ loadLocaleId(GetThreadLocale(), localeName);
+ // keep the C-runtime (CRT) in synch with the Windows API locale locale
+ setlocale(LC_ALL, localeName);
+ }
+
return _AtlModule.DllMain(dwReason, lpReserved);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|