From 7b9775370a639e7a26b5313d3d3b877864635562 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sat, 9 Nov 2013 23:41:44 +0100 Subject: [PATCH] Allow "depth " syntax. --- gnushogi/commondsp.c | 2 +- gnushogi/cursesdsp.c | 2 +- gnushogi/gnushogi.h | 2 +- gnushogi/rawdsp.c | 12 +++++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 45c2e2e..ac058ff 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -1860,7 +1860,7 @@ InputCommand(char *command) } else if (strcmp(s, "depth") == 0) { - dsp->ChangeSearchDepth(); + dsp->ChangeSearchDepth(sx + strlen("depth")); } else if (strcmp(s, "hashdepth") == 0) { diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 0914449..6300368 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -965,7 +965,7 @@ Curses_GiveHint(void) void -Curses_ChangeSearchDepth(void) +Curses_ChangeSearchDepth(char* sx) { Curses_ShowMessage("depth = "); FLUSH_SCANW("%hd", &MaxSearchDepth); diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h index fb9d849..50cab61 100644 --- a/gnushogi/gnushogi.h +++ b/gnushogi/gnushogi.h @@ -1128,7 +1128,7 @@ struct display void (*ChangeAlphaWindow)(void); void (*ChangeBetaWindow)(void); void (*ChangeHashDepth)(void); - void (*ChangeSearchDepth)(void); + void (*ChangeSearchDepth)(char *sx); void (*ChangeXwindow)(void); void (*ClearScreen)(void); void (*DoDebug)(void); diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index b73bd0a..e0a9857 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -794,10 +794,16 @@ Raw_SelectLevel(char *sx) void -Raw_ChangeSearchDepth(void) +Raw_ChangeSearchDepth(char *sx) { - printf("depth = "); - scanf("%hd", &MaxSearchDepth); + char buf[80+1]; + strncpy(buf, sx, 80); buf[80] = '\0'; + /* if line empty, ask for input */ + if (!buf[0]) { + printf("depth = "); + fgets(buf, 80+1, stdin); + } + sscanf(buf, "%hd", &MaxSearchDepth); TCflag = !(MaxSearchDepth > 0); } -- 1.7.0.4