diff files.c @ 164:f14f5352956c

Merge upstream into Joerg's changes.
author David A. Holland
date Fri, 12 Jun 2015 01:00:38 -0400
parents d6e6b3940780 a2c2fe8dbea3
children ffdb0b73856f
line wrap: on
line diff
--- a/files.c	Fri Feb 27 13:44:39 2015 +0100
+++ b/files.c	Fri Jun 12 01:00:38 2015 -0400
@@ -172,14 +172,15 @@
 void
 file_read(const struct placefile *pf, int fd, const char *name, bool toplevel)
 {
-	struct place linestartplace, nextlinestartplace, ptmp;
+	struct lineplace places;
+	struct place ptmp;
 	size_t bufend, bufmax, linestart, lineend, nextlinestart, tmp;
 	ssize_t result;
 	bool ateof = false;
 	char *buf;
 
-	place_setfilestart(&linestartplace, pf);
-	nextlinestartplace = linestartplace;
+	place_setfilestart(&places.current, pf);
+	places.nextline = places.current;
 
 	bufmax = 128;
 	bufend = 0;
@@ -223,7 +224,7 @@
 			} else if (result == 0) {
 				/* eof in middle of line */
 				ateof = true;
-				ptmp = linestartplace;
+				ptmp = places.current;
 				ptmp.column += bufend - linestart;
 				complain(&ptmp, "No newline at end of file");
 				if (mode.werror) {
@@ -244,7 +245,7 @@
 		assert(buf[lineend] == '\n');
 		buf[lineend] = '\0';
 		nextlinestart = lineend+1;
-		nextlinestartplace.line++;
+		places.nextline.line++;
 
 		/* check for CR/NL */
 		if (lineend > 0 && buf[lineend-1] == '\r') {
@@ -271,21 +272,21 @@
 		assert(buf[lineend] == '\0');
 
 		/* count how many commented-out newlines we swallowed */
-		nextlinestartplace.line += countnls(buf, linestart, lineend);
+		places.nextline.line += countnls(buf, linestart, lineend);
 
 		/* if the line isn't empty, process it */
 		if (lineend > linestart) {
-			directive_gotline(&linestartplace, &nextlinestartplace,
+			directive_gotline(&places,
 					  buf+linestart, lineend-linestart);
 		}
 
 		linestart = nextlinestart;
 		lineend = findeol(buf, linestart, bufend);
-		linestartplace = nextlinestartplace;
+		places.current = places.nextline;
 	}
 
 	if (toplevel) {
-		directive_goteof(&linestartplace);
+		directive_goteof(&places.current);
 	}
 	dofree(buf, bufmax);
 }