summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'read.c')
-rw-r--r--read.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/read.c b/read.c
index ec54650..6d2de07 100644
--- a/read.c
+++ b/read.c
@@ -380,7 +380,9 @@ eval_makefile (filename, flags)
reading_file = curfile;
- free(ebuf.bufstart);
+ fclose (ebuf.fp);
+
+ free (ebuf.bufstart);
return r;
}
@@ -2564,7 +2566,12 @@ readline (ebuf)
if (ferror (ebuf->fp))
pfatal_with_name (ebuf->floc.filenm);
- return nlines ? nlines : -1;
+ /* If we found some lines, return how many.
+ If we didn't, but we did find _something_, that indicates we read the last
+ line of a file with no final newline; return 1.
+ If we read nothing, we're at EOF; return -1. */
+
+ return nlines ? nlines : p == ebuf->bufstart ? -1 : 1;
}
/* Parse the next "makefile word" from the input buffer, and return info