scc

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

commit 3ebea5faa5010e59f17ad4df846d0b5440c5f82c
parent 04a23f827762c3430fb2002d9eeca96bbad775ef
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Jun 2012 15:30:14 +0200

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.

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

diff --git a/lex.c b/lex.c @@ -211,8 +211,12 @@ unsigned char next(void) 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 @@ void open_file(const char *file) if ((yyin = fopen(file, "r")) == NULL) die("file '%s' not found", file); filename = file; + columnum = linenum = 1; }