home · contact · privacy
Re-wrote map object system to use same structs for items and monsters, and switched...
[plomrogue] / src / readwrite.c
index 09faaeb282dcb8a84731c5c1bce3c69b2dd41c77..657d8173dd674ecfa9528cfce9653ee5dd841449 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "readwrite.h"
 #include <stdio.h>  /* for FILE typedef, fopen(), fgetc(), fputc(), fseek(),
-                     * sprintf(), fwrite()
+                     * sprintf(), fwrite(), ferror()
                      */
 #include <stdint.h> /* for uint8_t, uint16_t, uint32_t */
 #include <string.h> /* for strlen()*/
@@ -59,12 +59,14 @@ extern void try_fclose(FILE * file, struct World * w, char * f)
 
 
 
-extern void try_fgets(char * line, int linemax, FILE * file,
-                      struct World * w, char * f)
+extern char * try_fgets(char * line, int linemax, FILE * file,
+                        struct World * w, char * f)
 {
     char * msg = trouble_msg(w, f, "fgets()");
-    exit_err(NULL == fgets(line, linemax, file), w, msg);
+    char * test = fgets(line, linemax, file);
+    exit_err(NULL == test && ferror(file), w, msg);
     free(msg);
+    return test;
 }