shithub: scc

Download patch

ref: 3ebea5faa5010e59f17ad4df846d0b5440c5f82c
parent: 04a23f827762c3430fb2002d9eeca96bbad775ef
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jun 8 11:30:14 EDT 2012

Added correct handling of numline and numcolum

These variables indicate where the lexical analyser is reading in a moment
in the input file. So it is necessary begin the count in column and line 1,
and each time that you find a new line, increment the count of lines and
reset the column count.

--- a/lex.c
+++ b/lex.c
@@ -211,8 +211,12 @@
 	register unsigned char ch;
 	extern char parser_out_home;
 
-	while (isspace(c = getc(yyin)))
-		/* nothing */;
+	while (isspace(c = getc(yyin))) {
+		if ((char) c == '\n')
+			++linenum, columnum = 1;
+		else
+			++columnum;
+	}
 	if (c == EOF) {
 		if (parser_out_home)
 			error("Find EOF while parsing");
@@ -343,4 +347,5 @@
 	if ((yyin = fopen(file, "r")) == NULL)
 		die("file '%s' not found", file);
 	filename = file;
+	columnum = linenum = 1;
 }