From ac63e467f24941187803d2bf6347a9b86a9490c6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Aug 2013 16:53:18 -0400 Subject: [PATCH] Thirs stage of varargs cleanups. --- extern.h | 26 +++++++++++++------------- term.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/extern.h b/extern.h index 92e1611..557ce17 100644 --- a/extern.h +++ b/extern.h @@ -211,23 +211,23 @@ void set_prod (city_info_t *cityp); /* terminal routines */ void pdebug (char *s, int a, int b, int c, int d, int e, int f, int g, int h); void topini (void); -void clreol (int linep, int colp); -void topmsg (int linep, char *buf, ...); -void topmsg1 (int linep, char *buf, ...); -void topmsg2 (int linep, char *buf, ...); -void prompt (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); -void prompt1 (char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); -void prompt2 (char *buf, char *a, int b, int c, int d, char *e, char *f, int g, int h); -void error (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void clreol (int line, int colp); +void topmsg (int line, char *fmt, ...); +void topmsg1 (int line, char *fmt, ...); +void topmsg2 (int line, char *fmt, ...); +void prompt (char *fmt, ...); +void prompt1 (char *fmt, ...); +void prompt2 (char *fmt, ...); +void error (char *fmt, ...); void info (char *a, char *b, char *c); -void comment (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); -void comment1 (char *buf,char *a, int b, int c, int d, int e, int f, int g, int h); -void extra (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void comment (char *fmt, int a, int b, int c, int d, int e, int f, int g, int h); +void comment1 (char *fmt,char *a, int b, int c, int d, int e, int f, int g, int h); +void extra (char *fmt, ...); void huh (void); void help (char **text, int nlines); void set_need_delay (void); -void ksend (char *buf, ...); -void ksend1 (char *buf, ...); +void ksend (char *fmt, ...); +void ksend1 (char *fmt, ...); /* utility routines */ void ttinit (void); diff --git a/term.c b/term.c index b4b3004..71c46f5 100644 --- a/term.c +++ b/term.c @@ -112,24 +112,33 @@ Print a prompt on the first message line. */ void -/* VARARGS1 */ -prompt(char *buf, - int a, int b, int c, int d, int e, int f, int g, int h) +prompt(char *fmt, ...) { - topmsg(1, buf, a, b, c, d, e, f, g, h); + va_list ap; + + va_start(ap, fmt); + vtopmsg(1, fmt, ap); + va_end(ap); } void -prompt1(char *buf, char *a, - int b, int c, int d, int e, int f, int g, int h) +prompt1(char *fmt, ...) { - topmsg1(1, buf, a, b, c, d, e, f, g, h); + va_list ap; + + va_start(ap, fmt); + vtopmsg(1, fmt, ap); + va_end(ap); } void -prompt2 (char *buf, - char *a, int b, int c, int d, char *e, char *f, int g, int h){ - topmsg2(1, buf, a, b, c, d, e, f, g, h); +prompt2 (char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vtopmsg(1, fmt, ap); + va_end(ap); } /* @@ -137,11 +146,13 @@ Print an error message on the second message line. */ void -/* VARARGS1 */ -error(char *buf, - int a, int b, int c, int d, int e, int f, int g, int h) +error(char *fmt, ...) { - topmsg(2, buf, a, b, c, d, e, f, g, h); + va_list ap; + + va_start(ap, fmt); + vtopmsg(2, fmt, ap); + va_end(ap); } /* @@ -149,13 +160,16 @@ Print out extra information. */ void -/* VARARGS1 */ -extra(char *buf, - int a, int b, int c, int d, int e, int f, int g, int h) +extra(char *fmt, ...) { - topmsg(3, buf, a, b, c, d, e, f, g, h); + va_list ap; + + va_start(ap, fmt); + vtopmsg(3, fmt, ap); + va_end(ap); } + /* Print out a generic error message. */ @@ -163,7 +177,7 @@ Print out a generic error message. void huh(void) { - error ("Type H for Help.",0,0,0,0,0,0,0,0); + error ("Type H for Help."); } /* @@ -216,7 +230,7 @@ vksend(const char *fmt, va_list varglist) { if(!(my_stream=fopen("info_list.txt","a"))) { - error("Cannot open info_list.txt",0,0,0,0,0,0,0,0); + error("Cannot open info_list.txt"); return; } vfprintf(my_stream, fmt, varglist); -- 2.43.0