Index: trunk/psLib/src/sys/psSlurp.c
===================================================================
--- trunk/psLib/src/sys/psSlurp.c	(revision 8996)
+++ trunk/psLib/src/sys/psSlurp.c	(revision 9001)
@@ -5,6 +5,6 @@
  *  @author Joshua Hoblitt, University of Hawaii
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-27 00:59:58 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-09-27 03:28:52 $
  *
  *  Copyright 2006 University of Hawaii
@@ -25,29 +25,26 @@
 psString psSlurpFD(int fd)
 {
-    psString str    = NULL;
-    size_t strSize  = 1; // bytes allocated -  make sure there is room for '\0'
-    size_t used     = 0; // bytes actually used
-
-    for (;;) {
+    psString str = NULL;                // String to which to write
+    size_t size  = 1;                   // bytes allocated -  make sure there is room for '\0'
+    size_t used = 0;                    // bytes actually used
+    ssize_t bytes;                      // Number of bytes read
+    do {
         // increase the allocated string size
-        strSize += SLURP_SIZE;
-        str = psRealloc(str, strSize);
+        size += SLURP_SIZE;
+        str = psRealloc(str, size);
 
         // read a block from the stream
-        ssize_t bytes = read(fd, str + used, SLURP_SIZE);
+        bytes = read(fd, str + used, SLURP_SIZE);
         if (bytes < 0) {
             // it's an error
-            psError(PS_ERR_IO, true, "slurp failed");
+            psError(PS_ERR_IO, true, "slurp failed on read");
             psFree(str);
             return NULL;
         }
 
-        // is this the end of the file?
-        if (bytes == SLURP_SIZE) {
-            break;
-        }
+        // Increase the size of the known string
+        used += bytes;
 
-        used += bytes;
-    }
+    } while (bytes != 0);
 
     // append '\0' to the end of the string
