diff options
author | Mariusz PluciĆski <mplucinski@mplucinski.com> | 2014-07-25 15:22:01 +0200 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2014-07-25 09:48:16 -0400 |
commit | 2d257614dd66f410375f24ce1f2306b3c260bd29 (patch) | |
tree | be8c3060532fc014ae6bf44d79fc3e24f0a52af6 /src/misc.c | |
parent | 681db87f8ffb3d6177f0bfa54d877a88ea0a9ed8 (diff) |
Allow error reporting routines to accept varying number of arguments in modern style
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -385,25 +385,27 @@ int htoi (str) /* lerrif - report an error message formatted with one integer argument */ -void lerrif (msg, arg) - const char *msg; - int arg; -{ +void lerrif (const char *msg, ...) { char errmsg[MAXLINE]; + va_list args; - snprintf (errmsg, sizeof(errmsg), msg, arg); + va_start(args, msg); + vsnprintf (errmsg, sizeof(errmsg), msg, args); + va_end(args); flexerror (errmsg); } /* lerrsf - report an error message formatted with one string argument */ -void lerrsf (msg, arg) - const char *msg, arg[]; +void lerrsf (const char *msg, ...) { char errmsg[MAXLINE]; + va_list args; - snprintf (errmsg, sizeof(errmsg)-1, msg, arg); + va_start(args, msg); + vsnprintf (errmsg, sizeof(errmsg)-1, msg, args); + va_end(args); errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */ flexerror (errmsg); } @@ -411,12 +413,14 @@ void lerrsf (msg, arg) /* lerrsf_fatal - as lerrsf, but call flexfatal */ -void lerrsf_fatal (msg, arg) - const char *msg, arg[]; +void lerrsf_fatal (const char *msg, ...) { char errmsg[MAXLINE]; + va_list args; + va_start(args, msg); - snprintf (errmsg, sizeof(errmsg)-1, msg, arg); + vsnprintf (errmsg, sizeof(errmsg)-1, msg, args); + va_end(args); errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */ flexfatal (errmsg); } |