From c7a2c80c178457b4d8a1525a6b0ccff9ca4e5afa Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Tue, 29 Mar 2005 08:09:47 -0500
Subject: ENH: SplitPath now supports slashes in both directions in the input
 path but still produces forward slashes in the root component.

---
 Source/kwsys/SystemTools.cxx    | 6 +++---
 Source/kwsys/SystemTools.hxx.in | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 25676ee..c508e38 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2240,7 +2240,7 @@ void SystemTools::SplitPath(const char* p,
   components.clear();
   // Identify the root component.
   const char* c = p;
-  if(c[0] == '/' && c[1] == '/')
+  if((c[0] == '/' && c[1] == '/') || (c[0] == '\\' && c[1] == '\\'))
     {
     // Network path.
     components.push_back("//");
@@ -2252,7 +2252,7 @@ void SystemTools::SplitPath(const char* p,
     components.push_back("/");
     c += 1;
     }
-  else if(c[0] && c[1] == ':' && c[2] == '/')
+  else if(c[0] && c[1] == ':' && (c[2] == '/' || c[2] == '\\'))
     {
     // Windows path.
     kwsys_stl::string root = "_:/";
@@ -2279,7 +2279,7 @@ void SystemTools::SplitPath(const char* p,
   const char* last = first;
   for(;*last; ++last)
     {
-    if(*last == '/')
+    if(*last == '/' || *last == '\\')
       {
       // End of a component.  Save it.
       components.push_back(kwsys_stl::string(first, last-first));
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 2656e33..0a1d6db 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -292,8 +292,7 @@ public:
    * The remaining components form the path.  If there is a trailing
    * slash then the last component is the empty string.  The
    * components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to
-   * produce the original path.  The input is assumed to be formatted
-   * with forward slashes.
+   * produce the original path.
    */
   static void SplitPath(const char* p,
                         kwsys_stl::vector<kwsys_stl::string>& components);
-- 
cgit v0.12