From 4ab0baafe671a50c5b10bcbfa36434b7d6e300fc Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 23 Jan 2016 22:37:08 -0800 Subject: [PATCH] Use varargs for errors in Slinky --- slinky/errorStuff.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/slinky/errorStuff.c b/slinky/errorStuff.c index e4a026d..4166f81 100644 --- a/slinky/errorStuff.c +++ b/slinky/errorStuff.c @@ -30,15 +30,10 @@ #include "slinkyTypes.h" #include "slinkyGlobals.h" - void -error(theError, arg1, arg2, arg3, arg4, arg5, arg6) - errorType theError; - anyOldThing *arg1; - anyOldThing *arg2; - anyOldThing *arg3; - anyOldThing *arg4; - anyOldThing *arg5; - anyOldThing *arg6; +#include + + static void +verror(errorType theError, va_list ap) { /* This table MUST be maintained congruently with the definition of the enumerated type 'errorType'. */ @@ -79,8 +74,16 @@ error(theError, arg1, arg2, arg3, arg4, arg5, arg6) }; printf("\"%s\": ", currentFileName); - printf(errorMessageStrings[(int)theError], arg1, arg2, arg3, arg4, - arg5, arg6); + vprintf(errorMessageStrings[(int)theError], ap); printf("\n"); errorFlag = TRUE; } + + void +error(errorType theError, ...) +{ + va_list ap; + va_start(ap, theError); + verror(theError, ap); + va_end(ap); +}