} else {
/* Enter file name */
ShowMessage(CP[63]);
- RequestInputString(fname);
+ RequestInputString(fname, sizeof(fname)-1);
}
/* shogi.000 */
} else {
/* Enter file name */
ShowMessage(CP[63]);
- RequestInputString(fname);
+ RequestInputString(fname, sizeof(fname)-1);
}
if (fname[0] == '\0') /* shogi.000 */
/* Enter file name */
ShowMessage(CP[63]);
- RequestInputString(fname);
+ RequestInputString(fname, sizeof(fname)-1);
if (fname[0] == '\0') /* XSHOGI.position.read */
strcpy(fname, CP[205]);
/* Enter file name */
ShowMessage(CP[63]);
- RequestInputString(fname);
+ RequestInputString(fname, sizeof(fname)-1);
if (fname[0] == '\0') /* XSHOGI.position.read */
strcpy(fname, CP[205]);
} else {
/* Enter file name */
ShowMessage(CP[63]);
- RequestInputString(fname);
+ RequestInputString(fname, sizeof(fname)-1);
}
if (fname[0] == '\0')
#include <ctype.h>
#include <signal.h>
+#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
void
-Curses_RequestInputString(char* buffer)
+Curses_doRequestInputString(const char* fmt, char* buffer)
{
- FLUSH_SCANW("%s", buffer);
+ FLUSH_SCANW(fmt, buffer);
}
void Curses_ShowLine(unsigned short *bstline);
void Curses_ShowMessage(char *s);
void Curses_Printf(const char *format, ...);
-void Curses_RequestInputString(char* buffer);
+void Curses_doRequestInputString(const char* fmt, char* buffer);
void Curses_ShowPatternCount(short side, short n);
void Curses_ShowPostnValue(short sq);
void Curses_ShowPostnValues(void);
#include "cursesdsp.h"
#include <stdarg.h>
+#include <stdio.h>
#define CASE_DSP_RAW(func,args) \
case DISPLAY_RAW: \
DISPLAY_FUNC(ShowLine, (unsigned short *bstline), (bstline))
DISPLAY_FUNC(ShowMessage, (char *s), (s))
DISPLAY_STDARGFUNC(Printf, (const char *format, ...), format, (format, ap))
-DISPLAY_FUNC(RequestInputString, (char* buffer), (buffer))
DISPLAY_FUNC(ShowPatternCount, (short side, short n), (side, n))
DISPLAY_FUNC(ShowPostnValue, (short sq), (sq))
DISPLAY_VOIDFUNC(ShowPostnValues)
DISPLAY_FUNC(TerminateSearch, (int sig), (sig))
DISPLAY_FUNC(UpdateDisplay, (short f, short t, short redraw, short isspec), (f, t, redraw, isspec))
DISPLAY_VOIDFUNC(help)
+
+DISPLAY_FUNC(doRequestInputString, (const char* fmt, char* buffer), (fmt, buffer))
+void RequestInputString(char* buffer, unsigned bufsize)
+{
+ static char fmt[10];
+ int ret = snprintf(fmt, sizeof(fmt), "%%%us", bufsize);
+ if (ret >= sizeof(fmt)) {
+ fprintf(stderr,
+ "Insufficient format-buffer size in %s for bufsize=%u\n",
+ __FUNCTION__, bufsize);
+ exit(1);
+ }
+ doRequestInputString(fmt, buffer);
+}
extern void ShowLine(unsigned short *bstline);
extern void ShowMessage(char *s);
extern void Printf(const char *format, ...);
-extern void RequestInputString(char* buffer);
+extern void RequestInputString(char* buffer, unsigned bufsize);
extern void ShowPatternCount(short side, short n);
extern void ShowPostnValue(short sq);
extern void ShowPostnValues(void);
}
void
-Raw_RequestInputString(char* buffer)
+Raw_doRequestInputString(const char* fmt, char* buffer)
{
- scanf("%s", buffer);
+ scanf(fmt, buffer);
}
void Raw_ShowLine(unsigned short *bstline);
void Raw_ShowMessage(char *s);
void Raw_Printf(const char *format, ...);
-void Raw_RequestInputString(char* buffer);
+void Raw_doRequestInputString(const char* fmt, char* buffer);
void Raw_ShowPatternCount(short side, short n);
void Raw_ShowPostnValue(short sq);
void Raw_ShowPostnValues(void);