Use varargs for errors in Slinky

This commit is contained in:
Michael Martin 2016-01-23 22:37:08 -08:00
parent 4c56782718
commit 4ab0baafe6

View File

@ -30,15 +30,10 @@
#include "slinkyTypes.h" #include "slinkyTypes.h"
#include "slinkyGlobals.h" #include "slinkyGlobals.h"
void #include <stdarg.h>
error(theError, arg1, arg2, arg3, arg4, arg5, arg6)
errorType theError; static void
anyOldThing *arg1; verror(errorType theError, va_list ap)
anyOldThing *arg2;
anyOldThing *arg3;
anyOldThing *arg4;
anyOldThing *arg5;
anyOldThing *arg6;
{ {
/* This table MUST be maintained congruently with the definition of the /* This table MUST be maintained congruently with the definition of the
enumerated type 'errorType'. */ enumerated type 'errorType'. */
@ -79,8 +74,16 @@ error(theError, arg1, arg2, arg3, arg4, arg5, arg6)
}; };
printf("\"%s\": ", currentFileName); printf("\"%s\": ", currentFileName);
printf(errorMessageStrings[(int)theError], arg1, arg2, arg3, arg4, vprintf(errorMessageStrings[(int)theError], ap);
arg5, arg6);
printf("\n"); printf("\n");
errorFlag = TRUE; errorFlag = TRUE;
} }
void
error(errorType theError, ...)
{
va_list ap;
va_start(ap, theError);
verror(theError, ap);
va_end(ap);
}