xmahjongg (3.7-3) 05-feof.patch

Summary

 src/game.cc |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

    
download this patch

Patch contents

Do not break if fgets() detects EOF when invoked *at* EOF instead of
setting the EOF flag at the end of the previous invocation, after
the final newline has been read.

--- a/src/game.cc
+++ b/src/game.cc
@@ -498,7 +498,7 @@
   while (!feof(f)) {
     buffer[0] = 0;
     if (fgets(buffer, BUFSIZ, f) == NULL)
-      return false;
+      return feof(f)? true: false;
     int r, c, l;
     if (sscanf(buffer, " %d %d %d", &r, &c, &l) == 3)
       if (!place_tile(r+2, c+2, l))
@@ -527,7 +527,7 @@
     for (int r = 0; r < 16 && !feof(f); r++) {
       buf[0] = 0;
       if (fgets(buf, BUFSIZ, f) == NULL)
-	return false;
+	return feof(f)? true: false;
       for (int c = 0; c < TILE_COLS - 3 && buf[c] && !isspace(buf[c]); c++)
 	if (buf[c] == '1') {
 	  if (!place_tile(r + 2, c + 2, l))