aboutsummaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
authorwelinder@darter.rentec.com <welinder@darter.rentec.com>2004-09-13 11:48:37 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:11 -0700
commitf336cf3c5e0b4eeeeb02cdd92828ecca75eea1d7 (patch)
tree51883d13d28f563a5f17a0df9d06032b0b0e1a29 /lib.c
parentsymbol.h, symbol.c: (diff)
downloadsparse-f336cf3c5e0b4eeeeb02cdd92828ecca75eea1d7.tar.gz
sparse-f336cf3c5e0b4eeeeb02cdd92828ecca75eea1d7.tar.bz2
sparse-f336cf3c5e0b4eeeeb02cdd92828ecca75eea1d7.zip
Many files:
warn->warning error->error_die new error lib.h: warn->warning error->error_die new error Add gcc format checking to warning/error/...
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 2b72040..a2c3c2c 100644
--- a/lib.c
+++ b/lib.c
@@ -40,8 +40,8 @@ struct token *expect(struct token *token, int op, const char *where)
static struct token bad_token;
if (token != &bad_token) {
bad_token.next = token;
- warn(token->pos, "Expected %s %s", show_special(op), where);
- warn(token->pos, "got %s", show_token(token));
+ warning(token->pos, "Expected %s %s", show_special(op), where);
+ warning(token->pos, "got %s", show_token(token));
}
if (op == ';')
return skip_to(token, op);
@@ -496,7 +496,7 @@ void info(struct position pos, const char * fmt, ...)
va_end(args);
}
-void warn(struct position pos, const char * fmt, ...)
+void warning(struct position pos, const char * fmt, ...)
{
static int warnings = 0;
va_list args;
@@ -517,6 +517,25 @@ void warn(struct position pos, const char * fmt, ...)
void error(struct position pos, const char * fmt, ...)
{
+ static int errors = 0;
+ va_list args;
+
+ if (errors > 100) {
+ static int once = 0;
+ if (once)
+ return;
+ fmt = "too many errors";
+ once = 1;
+ }
+
+ va_start(args, fmt);
+ do_warn("error: ", pos, fmt, args);
+ va_end(args);
+ errors++;
+}
+
+void error_die(struct position pos, const char * fmt, ...)
+{
va_list args;
va_start(args, fmt);
do_warn("error: ", pos, fmt, args);