scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit f68fdbc771e1a8d3a0944c4fd455bcdcb48bdcd8
parent 7bc95eeda82f12145e9a7c835414ed3a58966c5a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 15 Aug 2012 18:45:44 +0200

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.

Diffstat:
Mlex.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lex.c b/lex.c @@ -64,10 +64,11 @@ static unsigned char skip(void) 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)