[mapguide-commits] r10265 - branches/4.0/MgDev/Portable/MgPortable/System
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Nov 4 17:02:07 PST 2026
Author: jng
Date: 2026-11-04 17:02:06 -0800 (Wed, 04 Nov 2026)
New Revision: 10265
Modified:
branches/4.0/MgDev/Portable/MgPortable/System/PlatformInit.cpp
Log:
#2897: Setup NLSPATH internally for MgPortable init
Modified: branches/4.0/MgDev/Portable/MgPortable/System/PlatformInit.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/System/PlatformInit.cpp 2026-11-04 10:34:11 UTC (rev 10264)
+++ branches/4.0/MgDev/Portable/MgPortable/System/PlatformInit.cpp 2026-11-05 01:02:06 UTC (rev 10265)
@@ -121,6 +121,63 @@
void* hlib = NULL;
string updatedPath;
+ // FDO resolves its messages with catopen(), which looks the catalogue up through NLSPATH, and
+ // the SDK installs the catalogues beside the library directory rather than inside it. A
+ // consumer of MgPortable should not have to know either of those, so derive the location from
+ // the configured FdoPath and prepend it to NLSPATH. Without this every message falls back to
+ // its raw symbol (FDOSM_220 rather than English text).
+ {
+ // fdoPath is a directory with a trailing slash, normally <fdo root>/lib64/.
+ STRING fdoDir = fdoPath;
+ while (!fdoDir.empty() && (fdoDir[fdoDir.size() - 1] == L'/' || fdoDir[fdoDir.size() - 1] == L'\\'))
+ fdoDir.erase(fdoDir.size() - 1);
+
+ STRING fdoRoot = fdoDir;
+ STRING::size_type lastSep = fdoRoot.find_last_of(L"/\\");
+ if (lastSep != STRING::npos)
+ fdoRoot = fdoRoot.substr(0, lastSep);
+
+ // The SDK installs the catalogues at <root>/nls; a build tree keeps them under
+ // <root>/nls/linux/en_US, and a FdoPath that already points at the root (rather than at
+ // lib64) makes <fdoPath>nls the one that exists. Take whichever are present, because a
+ // pattern for a directory that does not exist is dead weight in the search path.
+ STRING nlsCandidates[3];
+ nlsCandidates[0] = fdoRoot + L"/nls";
+ nlsCandidates[1] = fdoRoot + L"/nls/linux/en_US";
+ nlsCandidates[2] = fdoPath + L"nls";
+
+ STRING nlspath;
+ for (int i = 0; i < 3; i++)
+ {
+ if (nlsCandidates[i].empty() || !MgFileUtil::IsDirectory(nlsCandidates[i]))
+ continue;
+
+ if (!nlspath.empty())
+ nlspath += L":";
+ nlspath += nlsCandidates[i];
+ nlspath += L"/%N";
+ }
+
+ if (!nlspath.empty())
+ {
+ char* existingNlspath = getenv("NLSPATH");
+ if (NULL != existingNlspath && '\0' != existingNlspath[0])
+ {
+ nlspath += L":";
+ nlspath += MgUtil::MultiByteToWideChar(string(existingNlspath));
+ }
+
+ std::string mbNlspath = MgUtil::WideCharToMultiByte(nlspath);
+ setenv("NLSPATH", mbNlspath.c_str(), 1);
+
+ MG_LOG_TRACE_ENTRY(L"NLSPATH = " + nlspath);
+ }
+ else
+ {
+ MG_LOG_TRACE_ENTRY(L"NLSPATH unchanged: no message catalogues under " + fdoRoot + L"/nls");
+ }
+ }
+
char* ldlibpath = getenv("LD_LIBRARY_PATH");
if (ldlibpath != NULL)
{
More information about the mapguide-commits
mailing list