Re: [AD] pack_ferror() - differences between platforms

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Apologies: I did a test, and it turns out that pack_ferror() doesn't actually 
return nonzero if you read beyond the end of a file with DJGPP. I thought it 
did, and that's why I wanted to make Allegro behave the same on Linux.

Now, as to exactly why my level loader stopped loading levels when compiled 
with DJGPP, but managed to load 65000-odd blank levels when I ran it on 
Linux, I've done some more investigation. It appears that malloc() is 
actually clearing the memory for me on Linux - for some reason - so my code 
thinks the level data are valid. With DJGPP, it encounters garbage, and the 
extra levels are invalidated. But that's off topic here.

Nevertheless, I believe the documentation could be improved. A patch for this 
is attached. I'm determined to get at least ONE patch in today :)

Ben
--- docs/src/allegro._tx.old	Sun Jan 19 13:26:35 2003
+++ docs/src/allegro._tx	Sun Jan 19 23:59:18 2003
@@ -6320,6 +6320,12 @@
    from the current text encoding. Newlines (\n) are written as \r\n on
    DOS/Windows. If you do not want either of these things to happen,
    use pack_fwrite() and/or pack_putc() instead.
+<li>
+   pack_feof() returns nonzero as soon as you reach the end of the file. It 
+   does not wait for you to attempt to read beyond the end of the file. The 
+   only way to know whether you have read beyond the end of the file is to 
+   check the return value of every read operation you do (and be wary of 
+   pack_*getl() as EOF is also a valid return value with these functions).
 </ul>
 @@PACKFILE *@pack_fopen_chunk(PACKFILE *f, int pack);
 @xref pack_fclose_chunk, pack_fopen


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/