diff --git a/display.c b/display.c index baee7ba..fcd291f 100644 --- a/display.c +++ b/display.c @@ -1339,10 +1339,8 @@ static void mlputc( char c) { * char *fmt; format string for output * char *arg; pointer to first argument to print */ -void mlwrite(const char *fmt, ...) -{ +void vmlwrite( const char *fmt, va_list ap) { int c; /* current char in format string */ - va_list ap; /* if we are not currently echoing on the command line, abort this */ if (discmd == FALSE) { @@ -1362,7 +1360,6 @@ void mlwrite(const char *fmt, ...) movecursor( term.t_nrow, 0) ; mpresf = *fmt ? TRUE : FALSE ; /* flag if line has content or not */ - va_start(ap, fmt); while ((c = *fmt++) != 0) { if (c != '%') mlputc( c) ; @@ -1402,7 +1399,6 @@ void mlwrite(const char *fmt, ...) } } } - va_end(ap); /* if we can, erase to the end of screen */ if( eolexist == TRUE && ttcol < term.t_ncol) @@ -1411,6 +1407,14 @@ void mlwrite(const char *fmt, ...) TTflush(); } +void mlwrite( const char *fmt, ...) { + va_list ap ; + + va_start( ap, fmt) ; + vmlwrite( fmt, ap) ; + va_end( ap) ; +} + /* * Write out a string. Update the physical cursor position. This assumes that * the characters in the string all have width "1"; if this is not the case diff --git a/display.h b/display.h index 82d4adb..3cb26b2 100644 --- a/display.h +++ b/display.h @@ -1,6 +1,8 @@ #ifndef _DISPLAY_H_ #define _DISPLAY_H_ +#include + #include "estruct.h" extern int mpresf ; /* Stuff in message line */ @@ -22,6 +24,7 @@ int updupd( int force) ; void upmode( void) ; void movecursor( int row, int col) ; void mlerase( void) ; +void vmlwrite( const char *fmt, va_list ap) ; void mlwrite( const char *fmt, ...) ; void getscreensize( int *widthp, int *heightp) ; diff --git a/eval.c b/eval.c index b150c8a..c75789b 100644 --- a/eval.c +++ b/eval.c @@ -259,6 +259,7 @@ struct variable_description { static void findvar( char *var, struct variable_description *vd, int size) ; static int svar( struct variable_description *var, char *value) ; +static char *i_to_a( int i) ; /* * putctext: @@ -817,15 +818,18 @@ int setvar(int f, int n) static void mlforce( char *s) ; #if DEBUGM -int mdbugout( char *fmt, char *s1, char *s2, char *s3) { +int mdbugout( char *fmt, ...) { int c ; /* input from kbd, output to terminal */ int savediscmd ; + va_list ap ; /* assignment status ; variable name ; value we tried to assign */ /* write out the debug line */ savediscmd = discmd ; discmd = TRUE ; - mlwrite( fmt, s1, s2, s3) ; + va_start( ap, fmt) ; + vmlwrite( fmt, ap) ; + va_end( ap) ; discmd = savediscmd ; update( TRUE) ; @@ -1076,7 +1080,7 @@ static int svar(struct variable_description *var, char *value) * * int i; integer to translate to a string */ -char *i_to_a( int i) { +static char *i_to_a( int i) { unsigned u ; int sign ; /* sign of resulting number */ /* returns result string: sign digits null */ diff --git a/eval.h b/eval.h index 3d6ef4a..e5943d5 100644 --- a/eval.h +++ b/eval.h @@ -5,7 +5,7 @@ #define DEBUGM 1 /* $debug triggers macro debugging */ #if DEBUGM -int mdbugout( char *fmt, char *s1, char *s2, char *s3) ; +int mdbugout( char *fmt, ...) ; #endif @@ -19,7 +19,6 @@ int is_it_cmd( char *token) ; void varinit( void) ; int setvar( int f, int n) ; -char *i_to_a( int i) ; char *getval( char *token) ; int stol( char *val) ; char *mklower( char *str) ; diff --git a/exec.c b/exec.c index b649883..849e1ca 100644 --- a/exec.c +++ b/exec.c @@ -647,8 +647,7 @@ static int dobuf(struct buffer *bp) int c ; /* debug macro name, if levels and lastly the line */ - c = mdbugout( "<<<%s:%s:%s>>>", bp->b_bname, i_to_a( execlevel), - eline) ; + c = mdbugout( "<<<%s:%d:%s>>>", bp->b_bname, execlevel, eline) ; if( c == abortc) { freewhile( whlist) ; return FALSE ;