summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-06-10 17:02:48 (GMT)
committerBrad King <brad.king@kitware.com>2009-06-10 17:02:48 (GMT)
commitfc537f05ba1e5eb13adf27511cddfda216cf0b56 (patch)
tree54bc3cd38eba1a2da034e0d8f25233c17f2dad8e /Source/kwsys
parentb5394e96005b7c2e285eb34196c27555b0ba3a7a (diff)
downloadCMake-fc537f05ba1e5eb13adf27511cddfda216cf0b56.zip
CMake-fc537f05ba1e5eb13adf27511cddfda216cf0b56.tar.gz
CMake-fc537f05ba1e5eb13adf27511cddfda216cf0b56.tar.bz2
ENH: Teach KWSys SystemTools about VMS paths
This teaches ConvertToUnixSlashes to convert VMS paths into posix-style paths. We also set the DECC$FILENAME_UNIX_ONLY feature so the process always sees posix-style paths on disk.
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/SystemTools.cxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 3338820..13a2dc2 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1483,12 +1483,38 @@ kwsys_stl::string SystemTools::EscapeChars(
return n;
}
+#ifdef __VMS
+static void ConvertVMSToUnix(kwsys_stl::string& path)
+{
+ kwsys_stl::string::size_type rootEnd = path.find(":[");
+ kwsys_stl::string::size_type pathEnd = path.find("]");
+ if(rootEnd != path.npos)
+ {
+ kwsys_stl::string root = path.substr(0, rootEnd);
+ kwsys_stl::string pathPart = path.substr(rootEnd+2, pathEnd - rootEnd-2);
+ const char* pathCString = pathPart.c_str();
+ const char* pos0 = pathCString;
+ for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
+ {
+ if ( *pos0 == '.' )
+ {
+ pathPart[pos] = '/';
+ }
+ pos0 ++;
+ }
+ path = "/"+ root + "/" + pathPart;
+ }
+}
+#endif
+
// convert windows slashes to unix slashes
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
{
const char* pathCString = path.c_str();
bool hasDoubleSlash = false;
-
+#ifdef __VMS
+ ConvertVMSToUnix(path);
+#else
const char* pos0 = pathCString;
const char* pos1 = pathCString+1;
for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
@@ -1522,7 +1548,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
{
SystemTools::ReplaceString(path, "//", "/");
}
-
+#endif
// remove any trailing slash
if(!path.empty())
{
@@ -4534,8 +4560,25 @@ SystemToolsManager::~SystemToolsManager()
}
}
+#if defined(__VMS)
+// On VMS we configure the run time C library to be more UNIX like.
+// http://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
+extern "C" int decc$feature_get_index(char *name);
+extern "C" int decc$feature_set_value(int index, int mode, int value);
+static int SetVMSFeature(char* name, int value)
+{
+ int i;
+ errno = 0;
+ i = decc$feature_get_index(name);
+ return i >= 0 && (decc$feature_set_value(i, 1, value) >= 0 || errno == 0);
+}
+#endif
+
void SystemTools::ClassInitialize()
{
+#ifdef __VMS
+ SetVMSFeature("DECC$FILENAME_UNIX_ONLY", 1);
+#endif
// Allocate the translation map first.
SystemTools::TranslationMap = new SystemToolsTranslationMap;
SystemTools::LongPathMap = new SystemToolsTranslationMap;