diff --git a/lang/m2/m2mm/error.c b/lang/m2/m2mm/error.c index f8ddde66e..5a55df79e 100644 --- a/lang/m2/m2mm/error.c +++ b/lang/m2/m2mm/error.c @@ -15,7 +15,11 @@ number of arguments! */ +#if __STDC__ +#include +#else #include +#endif #include #include "input.h" #include "f_info.h" @@ -42,14 +46,76 @@ extern char *symbol2str(); node, whereas other errors use the information in the token. */ +#if __STDC__ +/*VARARGS1*/ +error(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _error(ERROR, fmt, ap); + va_end(ap); +} + +/*VARARGS1*/ +Gerror(char *fmt, ...) +{ + va_list ap; + char *fn = FileName; + + FileName = 0; + va_start(ap, fmt); + _error(ERROR, fmt, ap); + va_end(ap); + FileName = fn; +} + +/*VARARGS1*/ +lexerror(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _error(LEXERROR, fmt, ap); + va_end(ap); +} + +/*VARARGS1*/ +fatal(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _error(FATAL, fmt, ap); + va_end(ap); + sys_stop(S_EXIT); +} + +/*VARARGS1*/ +crash(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _error(CRASH, fmt, ap); + va_end(ap); +#ifdef DEBUG + sys_stop(S_ABORT); +#else + sys_stop(S_EXIT); +#endif +} +#else /*VARARGS1*/ error(va_alist) va_dcl { va_list ap; + char *fmt; va_start(ap); - _error(ERROR, ap); + fmt = va_arg(ap, char *); + _error(ERROR, fmt, ap); va_end(ap); } @@ -58,11 +124,13 @@ Gerror(va_alist) va_dcl { va_list ap; + char *fmt; char *fn = FileName; FileName = 0; va_start(ap); - _error(ERROR, ap); + fmt = va_arg(ap, char *); + _error(ERROR, fmt, ap); va_end(ap); FileName = fn; } @@ -72,9 +140,11 @@ lexerror(va_alist) va_dcl { va_list ap; + char *fmt; va_start(ap); - _error(LEXERROR, ap); + fmt = va_arg(ap, char *); + _error(LEXERROR, fmt, ap); va_end(ap); } @@ -83,9 +153,11 @@ fatal(va_alist) va_dcl { va_list ap; + char *fmt; va_start(ap); - _error(FATAL, ap); + fmt = va_arg(ap, char *); + _error(FATAL, fmt, ap); va_end(ap); sys_stop(S_EXIT); } @@ -95,9 +167,11 @@ crash(va_alist) va_dcl { va_list ap; + char *fmt; va_start(ap); - _error(CRASH, ap); + fmt = va_arg(ap, char *); + _error(CRASH, fmt, ap); va_end(ap); #ifdef DEBUG sys_stop(S_ABORT); @@ -105,9 +179,11 @@ crash(va_alist) sys_stop(S_EXIT); #endif } +#endif -_error(class, argv) +_error(class, fmt, argv) int class; + char *fmt; va_list argv; { /* _error attempts to limit the number of error messages @@ -115,7 +191,6 @@ _error(class, argv) */ unsigned int ln = 0; register char *remark = 0; - char *fmt = va_arg(argv, char *); /* Since name and number are gathered from different places depending on the class, we first collect the relevant