From 1087eb7b2d8447adf9a7deb549d4004a87b46b10 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 9 Jun 2011 09:59:21 +0200 Subject: [PATCH] version 1.4.36b --- ChangeLog | 7 +++++++ README | 13 +++++++++---- board.c | 18 +++++++++--------- config.h | 6 +++--- configure | 20 ++++++++++---------- configure.ac | 2 +- main.c | 2 +- option.c | 1 + pipex_win32.c | 8 +++----- polyglot.man | 11 ++++++++--- polyglot.pod | 10 ++++++++-- polyglot.spec | 2 +- uci.c | 14 +++++++------- util.c | 4 ++-- util.h | 2 +- xboard2uci.c | 15 +++++++++++---- 16 files changed, 82 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea9082b..9bae4d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +=========1.4.36b================ +- Bugfix: option = 0/1 was translated incorrectly. +- Default node count is 1. +- EOF received from the engine should now be logged correctly (i.e. after the buffer is empty). +- Bugfix: Nasty buffer overflow in the macro CONSTRUCT_ARG_STRING. +- Bugfix: pipex_writeln (win32) was logging at the wrong spot. +- Log board when an illegal move is received. =========1.4.35b================ - New WbWorkAround for silly bug in WB. Depth <=1 clears the engine output window. Why should an engine not be allowed to send info at depth one? =========1.4.34b================ diff --git a/README b/README index df31a94..b523a6d 100644 --- a/README +++ b/README @@ -440,15 +440,20 @@ CONFIG FILE FORMAT case. WbWorkArounds (default: true) - The intention of this option is to provide work arounds for - xboard/winboard bugs should they arise. Currently it decapitalizes - the word Draw in options that contain this word. Some versions of + The intention of these options is to provide work arounds for + xboard/winboard bugs should they arise. This one decapitalizes the + word Draw in options that contain this word. Some versions of xboard/winboard contain a bug which causes such options to be interpreted as draw claims by the engine. Engines that send options with "Draw" in their name are Rybka and HIARCS. + WbWorkArounds2 (default: false) + Old version of Winboard clear the engine output window at depth 1. + With this work around PG will send info lines at depth >=2. This + may or may not improve the display. + [Engine] section This section contains engine UCI options. PolyGlot does not understand @@ -521,4 +526,4 @@ SEE ALSO - 2009-08-07 POLYGLOT(6) + 2009-08-11 POLYGLOT(6) diff --git a/board.c b/board.c index b17d354..8c51a88 100644 --- a/board.c +++ b/board.c @@ -459,31 +459,31 @@ void board_disp(const board_t * board) { int file, rank, sq; int piece, c; char fen[256]; + char row[9]; + char line[256]; ASSERT(board!=NULL); if (!board_to_fen(board,fen,256)) ASSERT(FALSE); - my_log("POLYGLOT %s\n",fen); - my_log("POLYGLOT\n"); + my_log("POLYGLOT FEN %s\n",fen); + my_log("POLYGLOT *** CURRENT BOARD ***\n"); for (rank = 7; rank >= 0; rank--) { - my_log("POLYGLOT "); - for (file = 0; file < 8; file++) { sq = square_make(file,rank); piece = board->square[sq]; c = (piece != Empty) ? piece_to_char(piece) : '-'; - my_log("%c ",c); + row[file]=c; } - - my_log("\n"); + row[8]='\0'; + snprintf(line,sizeof(line),"POLYGLOT %s\n",row); + line[sizeof(line)-1]='\0'; + my_log(line); } - my_log("POLYGLOT\n"); - my_log("POLYGLOT %s to play\n",(colour_is_black(board->turn))?"black":"white"); my_log("POLYGLOT\n"); } diff --git a/config.h b/config.h index 4d18e66..5076fe9 100644 --- a/config.h +++ b/config.h @@ -115,13 +115,13 @@ #define PACKAGE_NAME "polyglot" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "polyglot 1.4.35b" +#define PACKAGE_STRING "polyglot 1.4.36b" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "polyglot" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.4.35b" +#define PACKAGE_VERSION "1.4.36b" /* Define to 1 if the C compiler supports function prototypes. */ #define PROTOTYPES 1 @@ -150,7 +150,7 @@ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define VERSION "1.4.35b" +#define VERSION "1.4.36b" /* Define like PROTOTYPES; this can be used by system headers. */ #define __PROTOTYPES 1 diff --git a/configure b/configure index 62d838e..df485e1 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for polyglot 1.4.35b. +# Generated by GNU Autoconf 2.61 for polyglot 1.4.36b. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='polyglot' PACKAGE_TARNAME='polyglot' -PACKAGE_VERSION='1.4.35b' -PACKAGE_STRING='polyglot 1.4.35b' +PACKAGE_VERSION='1.4.36b' +PACKAGE_STRING='polyglot 1.4.36b' PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be' ac_unique_file="mainloop.c" @@ -1207,7 +1207,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures polyglot 1.4.35b to adapt to many kinds of systems. +\`configure' configures polyglot 1.4.36b to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1273,7 +1273,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of polyglot 1.4.35b:";; + short | recursive ) echo "Configuration of polyglot 1.4.36b:";; esac cat <<\_ACEOF @@ -1357,7 +1357,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -polyglot configure 1.4.35b +polyglot configure 1.4.36b generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1371,7 +1371,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by polyglot $as_me 1.4.35b, which was +It was created by polyglot $as_me 1.4.36b, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2061,7 +2061,7 @@ fi # Define the identity of the package. PACKAGE='polyglot' - VERSION='1.4.35b' + VERSION='1.4.36b' cat >>confdefs.h <<_ACEOF @@ -6848,7 +6848,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by polyglot $as_me 1.4.35b, which was +This file was extended by polyglot $as_me 1.4.36b, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6901,7 +6901,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -polyglot config.status 1.4.35b +polyglot config.status 1.4.36b configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 42efee9..fa15e53 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([polyglot], [1.4.35b], [michel.vandenbergh@uhasselt.be]) +AC_INIT([polyglot], [1.4.36b], [michel.vandenbergh@uhasselt.be]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([mainloop.c]) AC_CONFIG_HEADER([config.h]) diff --git a/main.c b/main.c index e34fb05..e49f51d 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,7 @@ // constants -static const char * const Version = "1.4.35b"; +static const char * const Version = "1.4.36b"; static const char * const HelpMessage = "\ SYNTAX\n\ * polyglot [configfile]\n\ diff --git a/option.c b/option.c index 8d067b8..cb2b5a8 100644 --- a/option.c +++ b/option.c @@ -71,6 +71,7 @@ option_t DefaultOptions[] = { { "PromoteWorkAround","check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, + { "WbWorkArounds2", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, { NULL, NULL,"0","0", NULL , NULL,0,NNB, 0}, }; diff --git a/pipex_win32.c b/pipex_win32.c index 3f9ed90..24199b7 100644 --- a/pipex_win32.c +++ b/pipex_win32.c @@ -219,10 +219,7 @@ static void pipex_set_eof_input(pipex_t *pipex){ EnterCriticalSection(&(pipex->CriticalSection)); (pipex->state)|=PIPEX_EOF; LeaveCriticalSection(&(pipex->CriticalSection)); - // not quit the right place - my_log("%s->Adapter: EOF\n",pipex->name); - -} + } // pipex_active() @@ -395,6 +392,7 @@ bool pipex_readln(pipex_t *pipex, char *szLineStr) { WaitForSingleObject(pipex->hEvent,INFINITE); } } + my_log("%s->Adapter: EOF\n",pipex->name); szLineStr[0]='\0'; return FALSE; } @@ -474,8 +472,8 @@ void pipex_write(pipex_t *pipex, const char *szLineStr) { void pipex_writeln(pipex_t *pipex, const char *szLineStr) { DWORD dwBytes; DWORD dwLengthWriteBuffer; - my_log("Adapter->%s: %s\n",pipex->name,pipex->szWriteBuffer); pipex_write(pipex, szLineStr); + my_log("Adapter->%s: %s\n",pipex->name,pipex->szWriteBuffer); if(pipex->bPipe){ dwLengthWriteBuffer = strlen(pipex->szWriteBuffer); if(dwLengthWriteBuffer>=sizeof(pipex->szWriteBuffer)-3){ diff --git a/polyglot.man b/polyglot.man index c6f8e49..58d1753 100644 --- a/polyglot.man +++ b/polyglot.man @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "POLYGLOT 6" -.TH POLYGLOT 6 "2009-08-07" "" "" +.TH POLYGLOT 6 "2009-08-11" "" "" .SH "NAME" PolyGlot \- Winboard protocol to UCI protocol adapter \- book engine for Polyglot books @@ -554,13 +554,18 @@ When RepeatPV is false PolyGlot does not repeat the last pv string. Due to the way kibitzing is implemented, KibitzMove is disabled in that case. .IP "\fBWbWorkArounds\fR (default: true)" 4 .IX Item "WbWorkArounds (default: true)" -The intention of this option is to provide work arounds for -xboard/winboard bugs should they arise. Currently it decapitalizes +The intention of these options is to provide work arounds for +xboard/winboard bugs should they arise. This one decapitalizes the word Draw in options that contain this word. Some versions of xboard/winboard contain a bug which causes such options to be interpreted as draw claims by the engine. .Sp Engines that send options with \*(L"Draw\*(R" in their name are Rybka and \s-1HIARCS\s0. +.IP "\fBWbWorkArounds2\fR (default: false)" 4 +.IX Item "WbWorkArounds2 (default: false)" +Old version of Winboard clear the engine output window at depth 1. With this +work around \s-1PG\s0 will send info lines at depth >=2. This may or may not improve +the display. .Sh "[Engine] section" .IX Subsection "[Engine] section" This section contains engine \s-1UCI\s0 options. PolyGlot does not diff --git a/polyglot.pod b/polyglot.pod index 285e9b1..45287d2 100644 --- a/polyglot.pod +++ b/polyglot.pod @@ -520,14 +520,20 @@ Due to the way kibitzing is implemented, KibitzMove is disabled in that case. =item B (default: true) -The intention of this option is to provide work arounds for -xboard/winboard bugs should they arise. Currently it decapitalizes +The intention of these options is to provide work arounds for +xboard/winboard bugs should they arise. This one decapitalizes the word Draw in options that contain this word. Some versions of xboard/winboard contain a bug which causes such options to be interpreted as draw claims by the engine. Engines that send options with "Draw" in their name are Rybka and HIARCS. +=item B (default: false) + +Old version of Winboard clear the engine output window at depth 1. With this +work around PG will send info lines at depth >=2. This may or may not improve +the display. + =back diff --git a/polyglot.spec b/polyglot.spec index 3a823ab..2c9413d 100644 --- a/polyglot.spec +++ b/polyglot.spec @@ -1,6 +1,6 @@ Summary: A Winboard protocol to UCI protocol adapter Name: polyglot -Version: 1.4.35b +Version: 1.4.36b Release: 1 License: GPL Group: Amusement/Games diff --git a/uci.c b/uci.c index f8537e2..e44fa34 100644 --- a/uci.c +++ b/uci.c @@ -162,8 +162,8 @@ void uci_clear(uci_t * uci) { uci->best_depth = 0; uci->best_sel_depth = 0; line_clear(uci->best_pv); - - uci->node_nb = 0; +// make the default 1 instead of 0 so that info lines can be recognized by their node number 0 + uci->node_nb = 1; uci->time = 0.0; uci->speed = 0.0; uci->cpu = 0.0; @@ -666,7 +666,8 @@ static int parse_info(uci_t * uci, const char string[]) { }else if(my_string_case_equal(argument,"Resign")){ event |= EVENT_RESIGN; }else{ - strcpy(uci->info,argument); + snprintf(uci->info,sizeof(uci->info),"%s",argument); + uci->info[sizeof(uci->info)-1]='\0'; event|=EVENT_INFO; } // TODO: argument to EOS @@ -692,11 +693,10 @@ static int parse_info(uci_t * uci, const char string[]) { } else { my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); - // this is for buggy engines; it should probably be protected + // This should probably be protected // by a "WorkAround" option. - strcpy(uci->info,option); - strcat(uci->info," "); - strcat(uci->info,argument); + snprintf(uci->info,sizeof(uci->info),"%s %s",option,argument); + uci->info[sizeof(uci->info)-1]='\0'; event|=EVENT_INFO; } } diff --git a/util.c b/util.c index 0d75adf..5e6e4f3 100644 --- a/util.c +++ b/util.c @@ -187,8 +187,8 @@ void my_fatal(const char format[], ...) { CONSTRUCT_ARG_STRING(format,string); - fprintf(stderr,format,string); - if (LogFile != NULL) fprintf(LogFile,format,&string); + fprintf(stderr,"%s",string); + if (LogFile != NULL) fprintf(LogFile,"%s",string); if (Error) { // recursive error my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); diff --git a/util.h b/util.h index 2b0886c..99fa6ac 100644 --- a/util.h +++ b/util.h @@ -77,7 +77,7 @@ format, \ arg_list); \ va_end(arg_list); \ - buf[sizeof(buf)]='\0'; \ + buf[sizeof(buf)-1]='\0'; \ if(written>=sizeof(buf) || written<0){ \ my_fatal("write_buffer overflow: file \"%s\", line %d\n", \ __FILE__,__LINE__); \ diff --git a/xboard2uci.c b/xboard2uci.c index 529f041..d026096 100644 --- a/xboard2uci.c +++ b/xboard2uci.c @@ -454,11 +454,17 @@ void xboard2uci_gui_step(char string[]) { char *pg_name=Star[0]; polyglot_set_option(pg_name,value); }else{ - start_protected_command(); - if(!uci_send_option(Uci, name, "%s", value)){ + option_t *opt=option_find(Uci->option,name); + if(opt){ + if(my_string_case_equal(opt->type,"check")){ + value=my_string_equal(value,"1")?"true":"false"; + } + start_protected_command(); + uci_send_option(Uci, name, "%s", value); + end_protected_command(); + }else{ gui_send(GUI,"Error (unknown option): %s",name); } - end_protected_command(); } } else if (match(string,"option *")){ char *name=Star[0]; @@ -740,6 +746,7 @@ void xboard2uci_engine_step(char string[]) { gui_send(GUI,"1-0 {polyglot: resign" " (illegal engine move black)}"); } + board_disp(board); XB->result = TRUE; mess(); } @@ -1463,7 +1470,7 @@ static void send_board(int extra_move) { static void send_info() { int min_depth; - if(option_get_bool(Option,"WbWorkArounds")){ + if(option_get_bool(Option,"WbWorkArounds2")){ // Silly bug in some versions of WinBoard. // depth <=1 clears the engine output window. // Why shouldn't an engine be allowed to send info at depth 1? -- 1.7.0.4