Fix crossgen command line handling on Unix
authorJan Kotas <jkotas@microsoft.com>
Thu, 24 Sep 2015 04:30:35 +0000 (21:30 -0700)
committerJan Kotas <jkotas@microsoft.com>
Thu, 24 Sep 2015 04:30:35 +0000 (21:30 -0700)
Replace hardcoded Windows directory and path separators with symbolic
constants.

src/inc/palclr.h
src/pal/inc/rt/palrt.h
src/tools/crossgen/crossgen.cpp

index 9842bc4..26d882d 100644 (file)
@@ -91,6 +91,7 @@
 #define DIRECTORY_SEPARATOR_STR_W W("\\")
 
 #define PATH_SEPARATOR_CHAR_W W(';')
+#define PATH_SEPARATOR_STR_W W(";")
 
 // PAL Macros
 // Not all compilers support fully anonymous aggregate types, so the
index 92d9b3a..b969047 100644 (file)
@@ -1364,11 +1364,13 @@ typedef VOID (__stdcall *WAITORTIMERCALLBACK)(PVOID, BOOLEAN);
 #define DIRECTORY_SEPARATOR_CHAR_W W('/')
 #define DIRECTORY_SEPARATOR_STR_W W("/")
 #define PATH_SEPARATOR_CHAR_W W(':')
+#define PATH_SEPARATOR_STR_W W(":")
 #else // PLATFORM_UNIX
 #define DIRECTORY_SEPARATOR_CHAR_A '\\'
 #define DIRECTORY_SEPARATOR_CHAR_W W('\\')
 #define DIRECTORY_SEPARATOR_STR_W W("\\")
 #define PATH_SEPARATOR_CHAR_W W(';')
+#define PATH_SEPARATOR_STR_W W(";")
 #endif // PLATFORM_UNIX
 
 #ifndef IMAGE_IMPORT_DESC_FIELD
index 192f6b1..9bdfdd7 100644 (file)
@@ -282,7 +282,7 @@ bool ComputeMscorlibPathFromTrustedPlatformAssemblies(LPWSTR pwzMscorlibPath, DW
 {
     LPWSTR wszTrustedPathCopy = new WCHAR[wcslen(pwzTrustedPlatformAssemblies) + 1];
     wcscpy_s(wszTrustedPathCopy, wcslen(pwzTrustedPlatformAssemblies) + 1, pwzTrustedPlatformAssemblies);
-    LPWSTR wszSingleTrustedPath = wcstok(wszTrustedPathCopy, W(";"));
+    LPWSTR wszSingleTrustedPath = wcstok(wszTrustedPathCopy, PATH_SEPARATOR_STR_W);
     
     while (wszSingleTrustedPath != NULL)
     {
@@ -294,12 +294,12 @@ bool ComputeMscorlibPathFromTrustedPlatformAssemblies(LPWSTR pwzMscorlibPath, DW
             wszSingleTrustedPath++;
         }
 
-        if (StringEndsWith(wszSingleTrustedPath, W("\\mscorlib.dll")) ||
-            StringEndsWith(wszSingleTrustedPath, W("\\mscorlib.ni.dll")))
+        if (StringEndsWith(wszSingleTrustedPath, DIRECTORY_SEPARATOR_STR_W W("mscorlib.dll")) ||
+            StringEndsWith(wszSingleTrustedPath, DIRECTORY_SEPARATOR_STR_W W("mscorlib.ni.dll")))
         {
             wcscpy_s(pwzMscorlibPath, cbMscorlibPath, wszSingleTrustedPath);
             
-            LPWSTR pwzSeparator = wcsrchr(pwzMscorlibPath, W('\\'));
+            LPWSTR pwzSeparator = wcsrchr(pwzMscorlibPath, DIRECTORY_SEPARATOR_CHAR_W);
             if (pwzSeparator == NULL)
             {
                 delete [] wszTrustedPathCopy;
@@ -311,7 +311,7 @@ bool ComputeMscorlibPathFromTrustedPlatformAssemblies(LPWSTR pwzMscorlibPath, DW
             return true;
         }
         
-        wszSingleTrustedPath = wcstok(NULL, W(";"));
+        wszSingleTrustedPath = wcstok(NULL, PATH_SEPARATOR_STR_W);
     }
     delete [] wszTrustedPathCopy;
 
@@ -370,7 +370,7 @@ void PopulateTPAList(SString path, LPCWSTR pwszMask, SString &refTPAList, bool f
                 if (fAddDelimiter)
                 {
                     // Add the path delimiter if we already have entries in the TPAList
-                    refTPAList.Append(W(";"));
+                    refTPAList.Append(PATH_SEPARATOR_CHAR_W);
                 }
                 // Add the path to the TPAList
                 refTPAList.Append(path);
@@ -400,7 +400,7 @@ void ComputeTPAListFromPlatformAssembliesPath(LPCWSTR pwzPlatformAssembliesPaths
         while (itr != end)
         {
             start = itr;
-            BOOL found = ssPlatformAssembliesPath.Find(itr, W(';'));
+            BOOL found = ssPlatformAssembliesPath.Find(itr, PATH_SEPARATOR_CHAR_W);
             if (!found)
             {
                 itr = end;
@@ -417,9 +417,9 @@ void ComputeTPAListFromPlatformAssembliesPath(LPCWSTR pwzPlatformAssembliesPaths
 
             if (len > 0)
             {
-                if (qualifiedPath[len-1]!='\\')
+                if (qualifiedPath[len-1]!=DIRECTORY_SEPARATOR_CHAR_W)
                 {
-                    qualifiedPath.Append('\\');
+                    qualifiedPath.Append(DIRECTORY_SEPARATOR_CHAR_W);
                 }
 
                 // Enumerate the EXE/DLL modules within this path and add them to the TPAList