[cmake-commits] hoffman committed CMakeLists.txt 1.96.2.2 1.96.2.3 CommandLineArguments.cxx 1.21.4.2 1.21.4.3 Configure.h.in 1.6 1.6.24.1 Directory.cxx 1.17.4.1 1.17.4.2 Glob.cxx 1.8.4.1 1.8.4.2 Glob.hxx.in 1.4 1.4.4.1 Process.h.in 1.24.24.1 1.24.24.2 ProcessUNIX.c 1.54.6.1 1.54.6.2 ProcessWin32.c 1.58.4.2 1.58.4.3 Registry.cxx 1.19.4.1 1.19.4.2 SharedForward.h.in 1.5 1.5.20.1 SystemTools.cxx 1.157.2.8 1.157.2.9 SystemTools.hxx.in 1.59.2.2 1.59.2.3 Terminal.c 1.4.4.3 1.4.4.4 testCommandLineArguments.cxx 1.5.6.1 1.5.6.2 testCommandLineArguments1.cxx 1.3.2.1 1.3.2.2 testProcess.c 1.31.6.1 1.31.6.2 testSystemTools.cxx 1.9.6.1 1.9.6.2

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Oct 13 10:52:10 EDT 2006


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv31017/Source/kwsys

Modified Files:
      Tag: CMake-2-4
	CMakeLists.txt CommandLineArguments.cxx Configure.h.in 
	Directory.cxx Glob.cxx Glob.hxx.in Process.h.in ProcessUNIX.c 
	ProcessWin32.c Registry.cxx SharedForward.h.in SystemTools.cxx 
	SystemTools.hxx.in Terminal.c testCommandLineArguments.cxx 
	testCommandLineArguments1.cxx testProcess.c 
	testSystemTools.cxx 
Log Message:
ENH: merge changes from the main tree to the 2.4 branch


Index: Configure.h.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Configure.h.in,v
retrieving revision 1.6
retrieving revision 1.6.24.1
diff -u -d -r1.6 -r1.6.24.1
--- Configure.h.in	26 Jul 2005 15:34:57 -0000	1.6
+++ Configure.h.in	13 Oct 2006 14:52:07 -0000	1.6.24.1
@@ -22,6 +22,46 @@
 # define kwsysEXPORT @KWSYS_NAMESPACE at _EXPORT
 #endif
 
+/* Whether Large File Support is requested.  */
+#define @KWSYS_NAMESPACE at _LFS_REQUESTED @KWSYS_LFS_REQUESTED@
+
+/* Whether Large File Support is available.  */
+#if @KWSYS_NAMESPACE at _LFS_REQUESTED
+# define @KWSYS_NAMESPACE at _LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
+#endif
+
+/* Setup Large File Support if requested.  */
+#if @KWSYS_NAMESPACE at _LFS_REQUESTED
+  /* Since LFS is requested this header must be included before system
+     headers whether or not LFS is available. */
+# if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
+#  error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
+# endif
+  /* Enable the large file API if it is available.  */
+# if @KWSYS_NAMESPACE at _LFS_AVAILABLE && \
+     !defined(@KWSYS_NAMESPACE at _LFS_NO_DEFINES)
+#  if !defined(_LARGEFILE_SOURCE) && \
+      !defined(@KWSYS_NAMESPACE at _LFS_NO_DEFINE_LARGEFILE_SOURCE)
+#   define _LARGEFILE_SOURCE
+#  endif
+#  if !defined(_LARGEFILE64_SOURCE) && \
+      !defined(@KWSYS_NAMESPACE at _LFS_NO_DEFINE_LARGEFILE64_SOURCE)
+#   define _LARGEFILE64_SOURCE
+#  endif
+#  if !defined(_LARGE_FILES) && \
+      !defined(@KWSYS_NAMESPACE at _LFS_NO_DEFINE_LARGE_FILES)
+#   define _LARGE_FILES
+#  endif
+#  if !defined(_FILE_OFFSET_BITS) && \
+      !defined(@KWSYS_NAMESPACE at _LFS_NO_DEFINE_FILE_OFFSET_BITS)
+#   define _FILE_OFFSET_BITS 64
+#  endif
+#  if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
+#   error "_FILE_OFFSET_BITS must be defined to at least 64"
+#  endif
+# endif
+#endif
+
 /* Setup the export macro.  */
 #if defined(_WIN32) && @KWSYS_BUILD_SHARED@
 # if defined(@KWSYS_NAMESPACE at _EXPORTS)

Index: ProcessWin32.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/ProcessWin32.c,v
retrieving revision 1.58.4.2
retrieving revision 1.58.4.3
diff -u -d -r1.58.4.2 -r1.58.4.3
--- ProcessWin32.c	24 Jul 2006 15:19:36 -0000	1.58.4.2
+++ ProcessWin32.c	13 Oct 2006 14:52:07 -0000	1.58.4.3
@@ -13,11 +13,13 @@
 =========================================================================*/
 #include "kwsysPrivate.h"
 #include KWSYS_HEADER(Process.h)
+#include KWSYS_HEADER(System.h)
 
 /* Work-around CMake dependency scanning limitation.  This must
    duplicate the above list of headers.  */
 #if 0
 # include "Process.h.in"
+# include "System.h.in"
 #endif
 
 /*
@@ -63,6 +65,7 @@
 #endif
 
 #if defined(__BORLANDC__)
+# pragma warn -8004 /* assigned a value that is never used  */
 # pragma warn -8060 /* Assignment inside if() condition.  */
 #endif
 
@@ -103,6 +106,8 @@
 static void kwsysProcessDestroy(kwsysProcess* cp, int event);
 static int kwsysProcessSetupOutputPipeFile(PHANDLE handle, const char* name);
 static int kwsysProcessSetupSharedPipe(DWORD nStdHandle, PHANDLE handle);
+static int kwsysProcessSetupPipeNative(PHANDLE handle, HANDLE p[2],
+                                       int isWrite);
 static void kwsysProcessCleanupHandle(PHANDLE h);
 static void kwsysProcessCleanupHandleSafe(PHANDLE h, DWORD nStdHandle);
 static void kwsysProcessCleanup(kwsysProcess* cp, int error);
@@ -245,6 +250,11 @@
   int PipeSharedSTDOUT;
   int PipeSharedSTDERR;
 
+  /* Native pipes provided by the user.  */
+  HANDLE PipeNativeSTDIN[2];
+  HANDLE PipeNativeSTDOUT[2];
+  HANDLE PipeNativeSTDERR[2];
+
   /* Handle to automatically delete the Win9x forwarding executable.  */
   HANDLE Win9xHandle;
 
@@ -788,9 +798,11 @@
     strcpy(*pfile, file);
     }
 
-  /* If we are redirecting the pipe, do not share it.  */
+  /* If we are redirecting the pipe, do not share it or use a native
+     pipe.  */
   if(*pfile)
     {
+    kwsysProcess_SetPipeNative(cp, pipe, 0);
     kwsysProcess_SetPipeShared(cp, pipe, 0);
     }
 
@@ -813,10 +825,51 @@
     default: return;
     }
 
-  /* If we are sharing the pipe, do not redirect it to a file.  */
+  /* If we are sharing the pipe, do not redirect it to a file or use a
+     native pipe.  */
   if(shared)
     {
     kwsysProcess_SetPipeFile(cp, pipe, 0);
+    kwsysProcess_SetPipeNative(cp, pipe, 0);
+    }
+}
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
+{
+  HANDLE* pPipeNative = 0;
+
+  if(!cp)
+    {
+    return;
+    }
+
+  switch(pipe)
+    {
+    case kwsysProcess_Pipe_STDIN: pPipeNative = cp->PipeNativeSTDIN; break;
+    case kwsysProcess_Pipe_STDOUT: pPipeNative = cp->PipeNativeSTDOUT; break;
+    case kwsysProcess_Pipe_STDERR: pPipeNative = cp->PipeNativeSTDERR; break;
+    default: return;
+    }
+
+  /* Copy the native pipe handles provided.  */
+  if(p)
+    {
+    pPipeNative[0] = p[0];
+    pPipeNative[1] = p[1];
+    }
+  else
+    {
+    pPipeNative[0] = 0;
+    pPipeNative[1] = 0;
+    }
+
+  /* If we are using a native pipe, do not share it or redirect it to
+     a file.  */
+  if(p)
+    {
+    kwsysProcess_SetPipeFile(cp, pipe, 0);
+    kwsysProcess_SetPipeShared(cp, pipe, 0);
     }
 }
 
@@ -1018,6 +1071,21 @@
       }
     }
 
+  /* Replace the stderr pipe with the native pipe provided if any.  In
+     this case the pipe thread will still run but never report
+     data.  */
+  if(cp->PipeNativeSTDERR[1])
+    {
+    if(!kwsysProcessSetupPipeNative(&si.StartupInfo.hStdError,
+                                    cp->PipeNativeSTDERR, 1))
+      {
+      kwsysProcessCleanup(cp, 1);
+      kwsysProcessCleanupHandleSafe(&si.StartupInfo.hStdError,
+                                    STD_ERROR_HANDLE);
+      return;
+      }
+    }
+
   /* Create the pipeline of processes.  */
   {
   HANDLE readEnd = 0;
@@ -1620,6 +1688,15 @@
       return 0;
       }
     }
+  else if(cp->PipeNativeSTDIN[0])
+    {
+    /* Use the provided native pipe.  */
+    if(!kwsysProcessSetupPipeNative(&si->StartupInfo.hStdInput,
+                                    cp->PipeNativeSTDIN, 0))
+      {
+      return 0;
+      }
+    }
   else
     {
     /* Explicitly give the child no stdin.  */
@@ -1678,6 +1755,18 @@
       }
     }
 
+  /* Replace the stdout pipe with the native pipe provided if any.  In
+     this case the pipe thread will still run but never report
+     data.  */
+  if(index == cp->NumberOfCommands-1 && cp->PipeNativeSTDOUT[1])
+    {
+    if(!kwsysProcessSetupPipeNative(&si->StartupInfo.hStdOutput,
+                                    cp->PipeNativeSTDOUT, 1))
+      {
+      return 0;
+      }
+    }
+
   /* Create the child process.  */
   {
   BOOL r;
@@ -1927,6 +2016,25 @@
 }
 
 /*--------------------------------------------------------------------------*/
+int kwsysProcessSetupPipeNative(PHANDLE handle, HANDLE p[2], int isWrite)
+{
+  /* Close the existing inherited handle.  */
+  kwsysProcessCleanupHandle(handle);
+
+  /* Create an inherited duplicate of the handle.  This also closes
+     the non-inherited version.  */
+  if(!DuplicateHandle(GetCurrentProcess(), p[isWrite? 1:0],
+                      GetCurrentProcess(), handle,
+                      0, TRUE, (DUPLICATE_CLOSE_SOURCE |
+                                DUPLICATE_SAME_ACCESS)))
+    {
+    return 0;
+    }
+
+  return 1;
+}
+
+/*--------------------------------------------------------------------------*/
 
 /* Close the given handle if it is open.  Reset its value to 0.  */
 void kwsysProcessCleanupHandle(PHANDLE h)
@@ -2085,59 +2193,9 @@
     char const* const* arg;
     for(arg = command; *arg; ++arg)
       {
-      /* Keep track of how many backslashes have been encountered in a
-         row in this argument.  */
-      int backslashes = 0;
-      int spaces = 0;
-      const char* c;
-
-      /* Scan the string for spaces.  If there are no spaces, we can
-         pass the argument verbatim.  */
-      for(c=*arg; *c; ++c)
-        {
-        if(*c == ' ' || *c == '\t')
-          {
-          spaces = 1;
-          break;
-          }
-        }
-
-      /* Add the length of the argument, plus 1 for the space
-         separating the arguments.  */
-      length += (int)strlen(*arg) + 1;
-
-      if(spaces)
-        {
-        /* Add 2 for double quotes since spaces are present.  */
-        length += 2;
-
-        /* Scan the string to find characters that need escaping.  */
-        for(c=*arg; *c; ++c)
-          {
-          if(*c == '\\')
-            {
-            /* Found a backslash.  It may need to be escaped later.  */
-            ++backslashes;
-            }
-          else if(*c == '"')
-            {
-            /* Found a double-quote.  We need to escape it and all
-               immediately preceding backslashes.  */
-            length += backslashes + 1;
-            backslashes = 0;
-            }
-          else
-            {
-            /* Found another character.  This eliminates the possibility
-               that any immediately preceding backslashes will be
-               escaped.  */
-            backslashes = 0;
-            }
-          }
-
-        /* We need to escape all ending backslashes. */
-        length += backslashes;
-        }
+      /* Add the length of this argument.  It already includes room
+         for a separating space or terminating null.  */
+      length += kwsysSystem_Shell_GetArgumentSizeForWindows(*arg, 0);
       }
     }
 
@@ -2160,87 +2218,14 @@
     char const* const* arg;
     for(arg = command; *arg; ++arg)
       {
-      /* Keep track of how many backslashes have been encountered in a
-         row in an argument.  */
-      int backslashes = 0;
-      int spaces = 0;
-      const char* c;
-
-      /* Scan the string for spaces.  If there are no spaces, we can
-         pass the argument verbatim.  */
-      for(c=*arg; *c; ++c)
-        {
-        if(*c == ' ' || *c == '\t')
-          {
-          spaces = 1;
-          break;
-          }
-        }
-
       /* Add the separating space if this is not the first argument.  */
       if(arg != command)
         {
         *cmd++ = ' ';
         }
 
-      if(spaces)
-        {
-        /* Add the opening double-quote for this argument.  */
-        *cmd++ = '"';
-
-        /* Add the characters of the argument, possibly escaping them.  */
-        for(c=*arg; *c; ++c)
-          {
-          if(*c == '\\')
-            {
-            /* Found a backslash.  It may need to be escaped later.  */
-            ++backslashes;
-            *cmd++ = '\\';
-            }
-          else if(*c == '"')
-            {
-            /* Add enough backslashes to escape any that preceded the
-               double-quote.  */
-            while(backslashes > 0)
-              {
-              --backslashes;
-              *cmd++ = '\\';
-              }
-
-            /* Add the backslash to escape the double-quote.  */
-            *cmd++ = '\\';
-
-            /* Add the double-quote itself.  */
-            *cmd++ = '"';
-            }
-          else
-            {
-            /* We encountered a normal character.  This eliminates any
-               escaping needed for preceding backslashes.  Add the
-               character.  */
-            backslashes = 0;
-            *cmd++ = *c;
-            }
-          }
-
-        /* Add enough backslashes to escape any trailing ones.  */
-        while(backslashes > 0)
-          {
-          --backslashes;
-          *cmd++ = '\\';
-          }
-
-        /* Add the closing double-quote for this argument.  */
-        *cmd++ = '"';
-        }
-      else
-        {
-        /* No spaces.  Add the argument verbatim.  */
-        for(c=*arg; *c; ++c)
-          {
-          *cmd++ = *c;
-          }
-        }
+      /* Add the current argument.  */
+      cmd = kwsysSystem_Shell_GetArgumentForWindows(*arg, cmd, 0);
       }
 
     /* Add the terminating null character to the command line.  */

Index: testSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/testSystemTools.cxx,v
retrieving revision 1.9.6.1
retrieving revision 1.9.6.2
diff -u -d -r1.9.6.1 -r1.9.6.2
--- testSystemTools.cxx	26 Jul 2006 12:35:38 -0000	1.9.6.1
+++ testSystemTools.cxx	13 Oct 2006 14:52:08 -0000	1.9.6.2
@@ -29,6 +29,8 @@
 
 #include "testSystemTools.h"
 
+#include <string.h> /* strcmp */
+
 //----------------------------------------------------------------------------
 const char* toUnixPaths[][2] =
 {
@@ -93,7 +95,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool CheckDetectFileType()
+bool CheckFileOperations()
 {
   bool res = true;
 
@@ -114,6 +116,14 @@
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
     res = false;
     }
+  
+  if (kwsys::SystemTools::FileLength(TEST_SYSTEMTOOLS_BIN_FILE) != 766)
+    {
+    kwsys_ios::cerr
+      << "Problem with FileLength - incorrect length for: "
+      << TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
+    res = false;    
+    }
 
   return res;
 }
@@ -156,7 +166,6 @@
     kwsys::SystemTools::AppendStrings("Mary Had A"," Little Lamb.");
   if (strcmp(cres,"Mary Had A Little Lamb."))
     {
-    delete [] cres;
     kwsys_ios::cerr
       << "Problem with AppendStrings "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -168,7 +177,6 @@
     kwsys::SystemTools::AppendStrings("Mary Had"," A ","Little Lamb.");
   if (strcmp(cres,"Mary Had A Little Lamb."))
     {
-    delete [] cres;
     kwsys_ios::cerr
       << "Problem with AppendStrings "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -188,7 +196,6 @@
     kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.","aeiou");
   if (strcmp(cres,"Mry Hd A Lttl Lmb."))
     {
-    delete [] cres;
     kwsys_ios::cerr
       << "Problem with RemoveChars "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -200,7 +207,6 @@
     kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb.");
   if (strcmp(cres,"A"))
     {
-    delete [] cres;
     kwsys_ios::cerr
       << "Problem with RemoveCharsButUpperHex "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -213,7 +219,6 @@
   kwsys::SystemTools::ReplaceChars(cres2,"aeiou",'X');
   if (strcmp(cres2,"MXry HXd A LXttlX LXmb."))
     {
-    delete [] cres2;
     kwsys_ios::cerr
       << "Problem with ReplaceChars "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -242,7 +247,6 @@
   cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb.");
   if (strcmp(cres,"Mary Had A Little Lamb."))
     {
-    delete [] cres;
     kwsys_ios::cerr
       << "Problem with DuplicateString "
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
@@ -259,7 +263,67 @@
       << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
     res = false;    
     }
+
+  kwsys_stl::vector<kwsys_stl::string> lines;
+  kwsys::SystemTools::Split("Mary Had A Little Lamb.",lines,' ');
+  if (lines[0] != "Mary" || lines[1] != "Had" ||
+      lines[2] != "A" || lines[3] != "Little" || lines[4] != "Lamb.")
+    {
+    kwsys_ios::cerr
+      << "Problem with Split "
+      << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+    res = false;    
+    }
+
+  if (kwsys::SystemTools::ConvertToWindowsOutputPath
+      ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") != 
+      "\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"")
+    {
+    kwsys_ios::cerr
+      << "Problem with ConvertToWindowsOutputPath "
+      << kwsys_ios::endl;
+    res = false;    
+    }
   
+  if (kwsys::SystemTools::ConvertToWindowsOutputPath
+      ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") != 
+      "\"\\\\grayson\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"")
+    {
+    kwsys_ios::cerr
+      << "Problem with ConvertToWindowsOutputPath "
+      << kwsys_ios::endl;
+    res = false;    
+    }
+
+  if (kwsys::SystemTools::ConvertToUnixOutputPath
+      ("//Local Mojo/Hex Power Pack/Iffy Voodoo") != 
+      "/Local\\ Mojo/Hex\\ Power\\ Pack/Iffy\\ Voodoo")
+    {
+    kwsys_ios::cerr
+      << "Problem with ConvertToUnixOutputPath "
+      << kwsys_ios::endl;
+    res = false;    
+    }
+
+  int targc;
+  char **targv;
+  kwsys::SystemTools::ConvertWindowsCommandLineToUnixArguments
+    ("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"", &targc, &targv);
+  if (targc != 4 || strcmp(targv[1],"Local Mojo\\Voodoo.asp") ||
+      strcmp(targv[2],"-CastHex") || 
+      strcmp(targv[3],"D:\\My Secret Mojo\\Voodoo.mp3"))
+    {
+    kwsys_ios::cerr
+      << "Problem with ConvertWindowsCommandLineToUnixArguments"
+      << TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
+    res = false;    
+    }
+  for (;targc >=0; --targc)
+    {
+    delete [] targv[targc];
+    }
+  delete [] targv;
+
   return res;
 }
 
@@ -288,7 +352,7 @@
                             *checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
     }
 
-  res &= CheckDetectFileType();
+  res &= CheckFileOperations();
 
   res &= CheckStringOperations();
 

Index: Glob.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Glob.hxx.in,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -d -r1.4 -r1.4.4.1
--- Glob.hxx.in	21 Mar 2006 21:02:47 -0000	1.4
+++ Glob.hxx.in	13 Oct 2006 14:52:07 -0000	1.4.4.1
@@ -61,6 +61,16 @@
   void SetRelative(const char* dir);
   const char* GetRelative();
 
+  /** Convert the given globbing pattern to a regular expression.
+      There is no way to quote meta-characters.  The
+      require_whole_string argument specifies whether the regex is
+      automatically surrounded by "^" and "$" to match the whole
+      string.  This is on by default because patterns always match
+      whole strings, but may be disabled to support concatenating
+      expressions more easily (regex1|regex2|etc).  */
+  static kwsys_stl::string PatternToRegex(const kwsys_stl::string& pattern,
+                                          bool require_whole_string = true);
+
 protected:
   //! Process directory
   void ProcessDirectory(kwsys_stl::string::size_type start,
@@ -71,14 +81,6 @@
   void RecurseDirectory(kwsys_stl::string::size_type start,
     const kwsys_stl::string& dir, bool dir_only);
 
-  //! Escape all non-alphanumeric characters in pattern.
-  void Escape(int ch, char* buffer);
-
-  //!
-  // Translate a shell PATTERN to a regular expression.
-  // There is no way to quote meta-characters.
-  kwsys_stl::string ConvertExpression(const kwsys_stl::string& expr);
-
   //! Add regular expression
   void AddExpression(const char* expr);
 
@@ -92,4 +94,9 @@
 
 } // namespace @KWSYS_NAMESPACE@
 
+/* Undefine temporary macro.  */
+#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE at _NAME_IS_KWSYS
+# undef kwsys_stl
+#endif
+
 #endif

Index: Process.h.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Process.h.in,v
retrieving revision 1.24.24.1
retrieving revision 1.24.24.2
diff -u -d -r1.24.24.1 -r1.24.24.2
--- Process.h.in	30 Jun 2006 17:48:47 -0000	1.24.24.1
+++ Process.h.in	13 Oct 2006 14:52:07 -0000	1.24.24.2
@@ -33,6 +33,7 @@
 #define kwsysProcess_SetTimeout          kwsys_ns(Process_SetTimeout)
 #define kwsysProcess_SetWorkingDirectory kwsys_ns(Process_SetWorkingDirectory)
 #define kwsysProcess_SetPipeFile         kwsys_ns(Process_SetPipeFile)
+#define kwsysProcess_SetPipeNative       kwsys_ns(Process_SetPipeNative)
 #define kwsysProcess_SetPipeShared       kwsys_ns(Process_SetPipeShared)
 #define kwsysProcess_Option_Detach       kwsys_ns(Process_Option_Detach)
 #define kwsysProcess_Option_HideWindow   kwsys_ns(Process_Option_HideWindow)
@@ -71,6 +72,7 @@
 #define kwsysProcess_Pipe_STDOUT         kwsys_ns(Process_Pipe_STDOUT)
 #define kwsysProcess_Pipe_STDERR         kwsys_ns(Process_Pipe_STDERR)
 #define kwsysProcess_Pipe_Timeout        kwsys_ns(Process_Pipe_Timeout)
+#define kwsysProcess_Pipe_Handle         kwsys_ns(Process_Pipe_Handle)
 #define kwsysProcess_WaitForExit         kwsys_ns(Process_WaitForExit)
 #define kwsysProcess_Kill                kwsys_ns(Process_Kill)
 
@@ -84,6 +86,13 @@
  */
 typedef struct kwsysProcess_s kwsysProcess;
 
+/* Platform-specific pipe handle type.  */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+typedef void* kwsysProcess_Pipe_Handle;
+#else
+typedef int kwsysProcess_Pipe_Handle;
+#endif
+
 /**
  * Create a new Process instance.
  */
@@ -146,6 +155,27 @@
                                             int shared);
 
 /**
+ * Specify a platform-specific native pipe for use as one of the child
+ * interface pipes.  The native pipe is specified by an array of two
+ * descriptors or handles.  The first entry in the array (index 0)
+ * should be the read end of the pipe.  The second entry in the array
+ * (index 1) should be the write end of the pipe.  If a null pointer
+ * is given the option will be disabled.
+ *
+ * For Pipe_STDIN the native pipe is connected to the first child in
+ * the pipeline as its stdin.  After the children are created the
+ * write end of the pipe will be closed in the child process and the
+ * read end will be closed in the parent process.
+ *
+ * For Pipe_STDOUT and Pipe_STDERR the pipe is connected to the last
+ * child as its stdout or stderr.  After the children are created the
+ * write end of the pipe will be closed in the parent process and the
+ * read end will be closed in the child process.
+ */
+kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe,
+                                            kwsysProcess_Pipe_Handle p[2]);
+
+/**
  * Get/Set a possibly platform-specific option.  Possible options are:
  *
  *  kwsysProcess_Option_Detach = Whether to detach the process.
@@ -349,6 +379,7 @@
 # undef kwsysProcess_SetTimeout
 # undef kwsysProcess_SetWorkingDirectory
 # undef kwsysProcess_SetPipeFile
+# undef kwsysProcess_SetPipeNative
 # undef kwsysProcess_SetPipeShared
 # undef kwsysProcess_Option_Detach
 # undef kwsysProcess_Option_HideWindow
@@ -387,6 +418,7 @@
 # undef kwsysProcess_Pipe_STDOUT
 # undef kwsysProcess_Pipe_STDERR
 # undef kwsysProcess_Pipe_Timeout
+# undef kwsysProcess_Pipe_Handle
 # undef kwsysProcess_WaitForExit
 # undef kwsysProcess_Kill
 #endif

Index: SharedForward.h.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SharedForward.h.in,v
retrieving revision 1.5
retrieving revision 1.5.20.1
diff -u -d -r1.5 -r1.5.20.1
--- SharedForward.h.in	31 Aug 2005 23:41:53 -0000	1.5
+++ SharedForward.h.in	13 Oct 2006 14:52:07 -0000	1.5.20.1
@@ -26,6 +26,7 @@
   #define @KWSYS_NAMESPACE at _SHARED_FORWARD_PATH_INSTALL "../lib/foo-1.2"
   #define @KWSYS_NAMESPACE at _SHARED_FORWARD_EXE_BUILD "foo-real"
   #define @KWSYS_NAMESPACE at _SHARED_FORWARD_EXE_INSTALL "../lib/foo-1.2/foo-real"
+  #define @KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_COMMAND "--command"
   #define @KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_PRINT "--print"
   #define @KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_LDD "--ldd"
   #if defined(CMAKE_INTDIR)
@@ -36,12 +37,32 @@
   {
     return @KWSYS_NAMESPACE at _shared_forward_to_real(argc, argv);
   }
- */
+
+  Specify search and executable paths relative to the forwarding
+  executable location or as full paths.  Include no trailing slash.
+  In the case of a multi-configuration build, when CMAKE_INTDIR is
+  defined, the build-tree paths should be specified relative to the
+  directory above the executable (the one containing the
+  per-configuration subdirectory specified by CMAKE_INTDIR).
+
+  Additional paths may be specified in the PATH_BUILD and PATH_INSTALL
+  variables by using comma-separated strings.  Paths pointing at build
+  trees should contain CMAKE_INTDIR as necessary.  For example:
+
+  #if defined(CMAKE_INTDIR)
+  # define CONFIG_DIR "/" CMAKE_INTDIR
+  #else
+  # define CONFIG_DIR ""
+  #endif
+  #define @KWSYS_NAMESPACE at _SHARED_FORWARD_PATH_BUILD \
+          "." CONFIG_DIR, "/path/to/bar-build" CONFIG_DIR
+  #define @KWSYS_NAMESPACE at _SHARED_FORWARD_PATH_INSTALL \
+          "../lib/foo-1.2", "../lib/bar-4.5"
+
+  See the comments below for specific explanations of each macro.
+*/
 
 /*--------------------------------------------------------------------------*/
-/* Configuration for this executable.  Specify search and executable
-   paths relative to the forwarding executable location or as full
-   paths.  Include no trailing slash.  */
 
 /* Full path to the directory in which this executable is built.  Do
    not include a trailing slash.  */
@@ -91,6 +112,15 @@
 # undef KWSYS_SHARED_FORWARD_CONFIG_NAME
 #endif
 
+/* Create command line option to replace executable.  */
+#if defined(@KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_COMMAND)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
+#  define KWSYS_SHARED_FORWARD_OPTION_COMMAND @KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_COMMAND
+# endif
+#else
+# undef KWSYS_SHARED_FORWARD_OPTION_COMMAND
+#endif
+
 /* Create command line option to print environment setting and exit.  */
 #if defined(@KWSYS_NAMESPACE at _SHARED_FORWARD_OPTION_PRINT)
 # if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
@@ -274,14 +304,6 @@
 
 /*--------------------------------------------------------------------------*/
 /* Functions to execute a child process.  */
-static void kwsys_shared_forward_execv(const char* cmd, char* const argv[])
-{
-#if defined(_MSC_VER)
-  _execv(cmd, argv);
-#else
-  execv(cmd, argv);
-#endif
-}
 static void kwsys_shared_forward_execvp(const char* cmd, char* const argv[])
 {
 #if defined(_MSC_VER)
@@ -611,6 +633,27 @@
       /* Store the environment variable.  */
       putenv(kwsys_shared_forward_ldpath);
 
+#if defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
+      /* Look for the command line replacement option.  */
+      if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_COMMAND) == 0)
+        {
+        if(argc > 2)
+          {
+          /* Use the command line given.  */
+          strcpy(exe, argv[2]);
+          argv += 2;
+          argc -= 2;
+          }
+        else
+          {
+          /* The option was not given an executable.  */
+          fprintf(stderr, "Option " KWSYS_SHARED_FORWARD_OPTION_COMMAND
+                  " must be followed by a command line.\n");
+          return 1;
+          }
+        }
+#endif
+
 #if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
       /* Look for the print command line option.  */
       if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_PRINT) == 0)
@@ -644,7 +687,7 @@
 
       /* Replace this process with the real executable.  */
       argv[0] = exe;
-      kwsys_shared_forward_execv(argv[0], argv);
+      kwsys_shared_forward_execvp(argv[0], argv);
 
       /* Report why execution failed.  */
       kwsys_shared_forward_print_failure(argv);

Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/CMakeLists.txt,v
retrieving revision 1.96.2.2
retrieving revision 1.96.2.3
diff -u -d -r1.96.2.2 -r1.96.2.3
--- CMakeLists.txt	24 Jul 2006 15:19:36 -0000	1.96.2.2
+++ CMakeLists.txt	13 Oct 2006 14:52:07 -0000	1.96.2.3
@@ -123,10 +123,12 @@
   SET(KWSYS_USE_Process 1)
   SET(KWSYS_USE_RegularExpression 1)
   SET(KWSYS_USE_Registry 1)
+  SET(KWSYS_USE_System 1)
   SET(KWSYS_USE_SystemTools 1)
   SET(KWSYS_USE_CommandLineArguments 1)
   SET(KWSYS_USE_FundamentalType 1)
   SET(KWSYS_USE_Terminal 1)
+  SET(KWSYS_USE_IOStream 1)
 ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
 
 #-----------------------------------------------------------------------------
@@ -142,6 +144,10 @@
   ENDIF(BUILD_TESTING)
 ENDIF(KWSYS_STANDALONE)
 
+# Include helper macros.
+INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
+INCLUDE(CheckTypeSize)
+
 # Do full dependency headers.
 INCLUDE_REGULAR_EXPRESSION("^.*$")
 
@@ -262,13 +268,35 @@
       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
     ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
   ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+  IF(CMAKE_SYSTEM MATCHES "HP-UX")
+    SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
+  ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
 ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
 
 #-----------------------------------------------------------------------------
+# Configure Large File Support.
+SET(KWSYS_LFS_REQUESTED 1)
+SET(KWSYS_LFS_AVAILABLE 0)
+IF(KWSYS_LFS_REQUESTED)
+  # Large File Support is requested.
+  SET(KWSYS_LFS_REQUESTED 1)
+
+  # Check for large file support.
+  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
+    "Checking for Large File Support" DIRECT)
+
+  IF(KWSYS_LFS_WORKS)
+    SET(KWSYS_LFS_AVAILABLE 1)
+  ENDIF(KWSYS_LFS_WORKS)
+ELSE(KWSYS_LFS_REQUESTED)
+  # Large File Support is not requested.
+  SET(KWSYS_LFS_REQUESTED 0)
+ENDIF(KWSYS_LFS_REQUESTED)
+
+#-----------------------------------------------------------------------------
 # Configure the standard library header wrappers based on compiler's
 # capabilities and parent project's request.  Enforce 0/1 as only
 # possible values for configuration into Configure.hxx.
-INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
 
 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
   "Checking whether STL classes are in std namespace" DIRECT)
@@ -371,7 +399,6 @@
 
 IF(KWSYS_USE_FundamentalType)
   # Determine type sizes.
-  INCLUDE(CheckTypeSize)
   CHECK_TYPE_SIZE("char"      KWSYS_SIZEOF_CHAR)
   CHECK_TYPE_SIZE("short"     KWSYS_SIZEOF_SHORT)
   CHECK_TYPE_SIZE("int"       KWSYS_SIZEOF_INT)
@@ -421,26 +448,28 @@
   ENDIF(KWSYS_USE___INT64)
 
   # Check signedness of "char" type.
-  IF("KWSYS_CHAR_IS_SIGNED" MATCHES "^KWSYS_CHAR_IS_SIGNED$")
-    MESSAGE(STATUS "Checking signedness of char")
-    TRY_RUN(KWSYS_CHAR_IS_SIGNED KWSYS_CHAR_IS_SIGNED_COMPILED
-      ${CMAKE_CURRENT_BINARY_DIR}
-      ${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cxx
-      COMPILE_DEFINITIONS -DTEST_KWSYS_CHAR_IS_SIGNED)
-    IF(KWSYS_CHAR_IS_SIGNED_COMPILED)
-      IF(KWSYS_CHAR_IS_SIGNED)
-        MESSAGE(STATUS "Checking signedness of char -- signed")
-        SET(KWSYS_CHAR_IS_SIGNED 1 CACHE INTERNAL "Whether char is signed.")
-      ELSE(KWSYS_CHAR_IS_SIGNED)
-        MESSAGE(STATUS "Checking signedness of char -- unsigned")
-        SET(KWSYS_CHAR_IS_SIGNED 0 CACHE INTERNAL "Whether char is signed.")
-      ENDIF(KWSYS_CHAR_IS_SIGNED)
-    ELSE(KWSYS_CHAR_IS_SIGNED_COMPILED)
-      MESSAGE(FATAL_ERROR "Checking signedness of char -- failed")
-    ENDIF(KWSYS_CHAR_IS_SIGNED_COMPILED)
-  ENDIF("KWSYS_CHAR_IS_SIGNED" MATCHES "^KWSYS_CHAR_IS_SIGNED$")
+  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
+    "Checking whether char is signed" DIRECT)
 ENDIF(KWSYS_USE_FundamentalType)
 
+IF(KWSYS_USE_IOStream)
+  # Determine whether iostreams support long long.
+  CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG)
+  IF(KWSYS_SIZEOF_LONG_LONG)
+    SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
+      -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
+      -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
+    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG
+      "Checking if istream supports long long" DIRECT)
+    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG
+      "Checking if ostream supports long long" DIRECT)
+    SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
+  ELSE(KWSYS_SIZEOF_LONG_LONG)
+    SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
+    SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
+  ENDIF(KWSYS_SIZEOF_LONG_LONG)
+ENDIF(KWSYS_USE_IOStream)
+
 IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
   SET(KWSYS_NAME_IS_KWSYS 1)
 ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
@@ -472,8 +501,25 @@
 # Create STL header wrappers to block warnings in the STL headers and
 # give standard names by which they may be included.
 SET(KWSYS_STL_HEADER_EXTRA_string 1)
-FOREACH(header algorithm deque iterator list map numeric queue set stack string
-               utility vector memory functional)
+FOREACH(header
+  algorithm
+  deque
+  exception
+  functional
+  iterator
+  list
+  map
+  memory
+  new
+  numeric
+  queue
+  set
+  stack
+  stdexcept
+  string
+  utility
+  vector
+  )
   # Configure the header wrapper.
   SET(KWSYS_STL_HEADER "${header}")
   IF(KWSYS_STL_HEADER_EXTRA_${header})
@@ -552,9 +598,15 @@
   SET(KWSYS_USE_SystemTools 1)
   SET(KWSYS_USE_RegularExpression 1)
 ENDIF(KWSYS_USE_Glob)
+IF(KWSYS_USE_Process)
+  SET(KWSYS_USE_System 1)
+ENDIF(KWSYS_USE_Process)
 
 # Add selected C++ classes.
-SET(cppclasses Directory DynamicLoader Glob RegularExpression SystemTools CommandLineArguments Registry)
+SET(cppclasses
+  Directory DynamicLoader Glob RegularExpression SystemTools
+  CommandLineArguments Registry IOStream
+  )
 FOREACH(cpp ${cppclasses})
   IF(KWSYS_USE_${cpp})
     SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
@@ -562,7 +614,7 @@
 ENDFOREACH(cpp)
 
 # Add selected C components.
-FOREACH(c Process Base64 FundamentalType Terminal)
+FOREACH(c Process Base64 FundamentalType Terminal System)
   IF(KWSYS_USE_${c})
     SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
   ENDIF(KWSYS_USE_${c})
@@ -586,11 +638,20 @@
   ELSE(NOT UNIX)
     # Use the UNIX implementation.
     SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
+
+    # Help ProcessUNIX.c compile properly on all platforms.
+    KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
+      "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
+    KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
+      "Checking whether C compiler has ssize_t in unistd.h" DIRECT)
+    SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c PROPERTIES
+      COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
+      )
   ENDIF(NOT UNIX)
 ENDIF(KWSYS_USE_Process)
 
 # Add selected C sources.
-FOREACH(c Base64 Terminal)
+FOREACH(c Base64 Terminal System)
   IF(KWSYS_USE_${c})
     SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c)
   ENDIF(KWSYS_USE_${c})

Index: testProcess.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/testProcess.c,v
retrieving revision 1.31.6.1
retrieving revision 1.31.6.2
diff -u -d -r1.31.6.1 -r1.31.6.2
--- testProcess.c	30 Jun 2006 17:48:48 -0000	1.31.6.1
+++ testProcess.c	13 Oct 2006 14:52:08 -0000	1.31.6.2
@@ -30,6 +30,10 @@
 # include <unistd.h>
 #endif
 
+#if defined(__BORLANDC__)
+# pragma warn -8060 /* possibly incorrect assignment */
+#endif
+
 int runChild(const char* cmd[], int state, int exception, int value,
              int share, int output, int delay, double timeout, int poll,
              int repeat, int disown);
@@ -196,7 +200,6 @@
   return 0;
 }
 
-
 int runChild2(kwsysProcess* kp,
               const char* cmd[], int state, int exception, int value,
               int share, int output, int delay, double timeout,
@@ -273,14 +276,14 @@
         }
       }
     }
-  
+
   if(disown)
     {
     kwsysProcess_Disown(kp);
     }
   else
     {
-  kwsysProcess_WaitForExit(kp, 0);
+    kwsysProcess_WaitForExit(kp, 0);
     }
 
   switch (kwsysProcess_GetState(kp))

Index: SystemTools.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.hxx.in,v
retrieving revision 1.59.2.2
retrieving revision 1.59.2.3
diff -u -d -r1.59.2.2 -r1.59.2.3
--- SystemTools.hxx.in	26 Jul 2006 12:35:38 -0000	1.59.2.2
+++ SystemTools.hxx.in	13 Oct 2006 14:52:08 -0000	1.59.2.3
@@ -256,6 +256,20 @@
   static kwsys_stl::string ConvertToOutputPath(const char*);
 
   /**
+   * Convert the path to a string that can be used in a unix makefile.
+   * double slashes are removed, and spaces are escaped.
+   */
+  static kwsys_stl::string ConvertToUnixOutputPath(const char*);
+
+  /**
+   * Convert the path to string that can be used in a windows project or
+   * makefile.   Double slashes are removed if they are not at the start of
+   * the string, the slashes are converted to windows style backslashes, and
+   * if there are spaces in the string it is double quoted.
+   */
+  static kwsys_stl::string ConvertToWindowsOutputPath(const char*);
+
+  /**
    * Return true if a file exists in the current directory
    */
   static bool FileExists(const char* filename);
@@ -350,6 +364,9 @@
    */
   static kwsys_stl::string JoinPath(
     const kwsys_stl::vector<kwsys_stl::string>& components);
+  static kwsys_stl::string JoinPath(
+    kwsys_stl::vector<kwsys_stl::string>::const_iterator first,
+    kwsys_stl::vector<kwsys_stl::string>::const_iterator last);
 
   /**
    * Compare a path or components of a path.
@@ -429,12 +446,6 @@
    */
   static bool IsSubDirectory(const char* fileOrDir, const char* dir);
 
-  /**
-   * Convert the path to a string that can be used in a unix makefile.
-   * double slashes are removed, and spaces are escaped.
-   */
-  static kwsys_stl::string ConvertToUnixOutputPath(const char*);
-
   /** -----------------------------------------------------------------
    *               File Manipulation Routines
    *  -----------------------------------------------------------------
@@ -754,17 +765,6 @@
   static void ConvertWindowsCommandLineToUnixArguments(
     const char *cmd_line, int *argc, char ***argv);
 
-protected:
-  // these two functions can be called from ConvertToOutputPath
-
-  /**
-   * Convert the path to string that can be used in a windows project or
-   * makefile.   Double slashes are removed if they are not at the start of
-   * the string, the slashes are converted to windows style backslashes, and
-   * if there are spaces in the string it is double quoted.
-   */
-  static kwsys_stl::string ConvertToWindowsOutputPath(const char*);
-
 private:
   /**
    * Allocate the std::map that serve as the Path Translation table.

Index: ProcessUNIX.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/ProcessUNIX.c,v
retrieving revision 1.54.6.1
retrieving revision 1.54.6.2
diff -u -d -r1.54.6.1 -r1.54.6.2
--- ProcessUNIX.c	30 Jun 2006 17:48:47 -0000	1.54.6.1
+++ ProcessUNIX.c	13 Oct 2006 14:52:07 -0000	1.54.6.2
@@ -47,6 +47,7 @@
 
 */
 
+#include <stddef.h>    /* ptrdiff_t */
 #include <stdio.h>     /* snprintf */
 #include <stdlib.h>    /* malloc, free */
 #include <string.h>    /* strdup, strerror, memset */
@@ -62,6 +63,18 @@
 #include <dirent.h>    /* DIR, dirent */
 #include <ctype.h>     /* isspace */
 
+#if defined(KWSYS_C_HAS_PTRDIFF_T) && KWSYS_C_HAS_PTRDIFF_T
+typedef ptrdiff_t kwsysProcess_ptrdiff_t;
+#else
+typedef int kwsysProcess_ptrdiff_t;
+#endif
+
+#if defined(KWSYS_C_HAS_SSIZE_T) && KWSYS_C_HAS_SSIZE_T
+typedef ssize_t kwsysProcess_ssize_t;
+#else
+typedef int kwsysProcess_ssize_t;
+#endif
+
 /* The number of pipes for the child's output.  The standard stdout
    and stderr pipes are the first two.  One more pipe is used to
    detect when the child process has terminated.  The third pipe is
@@ -102,6 +115,7 @@
                               kwsysProcessCreateInformation* si, int* readEnd);
 static void kwsysProcessDestroy(kwsysProcess* cp);
 static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
+static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
 static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
                                       kwsysProcessTime* timeoutTime);
 static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
@@ -217,6 +231,11 @@
   int PipeSharedSTDOUT;
   int PipeSharedSTDERR;
 
+  /* Native pipes provided by the user.  */
+  int PipeNativeSTDIN[2];
+  int PipeNativeSTDOUT[2];
+  int PipeNativeSTDERR[2];
+
   /* The real working directory of this process.  */
   int RealWorkingDirectoryLength;
   char* RealWorkingDirectory;
@@ -236,6 +255,14 @@
   /* Share stdin with the parent process by default.  */
   cp->PipeSharedSTDIN = 1;
 
+  /* No native pipes by default.  */
+  cp->PipeNativeSTDIN[0] = -1;
+  cp->PipeNativeSTDIN[1] = -1;
+  cp->PipeNativeSTDOUT[0] = -1;
+  cp->PipeNativeSTDOUT[1] = -1;
+  cp->PipeNativeSTDERR[0] = -1;
+  cp->PipeNativeSTDERR[1] = -1;
+
   /* Set initial status.  */
   cp->State = kwsysProcess_State_Starting;
 
@@ -354,8 +381,8 @@
     {
     /* Copy each argument string individually.  */
   char const* const* c = command;
-  int n = 0;
-  int i = 0;
+    kwsysProcess_ptrdiff_t n = 0;
+    kwsysProcess_ptrdiff_t i = 0;
   while(*c++);
   n = c - command - 1;
   newCommands[cp->NumberOfCommands] = (char**)malloc((n+1)*sizeof(char*));
@@ -470,9 +497,11 @@
     strcpy(*pfile, file);
     }
 
-  /* If we are redirecting the pipe, do not share it.  */
+  /* If we are redirecting the pipe, do not share it or use a native
+     pipe.  */
   if(*pfile)
     {
+    kwsysProcess_SetPipeNative(cp, prPipe, 0);
     kwsysProcess_SetPipeShared(cp, prPipe, 0);
     }
   return 1;
@@ -494,10 +523,51 @@
     default: return;
     }
 
-  /* If we are sharing the pipe, do not redirect it to a file.  */
+  /* If we are sharing the pipe, do not redirect it to a file or use a
+     native pipe.  */
   if(shared)
     {
     kwsysProcess_SetPipeFile(cp, prPipe, 0);
+    kwsysProcess_SetPipeNative(cp, prPipe, 0);
+    }
+}
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
+{
+  int* pPipeNative = 0;
+
+  if(!cp)
+    {
+    return;
+    }
+
+  switch(prPipe)
+    {
+    case kwsysProcess_Pipe_STDIN: pPipeNative = cp->PipeNativeSTDIN; break;
+    case kwsysProcess_Pipe_STDOUT: pPipeNative = cp->PipeNativeSTDOUT; break;
+    case kwsysProcess_Pipe_STDERR: pPipeNative = cp->PipeNativeSTDERR; break;
+    default: return;
+    }
+
+  /* Copy the native pipe descriptors provided.  */
+  if(p)
+    {
+    pPipeNative[0] = p[0];
+    pPipeNative[1] = p[1];
+    }
+  else
+    {
+    pPipeNative[0] = -1;
+    pPipeNative[1] = -1;
+    }
+
+  /* If we are using a native pipe, do not share it or redirect it to
+     a file.  */
+  if(p)
+    {
+    kwsysProcess_SetPipeFile(cp, prPipe, 0);
+    kwsysProcess_SetPipeShared(cp, prPipe, 0);
     }
 }
 
@@ -684,6 +754,19 @@
     si.StdErr = 2;
     }
 
+  /* Replace the stderr pipe with the native pipe provided if any.  In
+     this case the select call will report that stderr is closed
+     immediately.  */
+  if(cp->PipeNativeSTDERR[1] >= 0)
+    {
+    if(!kwsysProcessSetupOutputPipeNative(&si.StdErr, cp->PipeNativeSTDERR))
+      {
+      kwsysProcessCleanup(cp, 1);
+      kwsysProcessCleanupDescriptor(&si.StdErr);
+      return;
+      }
+    }
+
   /* The timeout period starts now.  */
   cp->StartTime = kwsysProcessTimeGetCurrent();
   cp->TimeoutTime.tv_sec = -1;
@@ -834,7 +917,7 @@
       if(cp->PipeReadEnds[i] >= 0 &&
          FD_ISSET(cp->PipeReadEnds[i], &cp->PipeSet))
         {
-        int n;
+        kwsysProcess_ssize_t n;
 
         /* We are handling this pipe now.  Remove it from the set.  */
         FD_CLR(cp->PipeReadEnds[i], &cp->PipeSet);
@@ -1297,6 +1380,19 @@
     {
     si->StdIn = 0;
     }
+  else if(cp->PipeNativeSTDIN[0] >= 0)
+    {
+    si->StdIn = cp->PipeNativeSTDIN[0];
+
+    /* Set close-on-exec flag on the pipe's ends.  The read end will
+       be dup2-ed into the stdin descriptor after the fork but before
+       the exec.  */
+    if((fcntl(cp->PipeNativeSTDIN[0], F_SETFD, FD_CLOEXEC) < 0) ||
+       (fcntl(cp->PipeNativeSTDIN[1], F_SETFD, FD_CLOEXEC) < 0))
+      {
+      return 0;
+      }
+    }
   else
     {
     si->StdIn = -1;
@@ -1340,6 +1436,17 @@
     si->StdOut = 1;
     }
 
+  /* Replace the stdout pipe with the native pipe provided if any.  In
+     this case the select call will report that stdout is closed
+     immediately.  */
+  if(prIndex == cp->NumberOfCommands-1 && cp->PipeNativeSTDOUT[1] >= 0)
+    {
+    if(!kwsysProcessSetupOutputPipeNative(&si->StdOut, cp->PipeNativeSTDOUT))
+      {
+      return 0;
+      }
+    }
+
   /* Create the error reporting pipe.  */
   if(pipe(si->ErrorPipe) < 0)
     {
@@ -1407,8 +1514,8 @@
   /* Block until the child's exec call succeeds and closes the error
      pipe or writes data to the pipe to report an error.  */
   {
-  int total = 0;
-  int n = 1;
+  kwsysProcess_ssize_t total = 0;
+  kwsysProcess_ssize_t n = 1;
   /* Read the entire error message up to the length of our buffer.  */
   while(total < KWSYSPE_PIPE_BUFFER_SIZE && n > 0)
     {
@@ -1520,6 +1627,26 @@
 }
 
 /*--------------------------------------------------------------------------*/
+static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
+{
+  /* Close the existing descriptor.  */
+  kwsysProcessCleanupDescriptor(p);
+
+  /* Set close-on-exec flag on the pipe's ends.  The proper end will
+     be dup2-ed into the standard descriptor number after fork but
+     before exec.  */
+  if((fcntl(des[0], F_SETFD, FD_CLOEXEC) < 0) ||
+     (fcntl(des[1], F_SETFD, FD_CLOEXEC) < 0))
+    {
+    return 0;
+    }
+
+  /* Assign the replacement descriptor.  */
+  *p = des[1];
+  return 1;
+}
+
+/*--------------------------------------------------------------------------*/
 /* Get the time at which either the process or user timeout will
    expire.  Returns 1 if the user timeout is first, and 0 otherwise.  */
 static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
@@ -2201,7 +2328,10 @@
     struct sigaction newSigChldAction;
     memset(&newSigChldAction, 0, sizeof(struct sigaction));
     newSigChldAction.sa_sigaction = kwsysProcessesSignalHandler;
-    newSigChldAction.sa_flags = SA_NOCLDSTOP | SA_RESTART | SA_SIGINFO;
+    newSigChldAction.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
+#ifdef SA_RESTART
+    newSigChldAction.sa_flags |= SA_RESTART;
+#endif
     while((sigaction(SIGCHLD, &newSigChldAction,
                      &kwsysProcessesOldSigChldAction) < 0) &&
           (errno == EINTR));
@@ -2287,7 +2417,7 @@
   /* Allocate space for the character.  */
   if((*end - *begin) >= *size)
     {
-    int length = *end - *begin;
+    kwsysProcess_ptrdiff_t length = *end - *begin;
     char* newBuffer = (char*)malloc(*size*2);
     if(!newBuffer)
       {
@@ -2325,7 +2455,7 @@
   /* Allocate space for the argument pointer.  */
   if((*end - *begin) >= *size)
     {
-    int length = *end - *begin;
+    kwsysProcess_ptrdiff_t length = *end - *begin;
     char** newPointers = (char**)malloc(*size*2*sizeof(char*));
     if(!newPointers)
       {
@@ -2498,14 +2628,14 @@
      buffer.  */
   if(!failed)
     {
-    int n = pointer_end - pointer_begin;
+    kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin;
     newCommand = (char**)malloc((n+1)*sizeof(char*));
     }
 
   if(newCommand)
     {
     /* Copy the arguments into the new command buffer.  */
-    int n = pointer_end - pointer_begin;
+    kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin;
     memcpy(newCommand, pointer_begin, sizeof(char*)*n);
     newCommand[n] = 0;
     }

Index: Registry.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Registry.cxx,v
retrieving revision 1.19.4.1
retrieving revision 1.19.4.2
diff -u -d -r1.19.4.1 -r1.19.4.2
--- Registry.cxx	24 Jul 2006 15:19:36 -0000	1.19.4.1
+++ Registry.cxx	13 Oct 2006 14:52:07 -0000	1.19.4.2
@@ -36,6 +36,8 @@
 
 #include <ctype.h> // for isspace
 #include <stdio.h>
+#include <string.h> /* strlen, strncpy */
+#include <stdlib.h> /* getenv */
 
 #ifdef _WIN32
 # include <windows.h>
@@ -210,13 +212,13 @@
   const char *key,
   const char **value)
 {
-  *value = 0;
   bool res = false;
   bool open = false;
   if ( ! value )
     {
     return res;
     }
+  *value = 0;
   if ( !m_Opened )
     {
     if ( !this->Open(this->GetTopLevel(), subkey,

Index: CommandLineArguments.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/CommandLineArguments.cxx,v
retrieving revision 1.21.4.2
retrieving revision 1.21.4.3
diff -u -d -r1.21.4.2 -r1.21.4.3
--- CommandLineArguments.cxx	24 Jul 2006 15:19:36 -0000	1.21.4.2
+++ CommandLineArguments.cxx	13 Oct 2006 14:52:07 -0000	1.21.4.3
@@ -216,7 +216,7 @@
       // additional value
       CommandLineArgumentsCallbackStructure *cs 
         = &this->Internals->Callbacks[matches[maxidx]];
-      const CommandLineArguments::Internal::String& sarg = matches[maxidx];
+      const kwsys_stl::string& sarg = matches[maxidx];
       if ( cs->Argument != sarg )
         {
         abort();

Index: testCommandLineArguments.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/testCommandLineArguments.cxx,v
retrieving revision 1.5.6.1
retrieving revision 1.5.6.2
diff -u -d -r1.5.6.1 -r1.5.6.2
--- testCommandLineArguments.cxx	24 Jul 2006 15:19:36 -0000	1.5.6.1
+++ testCommandLineArguments.cxx	13 Oct 2006 14:52:08 -0000	1.5.6.2
@@ -23,6 +23,9 @@
 # include "kwsys_ios_iostream.h.in"
 #endif
 
+#include <stddef.h> /* size_t */
+#include <string.h> /* strcmp */
+
 void* random_ptr = reinterpret_cast<void*>(0x123);
 
 int argument(const char* arg, const char* value, void* call_data)

Index: testCommandLineArguments1.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/testCommandLineArguments1.cxx,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -d -r1.3.2.1 -r1.3.2.2
--- testCommandLineArguments1.cxx	24 Jul 2006 15:19:36 -0000	1.3.2.1
+++ testCommandLineArguments1.cxx	13 Oct 2006 14:52:08 -0000	1.3.2.2
@@ -23,6 +23,8 @@
 # include "kwsys_ios_iostream.h.in"
 #endif
 
+#include <string.h> /* strcmp */
+
 int main(int argc, char* argv[])
 {
   kwsys::CommandLineArguments arg;

Index: Directory.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Directory.cxx,v
retrieving revision 1.17.4.1
retrieving revision 1.17.4.2
diff -u -d -r1.17.4.1 -r1.17.4.2
--- Directory.cxx	30 Jun 2006 17:48:47 -0000	1.17.4.1
+++ Directory.cxx	13 Oct 2006 14:52:07 -0000	1.17.4.2
@@ -199,6 +199,11 @@
 bool Directory::Load(const char* name)
 {
   this->Clear();
+   
+  if (!name)
+    {
+    return 0;
+    }
   DIR* dir = opendir(name);
 
   if (!dir)

Index: Terminal.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Terminal.c,v
retrieving revision 1.4.4.3
retrieving revision 1.4.4.4
diff -u -d -r1.4.4.3 -r1.4.4.4
--- Terminal.c	24 Jul 2006 15:19:36 -0000	1.4.4.3
+++ Terminal.c	13 Oct 2006 14:52:08 -0000	1.4.4.4
@@ -144,14 +144,17 @@
   "console",
   "cygwin",
   "konsole",
+  "konsole-256color",
   "linux",
   "msys",
   "rxvt",
   "rxvt-unicode",
   "screen",
+  "screen-256color",
   "vt100",
   "xterm",
   "xterm-color",
+  "xterm-256color",
   0
 };
 

Index: Glob.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/Glob.cxx,v
retrieving revision 1.8.4.1
retrieving revision 1.8.4.2
diff -u -d -r1.8.4.1 -r1.8.4.2
--- Glob.cxx	24 Jul 2006 15:19:36 -0000	1.8.4.1
+++ Glob.cxx	13 Oct 2006 14:52:07 -0000	1.8.4.2
@@ -39,14 +39,14 @@
 #include <string.h>
 namespace KWSYS_NAMESPACE
 {
-#if defined( _WIN32 ) || defined( APPLE ) || defined( __CYGWIN__ )
-  // On Windows and apple, no difference between lower and upper case
-  #define KWSYS_GLOB_CASE_INDEPENDENT
+#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
+// On Windows and apple, no difference between lower and upper case
+# define KWSYS_GLOB_CASE_INDEPENDENT
 #endif
 
-#if defined( _WIN32 ) || defined( __CYGWIN__ )
-  // Handle network paths
-  #define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
+#if defined(_WIN32) || defined(__CYGWIN__)
+// Handle network paths
+# define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
 #endif
 
 //----------------------------------------------------------------------------
@@ -55,7 +55,6 @@
 public:
   kwsys_stl::vector<kwsys_stl::string> Files;
   kwsys_stl::vector<kwsys::RegularExpression> Expressions;
-  kwsys_stl::vector<kwsys_stl::string> TextExpressions;
 };
 
 //----------------------------------------------------------------------------
@@ -73,109 +72,138 @@
 }
 
 //----------------------------------------------------------------------------
-void Glob::Escape(int ch, char* buffer)
-{
-  if (! (
-      'a' <= ch && ch <= 'z' ||
-      'A' <= ch && ch <= 'Z' ||
-      '0' <= ch && ch <= '9') )
-    {
-    sprintf(buffer, "\\%c", ch);
-    }
-  else
-    {
-#if defined( KWSYS_GLOB_CASE_INDEPENDENT )
-    // On Windows and apple, no difference between lower and upper case
-    sprintf(buffer, "%c", tolower(ch));
-#else
-    sprintf(buffer, "%c", ch);
-#endif
-    }
-}
-
-//----------------------------------------------------------------------------
 kwsys_stl::vector<kwsys_stl::string>& Glob::GetFiles()
 {
   return this->Internals->Files;
 }
 
 //----------------------------------------------------------------------------
-kwsys_stl::string Glob::ConvertExpression(const kwsys_stl::string& expr)
+kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern,
+                                       bool require_whole_string)
 {
-
-  kwsys_stl::string::size_type i = 0;
-  kwsys_stl::string::size_type n = expr.size();
-
-  kwsys_stl::string res = "^";
-  kwsys_stl::string stuff = "";
-
-  while ( i < n )
+  // Incrementally build the regular expression from the pattern.
+  kwsys_stl::string regex = require_whole_string? "^" : "";
+  kwsys_stl::string::const_iterator pattern_first = pattern.begin();
+  kwsys_stl::string::const_iterator pattern_last = pattern.end();
+  for(kwsys_stl::string::const_iterator i = pattern_first;
+      i != pattern_last; ++i)
     {
-    int c = expr[i];
-    i = i+1;
-    if ( c == '*' )
+    int c = *i;
+    if(c == '*')
       {
-      res = res + ".*";
+      // A '*' (not between brackets) matches any string.
+      // We modify this to not match slashes since the orignal glob
+      // pattern documentation was meant for matching file name
+      // components separated by slashes.
+      regex += "[^/]*";
       }
-    else if ( c == '?' )
+    else if(c == '?')
       {
-      res = res + ".";
+      // A '?' (not between brackets) matches any single character.
+      // We modify this to not match slashes since the orignal glob
+      // pattern documentation was meant for matching file name
+      // components separated by slashes.
+      regex += "[^/]";
       }
-    else if ( c == '[' )
+    else if(c == '[')
       {
-      kwsys_stl::string::size_type j = i;
-      if ( j < n && ( expr[j] == '!' || expr[j] == '^' ) )
+      // Parse out the bracket expression.  It begins just after the
+      // opening character.
+      kwsys_stl::string::const_iterator bracket_first = i+1;
+      kwsys_stl::string::const_iterator bracket_last = bracket_first;
+
+      // The first character may be complementation '!' or '^'.
+      if(bracket_last != pattern_last &&
+         (*bracket_last == '!' || *bracket_last == '^'))
         {
-        j = j+1;
+        ++bracket_last;
         }
-      if ( j < n && expr[j] == ']' )
+
+      // If the next character is a ']' it is included in the brackets
+      // because the bracket string may not be empty.
+      if(bracket_last != pattern_last && *bracket_last == ']')
         {
-        j = j+1;
+        ++bracket_last;
         }
-      while ( j < n && expr[j] != ']' )
+
+      // Search for the closing ']'.
+      while(bracket_last != pattern_last && *bracket_last != ']')
         {
-        j = j+1;
+        ++bracket_last;
         }
-      if ( j >= n )
+
+      // Check whether we have a complete bracket string.
+      if(bracket_last == pattern_last)
         {
-        res = res + "\\[";
+        // The bracket string did not end, so it was opened simply by
+        // a '[' that is supposed to be matched literally.
+        regex += "\\[";
         }
       else
         {
-        stuff = "";
-        kwsys_stl::string::size_type cc;
-        for ( cc = i; cc < j; cc ++ )
-          {
-          if ( expr[cc] == '\\' )
+        // Convert the bracket string to its regex equivalent.
+        kwsys_stl::string::const_iterator k = bracket_first;
+
+        // Open the regex block.
+        regex += "[";
+
+        // A regex range complement uses '^' instead of '!'.
+        if(k != bracket_last && *k == '!')
             {
-            stuff += "\\\\";
+          regex += "^";
+          ++k;
             }
-          else
+
+        // Convert the remaining characters.
+        for(; k != bracket_last; ++k)
+          {
+          // Backslashes must be escaped.
+          if(*k == '\\')
             {
-            stuff += expr[cc];
+            regex += "\\";
             }
+
+          // Store this character.
+          regex += *k;
           }
-        i = j+1;
-        if ( stuff[0] == '!' || stuff[0] == '^' )
+
+        // Close the regex block.
+        regex += "]";
+
+        // Jump to the end of the bracket string.
+        i = bracket_last;
+        }
+      }
+    else
+      {
+      // A single character matches itself.
+      int ch = c;
+      if(!(('a' <= ch && ch <= 'z') ||
+           ('A' <= ch && ch <= 'Z') ||
+           ('0' <= ch && ch <= '9')))
           {
-          stuff = '^' + stuff.substr(1);
+        // Escape the non-alphanumeric character.
+        regex += "\\";
           }
-        else if ( stuff[0] == '^' )
+#if defined(KWSYS_GLOB_CASE_INDEPENDENT)
+      else
           {
-          stuff = '\\' + stuff;
+        // On case-insensitive systems file names are converted to lower
+        // case before matching.
+        ch = tolower(ch);
           }
-        res = res + "[" + stuff + "]";
+#endif
+
+      // Store the character.
+      regex.append(1, static_cast<char>(ch));
         }
       }
-    else
+
+  if(require_whole_string)
       {
-      char buffer[100];
-      buffer[0] = 0;
-      this->Escape(c, buffer);
-      res = res + buffer;
+    regex += "$";
       }
-    }
-  return res + "$";
+  return regex;
 }
 
 //----------------------------------------------------------------------------
@@ -276,8 +304,8 @@
       realname = dir + "/" + fname;
       }
 
-#if defined( KWSYS_GLOB_CASE_INDEPENDENT )
-    // On Windows and apple, no difference between lower and upper case
+#if defined(KWSYS_GLOB_CASE_INDEPENDENT)
+    // On case-insensitive file systems convert to lower case for matching.
     fname = kwsys::SystemTools::LowerCase(fname);
 #endif
 
@@ -427,8 +455,7 @@
 {
   this->Internals->Expressions.push_back(
     kwsys::RegularExpression(
-      this->ConvertExpression(expr).c_str()));
-  this->Internals->TextExpressions.push_back(this->ConvertExpression(expr));
+      this->PatternToRegex(expr).c_str()));
 }
 
 //----------------------------------------------------------------------------

Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.157.2.8
retrieving revision 1.157.2.9
diff -u -d -r1.157.2.8 -r1.157.2.9
--- SystemTools.cxx	28 Jul 2006 13:14:21 -0000	1.157.2.8
+++ SystemTools.cxx	13 Oct 2006 14:52:07 -0000	1.157.2.9
@@ -337,6 +337,10 @@
 
 bool SystemTools::MakeDirectory(const char* path)
 {
+  if(!path)
+    {
+    return false;
+    }
   if(SystemTools::FileExists(path))
     {
     return true;
@@ -1366,18 +1370,32 @@
     {
     ret.erase(pos, 1);
     }
-  // now escape spaces if there is a space in the path
-  if(ret.find(" ") != kwsys_stl::string::npos)
+  // escape spaces and () in the path
+  if(ret.find_first_of(" ()") != kwsys_stl::string::npos)
     {
     kwsys_stl::string result = "";
     char lastch = 1;
+    bool inDollarVariable = false;
     for(const char* ch = ret.c_str(); *ch != '\0'; ++ch)
       {
         // if it is already escaped then don't try to escape it again
-      if(*ch == ' ' && lastch != '\\')
+      if((*ch == ' ' || *ch == '(' || *ch == ')') && lastch != '\\')
+        {
+        if(*ch == '(' && lastch == '$')
+          {
+          inDollarVariable = true;
+          }
+        // if we are in a $(..... and we get a ) then do not escape
+        // the ) and but set inDollarVariable to false
+        else if(*ch == ')' && inDollarVariable)
+          {
+          inDollarVariable = false;
+          }
+        else
         {
         result += '\\';
         }
+        }
       result += *ch;
       lastch = *ch;
       }
@@ -1764,7 +1782,7 @@
 
 bool SystemTools::ConvertDateMacroString(const char *str, time_t *tmt)
 {
-  if (!str || !tmt || strlen(str) < 12)
+  if (!str || !tmt || strlen(str) > 11)
     {
     return false;
     }
@@ -1812,7 +1830,7 @@
 
 bool SystemTools::ConvertTimeStampMacroString(const char *str, time_t *tmt)
 {
-  if (!str || !tmt || strlen(str) < 27)
+  if (!str || !tmt || strlen(str) > 26)
     {
     return false;
     }
@@ -2242,6 +2260,17 @@
 
 bool SystemTools::FileIsDirectory(const char* name)
 {
+  // Remove any trailing slash from the name.
+  char buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
+  int last = static_cast<int>(strlen(name))-1;
+  if(last >= 0 && (name[last] == '/' || name[last] == '\\'))
+    {
+    memcpy(buffer, name, last);
+    buffer[last] = 0;
+    name = buffer;
+    }
+
+  // Now check the file node type.
   struct stat fs;
   if(stat(name, &fs) == 0)
     {
@@ -2441,7 +2470,8 @@
 
 void SystemTools::AddKeepPath(const char* dir)
 {
-  kwsys_stl::string cdir = SystemTools::CollapseFullPath(dir);
+  kwsys_stl::string cdir;
+  Realpath(SystemTools::CollapseFullPath(dir).c_str(), cdir);
   SystemTools::AddTranslationPath(cdir.c_str(), dir);
 }
 
@@ -2798,20 +2828,36 @@
 kwsys_stl::string
 SystemTools::JoinPath(const kwsys_stl::vector<kwsys_stl::string>& components)
 {
+  return SystemTools::JoinPath(components.begin(), components.end());
+}
+
+//----------------------------------------------------------------------------
+kwsys_stl::string
+SystemTools
+::JoinPath(kwsys_stl::vector<kwsys_stl::string>::const_iterator first,
+           kwsys_stl::vector<kwsys_stl::string>::const_iterator last)
+{
+  // Construct result in a single string.
   kwsys_stl::string result;
-  if(components.size() > 0)
+
+  // The first two components do not add a slash.
+  if(first != last)
     {
-    result += components[0];
+    result += *first++;
     }
-  if(components.size() > 1)
+  if(first != last)
     {
-    result += components[1];
+    result += *first++;
     }
-  for(unsigned int i=2; i < components.size(); ++i)
+
+  // All remaining components are always separated with a slash.
+  while(first != last)
     {
     result += "/";
-    result += components[i];
+    result += *first++;
     }
+
+  // Return the concatenated result.
   return result;
 }
 
@@ -3348,7 +3394,7 @@
   time_t t;
   time(&t);
   strftime(buf, sizeof(buf), format, localtime(&t));
-  return buf;
+  return kwsys_stl::string(buf);
 }
 
 kwsys_stl::string SystemTools::MakeCindentifier(const char* s)
@@ -3374,39 +3420,49 @@
 // Due to a buggy stream library on the HP and another on Mac OSX, we
 // need this very carefully written version of getline.  Returns true
 // if any data were read before the end-of-file was reached.
-bool SystemTools::GetLineFromStream(kwsys_ios::istream& is, kwsys_stl::string& line,
-                                    bool *has_newline /* = 0 */)
+bool SystemTools::GetLineFromStream(kwsys_ios::istream& is,
+                                    kwsys_stl::string& line,
+                                    bool* has_newline /* = 0 */)
 {
   const int bufferSize = 1024;
   char buffer[bufferSize];
-  line = "";
   bool haveData = false;
-  if ( has_newline )
-    {
-    *has_newline = false;
-    }
+  bool haveNewline = false;
+
+  // Start with an empty line.
+  line = "";
 
   // If no characters are read from the stream, the end of file has
-  // been reached.
-  while((is.getline(buffer, bufferSize), is.gcount() > 0))
+  // been reached.  Clear the fail bit just before reading.
+  while(!haveNewline &&
+        (is.clear(is.rdstate() & ~kwsys_ios::ios::failbit),
+         is.getline(buffer, bufferSize), is.gcount() > 0))
     {
+    // We have read at least one byte.
     haveData = true;
-    line.append(buffer);
 
-    // If newline character was read, the gcount includes the
-    // character, but the buffer does not.  The end of line has been
-    // reached.
-    if(strlen(buffer) < static_cast<size_t>(is.gcount()))
+    // If newline character was read the gcount includes the character
+    // but the buffer does not: the end of line has been reached.
+    size_t length = strlen(buffer);
+    if(length < static_cast<size_t>(is.gcount()))
       {
-      if ( has_newline )
+      haveNewline = true;
+      }
+
+    // Avoid storing a carriage return character.
+    if(length > 0 && buffer[length-1] == '\r')
         {
-        *has_newline = true;
+      buffer[length-1] = 0;
         }
-      break;
+
+    // Append the data read to the line.
+    line.append(buffer);
       }
 
-    // The fail bit may be set.  Clear it.
-    is.clear(is.rdstate() & ~kwsys_ios::ios::failbit);
+  // Return the results.
+  if(has_newline)
+    {
+    *has_newline = haveNewline;
     }
   return haveData;
 }



More information about the Cmake-commits mailing list