From fb48401cc0dbcfd5ef35f3debc3cc61ab53c4506 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 27 Sep 2001 18:51:37 +0000 Subject: [PATCH] Add *Now and *At error and warning functions. *At functions still need to be implemented. Consider a rename of these functions at some point? svn path=/trunk/yasm/; revision=248 --- libyasm/errwarn.c | 39 +++++++++++++++++++++++++++++++++++++-- libyasm/errwarn.h | 14 ++++++++++++++ src/errwarn.c | 39 +++++++++++++++++++++++++++++++++++++-- src/errwarn.h | 14 ++++++++++++++ 4 files changed, 102 insertions(+), 4 deletions(-) diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index f2191f89..377da658 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -151,7 +151,7 @@ Fatal(fatal_num num) /* Register an error. Uses argtypes as described above to specify the * argument types. Does not print the error, only stores it for - * OutputError() to print. */ + * OutputAllErrorWarning() to print. */ void Error(char *fmt, ...) { @@ -198,7 +198,7 @@ Error(char *fmt, ...) /* Register a warning. Uses argtypes as described above to specify the * argument types. Does not print the warning, only stores it for - * OutputWarning() to print. */ + * OutputAllErrorWarning() to print. */ void Warning(char *fmt, ...) { @@ -233,6 +233,41 @@ Warning(char *fmt, ...) warning_count++; } +void +ErrorNow(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +void +WarningNow(char *fmt, ...) +{ + va_list ap; + + fprintf(stderr, "%s ", _("warning:")); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +void +ErrorAt(char *filename, unsigned long line, char *fmt, ...) +{ + /* TODO */ +} + +void +WarningAt(char *filename, unsigned long line, char *fmt, ...) +{ + /* TODO */ +} + /* Output all previously stored errors and warnings to stderr. */ unsigned int OutputAllErrorWarning(void) diff --git a/libyasm/errwarn.h b/libyasm/errwarn.h index 9a581272..cb701f95 100644 --- a/libyasm/errwarn.h +++ b/libyasm/errwarn.h @@ -40,6 +40,20 @@ void Fatal(fatal_num); void Error(char *, ...); void Warning(char *, ...); +/* Use Error() and Warning() instead of ErrorAt() and WarningAt() when being + * called in line order from a parser. The *At() functions are much slower, + * at least in the current implementation. + */ +void ErrorAt(char *filename, unsigned long line, char *, ...); +void WarningAt(char *filename, unsigned long line, char *, ...); + +/* These two functions immediately output the error or warning, with no file + * or line information. They should be used for errors and warnings outside + * the parser stage (at program startup, for instance). + */ +void ErrorNow(char *, ...); +void WarningNow(char *, ...); + /* Returns total number of errors to this point in assembly. */ unsigned int OutputAllErrorWarning(void); diff --git a/src/errwarn.c b/src/errwarn.c index f2191f89..377da658 100644 --- a/src/errwarn.c +++ b/src/errwarn.c @@ -151,7 +151,7 @@ Fatal(fatal_num num) /* Register an error. Uses argtypes as described above to specify the * argument types. Does not print the error, only stores it for - * OutputError() to print. */ + * OutputAllErrorWarning() to print. */ void Error(char *fmt, ...) { @@ -198,7 +198,7 @@ Error(char *fmt, ...) /* Register a warning. Uses argtypes as described above to specify the * argument types. Does not print the warning, only stores it for - * OutputWarning() to print. */ + * OutputAllErrorWarning() to print. */ void Warning(char *fmt, ...) { @@ -233,6 +233,41 @@ Warning(char *fmt, ...) warning_count++; } +void +ErrorNow(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +void +WarningNow(char *fmt, ...) +{ + va_list ap; + + fprintf(stderr, "%s ", _("warning:")); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +void +ErrorAt(char *filename, unsigned long line, char *fmt, ...) +{ + /* TODO */ +} + +void +WarningAt(char *filename, unsigned long line, char *fmt, ...) +{ + /* TODO */ +} + /* Output all previously stored errors and warnings to stderr. */ unsigned int OutputAllErrorWarning(void) diff --git a/src/errwarn.h b/src/errwarn.h index 9a581272..cb701f95 100644 --- a/src/errwarn.h +++ b/src/errwarn.h @@ -40,6 +40,20 @@ void Fatal(fatal_num); void Error(char *, ...); void Warning(char *, ...); +/* Use Error() and Warning() instead of ErrorAt() and WarningAt() when being + * called in line order from a parser. The *At() functions are much slower, + * at least in the current implementation. + */ +void ErrorAt(char *filename, unsigned long line, char *, ...); +void WarningAt(char *filename, unsigned long line, char *, ...); + +/* These two functions immediately output the error or warning, with no file + * or line information. They should be used for errors and warnings outside + * the parser stage (at program startup, for instance). + */ +void ErrorNow(char *, ...); +void WarningNow(char *, ...); + /* Returns total number of errors to this point in assembly. */ unsigned int OutputAllErrorWarning(void); -- 2.40.0