commit df063b6694f70d8d0d43ced04cea5da6ee78afc7
Author: Markus Pfeiffer <markus.pfeiffer@morphism.de>
Date:   Mon Oct 3 11:20:21 2016 +0100

    Make StringFile work on pipes again
    
    * This was introduced by the new READ_FILE_STRING code
      commits (29a3adb0, 01271c25)
    * We use pipes for reading gzipped files
    * A pipe does not have a size
    * If a fid is a pipe we use a generic read function
    
    Reported-By: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>

diff --git a/src/streams.c b/src/streams.c
index a597c30..93fbe07 100644
--- a/src/streams.c
+++ b/src/streams.c
@@ -1978,10 +1978,7 @@ Obj FuncREAD_STRING_FILE (
             (Int)TNAM_OBJ(fid), 0L,
             "you can replace <fid> via 'return <fid>;'" );
     }
-    if ( syBuf[INT_INTOBJ(fid)].pipe == 1 ) {
-        ErrorMayQuit("<fid> is a pipe, not a file", 0L, 0L);
-    }
-    return SyReadStringFile(INT_INTOBJ(fid));
+    return SyReadStringFid(INT_INTOBJ(fid));
 }
 
 /****************************************************************************
diff --git a/src/sysfiles.c b/src/sysfiles.c
index c7396ae..3e74086 100644
--- a/src/sysfiles.c
+++ b/src/sysfiles.c
@@ -4024,11 +4024,43 @@ Char * SyTmpdir ( const Char * hint )
 #endif
 #endif
 
+Obj SyReadStringFile(Int fid)
+{
+    Char            buf[32769];
+    Int             ret, len;
+    UInt            lstr;
+    Obj             str;
+
+    /* read <fid> until we see  eof   (in 32kB pieces)                     */
+    str = NEW_STRING(0);
+    len = 0;
+    do {
+        ret = read( syBuf[fid].fp , buf, 32768);
+        if (ret < 0) {
+            SySetErrorNo();
+            return Fail;
+        }
+        len += ret;
+        GROW_STRING( str, len );
+        lstr = GET_LEN_STRING(str);
+        memcpy( CHARS_STRING(str)+lstr, buf, ret );
+        *(CHARS_STRING(str)+lstr+ret) = '\0';
+        SET_LEN_STRING(str, lstr+ret);
+    } while(ret > 0);
+
+    /* fix the length of <str>                                             */
+    len = GET_LEN_STRING(str);
+    ResizeBag( str, SIZEBAG_STRINGLEN(len) );
+
+    syBuf[fid].ateof = 1;
+    return str;
+}
+
 #if !defined(SYS_IS_CYGWIN32) && defined(HAVE_STAT)
 /* fstat seems completely broken under CYGWIN */
 /* first try to get the whole file as one chunk, this avoids garbage
    collections because of the GROW_STRING calls below    */
-Obj SyReadStringFile(Int fid)
+Obj SyReadStringFileStat(Int fid)
 {
     Int             ret, len;
     Obj             str;
@@ -4065,42 +4097,25 @@ Obj SyReadStringFile(Int fid)
     }
 }
 
-#else
-
-Obj SyReadStringFile(Int fid)
+Obj SyReadStringFid(Int fid)
 {
-    Char            buf[32769];
-    Int             ret, len;
-    UInt            lstr;
-    Obj             str;
-
-    /* read <fid> until we see  eof   (in 32kB pieces)                     */
-    str = NEW_STRING(0);
-    len = 0;
-    do {
-        ret = read( syBuf[fid].fp , buf, 32768);
-        if (ret < 0) {
-            SySetErrorNo();
-            return Fail;
-        }
-        len += ret;
-        GROW_STRING( str, len );
-        lstr = GET_LEN_STRING(str);
-        memcpy( CHARS_STRING(str)+lstr, buf, ret );
-        *(CHARS_STRING(str)+lstr+ret) = '\0';
-        SET_LEN_STRING(str, lstr+ret);
-    } while(ret > 0);
+    if(syBuf[fid].pipe == 1) {
+        return SyReadStringFile(fid);
+    } else {
+        return SyReadStringFileStat(fid);
+    }
+}
 
-    /* fix the length of <str>                                             */
-    len = GET_LEN_STRING(str);
-    ResizeBag( str, SIZEBAG_STRINGLEN(len) );
+#else
 
-    syBuf[fid].ateof = 1;
-    return str;
+Obj SyReadStringFid(Int fid) {
+    return SyReadStringFile(fid);
 }
 
 #endif
 
+
+
 /****************************************************************************
 **
 *V  GVarFuncs . . . . . . . . . . . . . . . . . . list of functions to export
diff --git a/src/sysfiles.h b/src/sysfiles.h
index 5dbf5c7..dbf6b19 100644
--- a/src/sysfiles.h
+++ b/src/sysfiles.h
@@ -632,15 +632,19 @@ extern void syWinPut (
 
 /***************************************************************************
  **
- *F SyReadFileString( <fid> )
- **   - read file given by <fid> file into a string
+ *F SyReadStringFid( <fid> )
+ **   - read file given by <fid> into a string
+ *F SyReadStringFile( <fid> )
+ **   - read file given by <fid> into a string, only rely on read()
+ *F SyReadStringFileStat( <fid> )
+ **   - read file given by <fid> into a string, use stat() to determine
+ **     size of file before reading. This does not work for pipes
  */
 
-extern Obj SyReadStringFile (
-    Int fid );
+extern Obj SyReadStringFid(Int fid);
+extern Obj SyReadStringFile(Int fid);
+extern Obj SyReadStringFileGeneric(Int fid);
 
-
-     
 /****************************************************************************
 **
 
