Index: /trunk/src/kObjCache/kObjCache.c
===================================================================
--- /trunk/src/kObjCache/kObjCache.c	(revision 1037)
+++ /trunk/src/kObjCache/kObjCache.c	(revision 1038)
@@ -41,5 +41,5 @@
 #ifndef PATH_MAX
 # define PATH_MAX _MAX_PATH /* windows */
-#endif 
+#endif
 #if defined(__OS2__) || defined(__WIN__)
 # include <process.h>
@@ -47,5 +47,5 @@
 # ifdef __OS2__
 #  include <unistd.h>
-# endif 
+# endif
 #else
 # include <unistd.h>
@@ -54,5 +54,5 @@
 #  define O_BINARY 0
 # endif
-#endif 
+#endif
 #include "crc32.h"
 #include "md5.h"
@@ -67,5 +67,5 @@
 #else
 # define PATH_SLASH '/'
-#endif 
+#endif
 #if defined(__OS2__) || defined(__WIN__)
 # define IS_SLASH(ch)       ((ch) == '/' || (ch) == '\\')
@@ -74,5 +74,5 @@
 # define IS_SLASH(ch)       ((ch) == '/')
 # define IS_SLASH_DRV(ch)   ((ch) == '/')
-#endif 
+#endif
 /** Use pipe instead of temp files when possible (speed). */
 #define USE_PIPE 1
@@ -84,6 +84,6 @@
 *******************************************************************************/
 /** A checksum list entry.
- * We keep a list checksums (of precompiler output) that matches, The planned 
- * matching algorithm doesn't require the precompiler output to be indentical, 
+ * We keep a list checksums (of precompiler output) that matches, The planned
+ * matching algorithm doesn't require the precompiler output to be indentical,
  * only to produce the same object files.
  */
@@ -111,6 +111,6 @@
     /** Set if the object needs to be (re)compiled. */
     unsigned fNeedCompiling;
-    /** Whether the precompiler runs in piped mode. If clear it's file 
-     * mode (it could be redirected stdout, but that's essentially the 
+    /** Whether the precompiler runs in piped mode. If clear it's file
+     * mode (it could be redirected stdout, but that's essentially the
      * same from our point of view). */
     unsigned fPiped;
@@ -172,8 +172,8 @@
 
 /**
- * Compares two check sum entries. 
- *  
- * @returns 1 if equal, 0 if not equal. 
- *  
+ * Compares two check sum entries.
+ *
+ * @returns 1 if equal, 0 if not equal.
+ *
  * @param pSum1     The first checksum.
  * @param pSum2     The second checksum.
@@ -195,5 +195,5 @@
 /**
  * Print a fatal error message and exit with rc=1.
- * 
+ *
  * @param   pEntry      The cache entry.
  * @param   pszFormat   The message to print.
@@ -215,5 +215,5 @@
 /**
  * Print a verbose message if verbosisty is enabled.
- * 
+ *
  * @param   pEntry      The cache entry.
  * @param   pszFormat   The message to print.
@@ -225,5 +225,5 @@
     {
         va_list va;
-    
+
         fprintf(stdout, "kObjCache %s - info: ", pEntry->pszName);
         va_start(va, pszFormat);
@@ -236,5 +236,5 @@
 /**
  * Creates a cache entry for the given cache file name.
- *  
+ *
  * @returns Pointer to a cache entry.
  * @param   pszFilename     The cache file name.
@@ -265,6 +265,6 @@
 #if 0 /* don't bother. */
 /**
- * Destroys the cache entry freeing up all it's resources. 
- *  
+ * Destroys the cache entry freeing up all it's resources.
+ *
  * @param   pEntry      The entry to free.
  */
@@ -287,5 +287,5 @@
 /**
  * Reads and parses the cache file.
- *  
+ *
  * @param   pEntry      The entry to read it into.
  */
@@ -299,5 +299,5 @@
         kObjCacheVerbose(pEntry, "reading cache file...\n");
 
-        /* 
+        /*
          * Check the magic.
          */
@@ -404,5 +404,5 @@
                     if (fBad)
                         break;
-                    
+
                     if (fFirstSum)
                     {
@@ -419,5 +419,5 @@
                 }
                 else
-                {         
+                {
                     fBad = 1;
                     break;
@@ -457,5 +457,5 @@
 /**
  * Writes the cache file.
- *  
+ *
  * @param   pEntry      The entry to write.
  */
@@ -469,5 +469,5 @@
     pFile = FOpenFileInDir(pEntry->pszName, pEntry->pszDir, "wb");
     if (!pFile)
-        kObjCacheFatal(pEntry, "Failed to open '%s' in '%s': %s\n", 
+        kObjCacheFatal(pEntry, "Failed to open '%s' in '%s': %s\n",
                        pEntry->pszName, pEntry->pszDir, strerror(errno));
 
@@ -485,5 +485,5 @@
          pSum;
          pSum = pSum->pNext)
-        fprintf(pFile, "sum=%#x:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", 
+        fprintf(pFile, "sum=%#x:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
                 pSum->crc32,
                 pSum->md5[0], pSum->md5[1], pSum->md5[2], pSum->md5[3],
@@ -491,5 +491,5 @@
                 pSum->md5[8], pSum->md5[9], pSum->md5[10], pSum->md5[11],
                 pSum->md5[12], pSum->md5[13], pSum->md5[14], pSum->md5[15]);
-    
+
     if (    fflush(pFile) < 0
         ||  ferror(pFile))
@@ -498,5 +498,5 @@
         fclose(pFile);
         UnlinkFileInDir(pEntry->pszName, pEntry->pszDir);
-        kObjCacheFatal(pEntry, "Stream error occured while writing '%s' in '%s': %d (?)\n", 
+        kObjCacheFatal(pEntry, "Stream error occured while writing '%s' in '%s': %d (?)\n",
                        pEntry->pszName, pEntry->pszDir, strerror(iErr));
     }
@@ -508,5 +508,5 @@
  * Spawns a child in a synchronous fashion.
  * Terminating on failure.
- * 
+ *
  * @param   papszArgv       Argument vector. The cArgv element is NULL.
  * @param   cArgv           The number of arguments in the vector.
@@ -524,5 +524,5 @@
         fdReDir = open(pszStdOut, O_CREAT | O_TRUNC | O_WRONLY, 0777);
         if (fdReDir < 0)
-            kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n", 
+            kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n",
                            pszMsg, pszStdOut, strerror(errno));
 
@@ -561,5 +561,5 @@
             fdReDir = open(pszStdOut, O_CREAT | O_TRUNC | O_WRONLY, 0777);
             if (fdReDir < 0)
-                kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n", 
+                kObjCacheFatal(pEntry, "%s - failed to create stdout redirection file '%s': %s\n",
                                pszMsg, pszStdOut, strerror(errno));
             if (fdReDir != 1)
@@ -572,5 +572,5 @@
 
         execvp(papszArgv[0], (char **)papszArgv);
-        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n", 
+        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n",
                        pszMsg, strerror(errno));
     }
@@ -582,5 +582,5 @@
         pidWait = waitpid(pid, &iStatus, 0);
     if (pidWait != pid)
-        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n", 
+        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n",
                        pszMsg, pidWait, strerror(errno));
     if (!WIFEXITED(iStatus))
@@ -597,5 +597,5 @@
  * Spawns a child in a synchronous fashion.
  * Terminating on failure.
- * 
+ *
  * @param   papszArgv       Argument vector. The cArgv element is NULL.
  * @param   cArgv           The number of arguments in the vector.
@@ -632,5 +632,5 @@
     fcntl(fds[0], F_SETFD, FD_CLOEXEC);
     fcntl(fdStdOut, F_SETFD, FD_CLOEXEC);
-#endif 
+#endif
 
     /*
@@ -648,10 +648,10 @@
     {
         execvp(papszArgv[0], (char **)papszArgv);
-        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n", 
+        kObjCacheFatal(pEntry, "%s - execvp failed: %s\n",
                        pszMsg, strerror(errno));
     }
     if (pid == -1)
         kObjCacheFatal(pEntry, "%s - fork() failed: %s\n", pszMsg, strerror(errno));
-#endif 
+#endif
 
     /*
@@ -682,5 +682,4 @@
         {
             size_t off = psz - *ppszOutput;
-            assert(off == cbAlloc);
             cbLeft = 4*1024*1024;
             cbAlloc += cbLeft;
@@ -688,5 +687,5 @@
             psz = *ppszOutput + off;
         }
-    } 
+    }
     close(fds[0]);
     *pcchOutput = cbAlloc - cbLeft;
@@ -698,5 +697,5 @@
     pidWait = _cwait(&iStatus, pid, _WAIT_CHILD);
     if (pidWait == -1)
-        kObjCacheFatal(pEntry, "%s - waitpid failed: %s\n", 
+        kObjCacheFatal(pEntry, "%s - waitpid failed: %s\n",
                        pszMsg, strerror(errno));
     if (iStatus)
@@ -707,5 +706,5 @@
         pidWait = waitpid(pid, &iStatus, 0);
     if (pidWait != pid)
-        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n", 
+        kObjCacheFatal(pEntry, "%s - waitpid failed rc=%d: %s\n",
                        pszMsg, pidWait, strerror(errno));
     if (!WIFEXITED(iStatus))
@@ -721,7 +720,7 @@
 /**
  * Reads the (new) output of the precompiler.
- * 
+ *
  * Not used when using pipes.
- * 
+ *
  * @param   pEntry      The cache entry. cbNewCpp and pszNewCppMapping will be updated.
  */
@@ -730,5 +729,5 @@
     pEntry->pszNewCppMapping = ReadFileInDir(pEntry->pszNewCppName, pEntry->pszDir, &pEntry->cbNewCpp);
     if (!pEntry->pszNewCppMapping)
-        kObjCacheFatal(pEntry, "failed to open/read '%s' in '%s': %s\n", 
+        kObjCacheFatal(pEntry, "failed to open/read '%s' in '%s': %s\n",
                        pEntry->pszNewCppName, pEntry->pszDir, strerror(errno));
     kObjCacheVerbose(pEntry, "precompiled file is %lu bytes long\n", (unsigned long)pEntry->cbNewCpp);
@@ -737,7 +736,7 @@
 
 /**
- * Worker for kObjCachePreCompile and calculates the checksum of 
+ * Worker for kObjCachePreCompile and calculates the checksum of
  * the precompiler output.
- * 
+ *
  * @param   pEntry      The cache entry. NewSum will be updated.
  */
@@ -763,5 +762,5 @@
 /**
  * Run the precompiler and calculate the checksum of the output.
- *  
+ *
  * @param   pEntry              The cache entry.
  * @param   papszArgvPreComp    The argument vector for executing precompiler. The cArgvPreComp'th argument must be NULL.
@@ -779,5 +778,5 @@
         pEntry->fPiped = 1;
     else
-#endif 
+#endif
         pEntry->fPiped = 0;
 
@@ -788,5 +787,5 @@
      * If we're using the pipe strategy, we will not do any renaming.
      */
-    if (    pEntry->pszOldCppName 
+    if (    pEntry->pszOldCppName
         &&  !pEntry->fPiped
         &&  DoesFileInDirExist(pEntry->pszOldCppName, pEntry->pszDir))
@@ -800,5 +799,5 @@
         UnlinkFileInDir(psz, pEntry->pszDir);
         if (RenameFileInDir(pEntry->pszOldCppName, psz, pEntry->pszDir))
-            kObjCacheFatal(pEntry, "failed to rename '%s' -> '%s' in '%s': %s\n", 
+            kObjCacheFatal(pEntry, "failed to rename '%s' -> '%s' in '%s': %s\n",
                            pEntry->pszOldCppName, psz, pEntry->pszDir, strerror(errno));
         free(pEntry->pszOldCppName);
@@ -815,5 +814,5 @@
         kObjCacheSpawnPipe(pEntry, papszArgvPreComp, cArgvPreComp, "precompile", &pEntry->pszNewCppMapping, &pEntry->cbNewCpp);
     else
-#endif 
+#endif
     {
         if (fRedirStdOut)
@@ -829,7 +828,7 @@
 /**
  * Check whether the string is a '#line' statement.
- * 
+ *
  * @returns 1 if it is, 0 if it isn't.
- * @param   psz         The line to examin. 
+ * @param   psz         The line to examin.
  * @parma   piLine      Where to store the line number.
  * @parma   ppszFile    Where to store the start of the filename.
@@ -855,5 +854,5 @@
         return 0;
     iLine = 0;
-    do  
+    do
     {
         iLine *= 10;
@@ -878,5 +877,5 @@
 /**
  * Scan backwards for the previous #line statement.
- * 
+ *
  * @returns The filename in the previous statement.
  * @param   pszStart        Where to start.
@@ -913,8 +912,8 @@
 
 /**
- * Worker for kObjCacheCompareOldAndNewOutput() that compares the 
+ * Worker for kObjCacheCompareOldAndNewOutput() that compares the
  * precompiled output using a fast but not very good method.
- * 
- * @returns 1 if matching, 0 if not matching. 
+ *
+ * @returns 1 if matching, 0 if not matching.
  * @param   pEntry      The entry containing the names of the files to compare.
  *                      The entry is not updated in any way.
@@ -952,15 +951,15 @@
              * Pinpoint the difference exactly and the try find the start
              * of that line. Then skip forward until we find something to
-             * work on that isn't spaces, #line statements or closing curly 
-             * braces. 
+             * work on that isn't spaces, #line statements or closing curly
+             * braces.
              *
-             * The closing curly braces are ignored because they are frequently 
-             * found at the end of header files (__END_DECLS) and the worst 
-             * thing that may happen if it isn't one of these braces we're 
-             * ignoring is that the final line in a function block is a little 
-             * bit off in the debug info. 
+             * The closing curly braces are ignored because they are frequently
+             * found at the end of header files (__END_DECLS) and the worst
+             * thing that may happen if it isn't one of these braces we're
+             * ignoring is that the final line in a function block is a little
+             * bit off in the debug info.
              *
-             * Since we might be skipping a few new empty headers, it is 
-             * possible that we will omit this header from the dependencies 
+             * Since we might be skipping a few new empty headers, it is
+             * possible that we will omit this header from the dependencies
              * when using VCC. This might not be a problem, since it seems
              * we'll have to use the precompiler output to generate the deps
@@ -987,5 +986,5 @@
             /* locate the start of that line. */
             psz = psz1;
-            while (     psz > pEntry->pszNewCppMapping 
+            while (     psz > pEntry->pszNewCppMapping
                    &&   psz[-1] != '\n')
                 psz--;
@@ -1133,5 +1132,5 @@
     }
 
-    return psz1 == pszEnd1 
+    return psz1 == pszEnd1
         && psz2 == pszEnd2;
 }
@@ -1139,8 +1138,8 @@
 
 /**
- * Worker for kObjCacheCompileIfNeeded that compares the 
- * precompiled output. 
- * 
- * @returns 1 if matching, 0 if not matching. 
+ * Worker for kObjCacheCompileIfNeeded that compares the
+ * precompiled output.
+ *
+ * @returns 1 if matching, 0 if not matching.
  * @param   pEntry      The entry containing the names of the files to compare.
  *                      This will load the old cpp output (changing pszOldCppName and cbOldCpp).
@@ -1148,7 +1147,7 @@
 static int kObjCacheCompareOldAndNewOutput(PKOBJCACHE pEntry)
 {
-    /** @todo do some quick but fancy comparing that determins whether code 
+    /** @todo do some quick but fancy comparing that determins whether code
      * has actually changed or moved. We can ignore declarations and typedefs that
-     * has just been moved up/down a bit. The typical case is adding a new error 
+     * has just been moved up/down a bit. The typical case is adding a new error
      * #define that doesn't influence the current compile job. */
 
@@ -1159,5 +1158,5 @@
     if (!pEntry->pszOldCppMapping)
     {
-        kObjCacheVerbose(pEntry, "failed to read old cpp file ('%s' in '%s'): %s\n", 
+        kObjCacheVerbose(pEntry, "failed to read old cpp file ('%s' in '%s'): %s\n",
                          pEntry->pszOldCppName, pEntry->pszDir, strerror(errno));
         return 0;
@@ -1174,7 +1173,7 @@
 
 /**
- * Worker for kObjCacheCompileIfNeeded that does the actual (re)compilation. 
- * 
- * @returns 1 if matching, 0 if not matching. 
+ * Worker for kObjCacheCompileIfNeeded that does the actual (re)compilation.
+ *
+ * @returns 1 if matching, 0 if not matching.
  * @param   pEntry              The cache entry.
  * @param   papszArgvCompile    The argument vector for invoking the compiler. The cArgvCompile'th entry must be NULL.
@@ -1202,5 +1201,5 @@
         FILE *pFile = FOpenFileInDir(pEntry->pszNewCppName, pEntry->pszDir, "wb");
         if (!pFile)
-            kObjCacheFatal(pEntry, "failed to create file '%s' in '%s': %s\n", 
+            kObjCacheFatal(pEntry, "failed to create file '%s' in '%s': %s\n",
                            pEntry->pszNewCppName, pEntry->pszDir, strerror(errno));
         if (fwrite(pEntry->pszNewCppMapping, pEntry->cbNewCpp, 1, pFile) != 1)
@@ -1230,6 +1229,6 @@
 /**
  * Check if (re-)compilation is required and do it.
- * 
- * @returns 1 if matching, 0 if not matching. 
+ *
+ * @returns 1 if matching, 0 if not matching.
  * @param   pEntry              The cache entry.
  * @param   papszArgvCompile    The argument vector for invoking the compiler. The cArgvCompile'th entry must be NULL.
@@ -1257,5 +1256,5 @@
      * TODO: Ignore irrelevant options here (like warning level).
      */
-    if (    !pEntry->fNeedCompiling 
+    if (    !pEntry->fNeedCompiling
         &&  pEntry->cArgvCompile != cArgvCompile)
     {
@@ -1333,6 +1332,6 @@
 
 /**
- * Gets the absolute path 
- * 
+ * Gets the absolute path
+ *
  * @returns A new heap buffer containing the absolute path.
  * @param   pszPath     The path to make absolute. (Readonly)
@@ -1354,5 +1353,5 @@
 /**
  * Utility function that finds the filename part in a path.
- * 
+ *
  * @returns Pointer to the file name part (this may be "").
  * @param   pszPath     The path to parse.
@@ -1361,5 +1360,5 @@
 {
     const char *pszFilename = strchr(pszPath, '\0') - 1;
-    while (     pszFilename > pszPath 
+    while (     pszFilename > pszPath
            &&   !IS_SLASH_DRV(pszFilename[-1]))
         pszFilename--;
@@ -1370,5 +1369,5 @@
 /**
  * Utility function that combines a filename and a directory into a path.
- * 
+ *
  * @returns malloced buffer containing the result.
  * @param   pszName     The file name.
@@ -1390,8 +1389,8 @@
 /**
  * Compares two path strings to see if they are identical.
- * 
- * This doesn't do anything fancy, just the case ignoring and 
+ *
+ * This doesn't do anything fancy, just the case ignoring and
  * slash unification.
- * 
+ *
  * @returns 1 if equal, 0 otherwise.
  * @param   pszPath1    The first path.
@@ -1424,5 +1423,5 @@
 #else
     return !strncmp(pszPath1, pszPath2, cch);
-#endif 
+#endif
 }
 
@@ -1430,5 +1429,5 @@
 /**
  * Calculate how to get to pszPath from pszDir.
- * 
+ *
  * @returns The relative path from pszDir to path pszPath.
  * @param   pszPath     The path to the object.
@@ -1482,5 +1481,5 @@
 /**
  * Utility function that combines a filename and directory and passes it onto fopen.
- * 
+ *
  * @returns fopen return value.
  * @param   pszName     The file name.
@@ -1499,5 +1498,5 @@
 /**
  * Deletes a file in a directory.
- * 
+ *
  * @returns whatever unlink returns.
  * @param   pszName     The file name.
@@ -1515,5 +1514,5 @@
 /**
  * Renames a file in a directory.
- * 
+ *
  * @returns whatever unlink returns.
  * @param   pszOldName  The new file name.
@@ -1534,5 +1533,5 @@
 /**
  * Check if a (regular) file exists in a directory.
- * 
+ *
  * @returns 1 if it exists and is a regular file, 0 if not.
  * @param   pszName     The file name.
@@ -1551,5 +1550,5 @@
 #else
 #error "Port me"
-#endif 
+#endif
 }
 
@@ -1557,5 +1556,5 @@
 /**
  * Reads into memory an entire file.
- * 
+ *
  * @returns Pointer to the heap allocation containing the file.
  *          On failure NULL and errno is returned.
@@ -1632,5 +1631,5 @@
 /**
  * Prints a syntax error and returns the appropriate exit code
- * 
+ *
  * @returns approriate exit code.
  * @param   pszFormat   The syntax error message.
@@ -1780,5 +1779,5 @@
 
 /** @page kObjCache Benchmarks.
- * 
+ *
  * 2007-06-02 - 21-23:00:
  * Mac OS X debug -j 3 clobber build (rm -Rf out/darwin.x86/debug ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3):
@@ -1786,7 +1785,7 @@
  *  user    13m13.291s
  *  sys     2m58.193s
- * 
+ *
  * Mac OS X debug -j 3 depend build (touch include/iprt/err.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3):
- *  real    3m55.275s                                                                                            
+ *  real    3m55.275s
  *  user    4m11.852s
  *  sys     0m54.931s
@@ -1796,14 +1795,14 @@
  *  user    14m27.736s
  *  sys     3m39.512s
- * 
+ *
  * Mac OS X debug -j 3 cached depend build (touch include/iprt/err.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3 USE_KOBJCACHE=1):
  *  real    1m17.445s
  *  user    1m13.410s
  *  sys     0m22.789s
- * 
+ *
  * Mac OS X debug -j3 cached depend build (touch include/iprt/cdefs.h ; sync ; svn diff ; sync ; sleep 1 ; time kmk -j 3 USE_KOBJCACHE=1):
  *  real    1m29.315s
  *  user    1m31.391s
  *  sys     0m32.748s
- * 
- */
+ *
+ */
