shithub: scc

Download patch

ref: f68fdbc771e1a8d3a0944c4fd455bcdcb48bdcd8
parent: 7bc95eeda82f12145e9a7c835414ed3a58966c5a
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 15 14:45:44 EDT 2012

Fixed column count in case of tabs

We were using a count of 1 for each blank (space) of the code, but this was
no correct in the case of tabulators, where we have to add 8.

--- a/lex.c
+++ b/lex.c
@@ -64,10 +64,11 @@
 	extern char parser_out_home;
 
 	while (isspace(c = getc(yyin))) {
-		if (c == '\n')
-			++linenum, columnum = 1;
-		else
-			++columnum;
+		switch (c) {
+		case '\n': ++linenum, columnum = 1; break;
+		case '\t': columnum += 8;	    break;
+		default:   ++columnum;		    break;
+		}
 	}
 	if (c == EOF) {
 		if (parser_out_home)