scc

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

commit 64add66232ba4cf148aab299b3fa999444fe6e8e
parent 3cb05279b1ab7d3b2a97d4aa427a44a1598ec839
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 23 Apr 2014 14:55:37 +0200

Remove columnum variable

columnum depend of the tab size, so it is not a good idea
assume a tab size of 8, or a tab size of 4 or whanever you want,
so the best option is remove it.

Diffstat:
Merror.c | 4++--
Mlex.c | 12++++--------
2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/error.c b/error.c @@ -15,8 +15,8 @@ warn_helper(signed char flag, const char *fmt, va_list va) { if (!flag) return; - fprintf(stderr, "%s:%s:%u:%u: ", - (!flag) ? "warning" : "error", filename, linenum, columnum); + fprintf(stderr, "%s:%s:%u: ", + (!flag) ? "warning" : "error", filename, linenum); vfprintf(stderr, fmt, va); putc('\n', stderr); if (flag < 0) diff --git a/lex.c b/lex.c @@ -11,7 +11,6 @@ static FILE *yyin; const char *filename; unsigned linenum; -unsigned columnum; uint8_t yytoken, yyntoken;; union yystype yylval; @@ -125,7 +124,7 @@ escape(char *s) case '0': /* TODO: */ case 'u': /* TODO: */ case '\n': - ++linenum, columnum = 1; + ++linenum; return s; default: warn(1, "unknown escape sequence"); @@ -371,11 +370,8 @@ next(void) } while (isspace(c = getc(yyin))) { - switch (c) { - case '\n': ++linenum, columnum = 1; break; - case '\t': columnum += 8; break; - default: ++columnum; break; - } + if (c == '\n') + ++linenum; } if (c == EOF) { @@ -417,6 +413,6 @@ open_file(register const char *file) die("file '%s' not found", file); filename = file; } - columnum = linenum = 1; + linenum = 1; next(); /* prefetch first token */ }