X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=uci.c;h=03c664781f833917085255397fe9cbadb0196012;hb=5eed4adb3552562329c0b0b460c8851efb1a38bb;hp=f8537e295bd0b492c6617586d5cd0d612f112609;hpb=a0f731f21d6aa26dbf7246039a1c66c2ade0533f;p=polyglot.git diff --git a/uci.c b/uci.c index f8537e2..03c6647 100644 --- a/uci.c +++ b/uci.c @@ -22,7 +22,7 @@ static const bool UseDebug = FALSE; -static const int StringSize = 4096; +#define StringSize ((int)4096) // variables @@ -61,8 +61,8 @@ static int mate_score (int dist); // uci_set_threads() void uci_set_threads(uci_t * uci, int n) { - ASSERT(n>=1); const char *thread_option=uci_thread_option(uci); + ASSERT(n>=1); if(thread_option){ uci_send_option(uci,thread_option,"%d",n); } @@ -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; } }