diff files.c @ 28:8a955e3dda2c posted-20101220

two more tests, more fixes
author David A. Holland
date Mon, 20 Dec 2010 05:42:15 -0500
parents daa801fe719e
children 76c114899f63
line wrap: on
line diff
--- a/files.c	Mon Dec 20 05:01:18 2010 -0500
+++ b/files.c	Mon Dec 20 05:42:15 2010 -0500
@@ -102,7 +102,7 @@
 
 static
 void
-file_read(const struct placefile *pf, int fd, const char *name)
+file_read(const struct placefile *pf, int fd, const char *name, bool toplevel)
 {
 	struct place linestartplace, nextlinestartplace, ptmp;
 	size_t bufend, bufmax, linestart, lineend, nextlinestart, tmp;
@@ -210,7 +210,9 @@
 		linestartplace = nextlinestartplace;
 	}
 
-	directive_goteof(&linestartplace);
+	if (toplevel) {
+		directive_goteof(&linestartplace);
+	}
 	free(buf);
 }
 
@@ -276,7 +278,7 @@
 		fd = file_tryopen(file);
 		if (fd >= 0) {
 			pf = place_addfile(place, file, id->issystem);
-			file_read(pf, fd, file);
+			file_read(pf, fd, file, false);
 			free(file);
 			close(fd);
 			return;
@@ -319,7 +321,7 @@
 		pf = place_addfile(place, name, false);
 	}
 
-	file_read(pf, fd, name);
+	file_read(pf, fd, name, true);
 
 	if (name != NULL) {
 		close(fd);