[Gridflow-cvs] [svn] commit: r4846 - /trunk/src/formats.cxx

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Nov 9 13:53:15 EST 2009


Author: matju
Date: Mon Nov  9 13:53:15 2009
New Revision: 4846

Log:
[#in grid]: fix EOF bug

Modified:
    trunk/src/formats.cxx

Modified: trunk/src/formats.cxx
==============================================================================
--- trunk/src/formats.cxx (original)
+++ trunk/src/formats.cxx Mon Nov  9 13:53:15 2009
@@ -170,12 +170,15 @@
 //	\decl void raw_open_gzip_out(string filename);
 };
 \def 0 bang () {
+	//post("#io.grid 0 bang: ftell=%ld",ftell(f));
 	P<Dim> dim;
 	if (feof(f)) {outlet_bang(bself->te_outlet); return;}
 	if (headerless_dim) {
 		dim = headerless_dim;
 	} else {
-		if (fread(&head,1,8,f)<8) RAISE("can't read header");
+		int r = fread(&head,1,8,f);
+		if (feof(f)) {outlet_bang(bself->te_outlet); return;} /* damn */
+		if (r<8) RAISE("can't read header: got %d bytes instead of 8",r);
 		uint8 *m = (uint8 *)head.magic;
 		if (strncmp((char *)m,"\x7fgrid",5)==0) endian=1; else
 		if (strncmp((char *)m,"\x7fGRID",5)==0) endian=0; else



More information about the Gridflow-cvs mailing list