scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 6b19dacc73f265c688c7ea1f6b371f6dd5525924
parent 98d60a06534921e0b79dd3b0a13910f2a8ec83a9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 24 Sep 2013 17:53:51 +0200

Change warning_error to warn

warning is never called because we always use warning_error, so
it is a nonsense this long name, which causes a lot of indentation.
We remove warning and rename warning_error to warn.

Diffstat:
cc.h | 3+--
decl.c | 20++++++++++----------
error.c | 17++++-------------
3 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/cc.h b/cc.h @@ -18,10 +18,9 @@ struct user_opt { extern struct user_opt options; -extern void warning(const char *fmt, ...); extern void error(const char *fmt, ...); extern void die(const char *fmt, ...); -extern void warning_error(char flag, const char *fmt, ...); +extern void warn(char flag, const char *fmt, ...); extern void *xmalloc(size_t size); extern void *xcalloc(size_t nmemb, size_t size); extern char *xstrdup(const char *s); diff --git a/decl.c b/decl.c @@ -106,8 +106,8 @@ struct_dcl(unsigned char ns) if (!(base = spec())) { base = newctype(); base->type = INT; - warning_error(options.implicit, - "data definition has no type or storage class"); + warn(options.implicit, + "data definition has no type or storage class"); } if (base->c_typedef || base->c_static || base->c_auto || base->c_register || base->c_extern) { @@ -217,8 +217,8 @@ spec(void) if (!tp) return NULL; if (!tp->type) { - warning_error(options.implicit, - "type defaults to 'int' in declaration"); + warn(options.implicit, + "type defaults to 'int' in declaration"); tp->type = INT; } if (!tp->c_signed && !tp->c_unsigned) { @@ -326,20 +326,20 @@ repeat: if (!(tp = spec())) { return NULL; tp = newctype(); tp->type = INT; - warning_error(options.implicit, - "data definition has no type or storage class"); + warn(options.implicit, + "data definition has no type or storage class"); } else if (accept(';')) { register unsigned char type = tp->type; if (type == STRUCT || type == UNION || type == ENUM) { if (tp->c_extern || tp->c_static || tp->c_auto || tp->c_register || tp->c_const || tp->c_volatile) { - warning_error(options.useless, - "useless storage class specifier in empty declaration"); + warn(options.useless, + "useless storage class specifier in empty declaration"); } } else { - warning_error(options.useless, - "useless type name in empty declaration"); + warn(options.useless, + "useless type name in empty declaration"); } delctype(tp); goto repeat; diff --git a/error.c b/error.c @@ -9,7 +9,7 @@ static void -warning_error_helper(char flag, const char *fmt, va_list va) +warn_helper(char flag, const char *fmt, va_list va) { fprintf(stderr, "%s:%s:%u:%u: ", (!flag) ? "warning" : "error", filename, linenum, columnum); @@ -20,11 +20,11 @@ warning_error_helper(char flag, const char *fmt, va_list va) } void -warning_error(char flag, const char *fmt, ...) +warn(char flag, const char *fmt, ...) { va_list va; va_start(va, fmt); - warning_error_helper(flag, fmt, va); + warn_helper(flag, fmt, va); va_end(va); } @@ -33,16 +33,7 @@ error(const char *fmt, ...) { va_list va; va_start(va, fmt); - warning_error_helper(1, fmt, va); - va_end(va); -} - -void -warning(const char *fmt, ...) -{ - va_list va; - va_start(va, fmt); - warning_error_helper(0, fmt, va); + warn_helper(1, fmt, va); va_end(va); }