From: Yann Dirson Date: Mon, 21 Oct 2013 22:51:02 +0000 (+0200) Subject: Fix regression with stdarg dspwrappers. X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=cbf4ad5e9942032a96215a4c7f095a4777bf0021;p=gnushogi.git Fix regression with stdarg dspwrappers. 1be442641b610fa1b6172a38d9acffe2d22797b6 and 3f589711eb3ecc7644378d6a0f2f29bc4b4c7db9 are both broken, passing the va_list inside another va_list to poor unsuspecting backend implementations. --- diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 412bdc0..fb4437d 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -165,26 +165,20 @@ Curses_ShowMessage(char *s) void -Curses_AlwaysShowMessage(const char *format, ...) +Curses_AlwaysShowMessage(const char *format, va_list ap) { static char buffer[60]; - va_list ap; - va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); Curses_ShowMessage(buffer); - va_end(ap); } void -Curses_Printf(const char *format, ...) +Curses_Printf(const char *format, va_list ap) { static char buffer[60]; - va_list ap; - va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); printw("%s", buffer); - va_end(ap); } diff --git a/gnushogi/cursesdsp.h b/gnushogi/cursesdsp.h index 8bea2bf..421c134 100644 --- a/gnushogi/cursesdsp.h +++ b/gnushogi/cursesdsp.h @@ -62,8 +62,8 @@ void Curses_ShowDepth(char ch); void Curses_ShowGameType(void); void Curses_ShowLine(unsigned short *bstline); void Curses_ShowMessage(char *s); -void Curses_AlwaysShowMessage(const char *format, ...); -void Curses_Printf(const char *format, ...); +void Curses_AlwaysShowMessage(const char *format, va_list ap); +void Curses_Printf(const char *format, va_list ap); void Curses_doRequestInputString(const char* fmt, char* buffer); int Curses_GetString(char* sx); void Curses_SetupBoard(void); diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c index d647f5a..b29afbe 100644 --- a/gnushogi/dspwrappers.c +++ b/gnushogi/dspwrappers.c @@ -37,7 +37,6 @@ #include "rawdsp.h" #include "cursesdsp.h" -#include #include #define CASE_DSP_RAW(func,args) \ diff --git a/gnushogi/dspwrappers.h b/gnushogi/dspwrappers.h index 449693f..9c5e3fe 100644 --- a/gnushogi/dspwrappers.h +++ b/gnushogi/dspwrappers.h @@ -35,6 +35,8 @@ #ifndef _DSPWRAPPERS_H_ #define _DSPWRAPPERS_H_ +#include + extern void ChangeAlphaWindow(void); extern void ChangeBetaWindow(void); extern void ChangeHashDepth(void); diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 6c8e654..0edfafd 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -123,23 +123,17 @@ Raw_ShowMessage(char *s) void -Raw_AlwaysShowMessage(const char *format, ...) +Raw_AlwaysShowMessage(const char *format, va_list ap) { - va_list ap; - va_start(ap, format); vprintf(format, ap); - va_end(ap); printf("\n"); } void -Raw_Printf(const char *format, ...) +Raw_Printf(const char *format, va_list ap) { - va_list ap; - va_start(ap, format); vprintf(format, ap); - va_end(ap); } diff --git a/gnushogi/rawdsp.h b/gnushogi/rawdsp.h index 44ec2d8..7c01fd8 100644 --- a/gnushogi/rawdsp.h +++ b/gnushogi/rawdsp.h @@ -62,8 +62,8 @@ void Raw_ShowDepth(char ch); void Raw_ShowGameType(void); void Raw_ShowLine(unsigned short *bstline); void Raw_ShowMessage(char *s); -void Raw_AlwaysShowMessage(const char *format, ...); -void Raw_Printf(const char *format, ...); +void Raw_AlwaysShowMessage(const char *format, va_list ap); +void Raw_Printf(const char *format, va_list ap); void Raw_doRequestInputString(const char* fmt, char* buffer); int Raw_GetString(char* sx); void Raw_SetupBoard(void);