From ccf0239bc468c1fb599785e0dea178e84279674d Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Fri, 13 Aug 2021 22:20:11 +0200 Subject: [PATCH] Improve handling of the debug log file. Fix handling of empty strings in uci options and reassigning of the log file Fixes https://github.com/official-stockfish/Stockfish/issues/3650 Closes https://github.com/official-stockfish/Stockfish/pull/3655 No functional change --- AUTHORS | 2 +- src/misc.cpp | 15 ++++++++------- src/ucioption.cpp | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index d7f90de0..5b5bbf22 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ -# List of authors for Stockfish, as of June 14, 2021 +# List of authors for Stockfish # Founders of the Stockfish project and fishtest infrastructure Tord Romstad (romstad) diff --git a/src/misc.cpp b/src/misc.cpp index 3b071ccb..f9c12337 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -110,7 +110,14 @@ public: static Logger l; - if (!fname.empty() && !l.file.is_open()) + if (l.file.is_open()) + { + cout.rdbuf(l.out.buf); + cin.rdbuf(l.in.buf); + l.file.close(); + } + + if (!fname.empty()) { l.file.open(fname, ifstream::out); @@ -123,12 +130,6 @@ public: cin.rdbuf(&l.in); cout.rdbuf(&l.out); } - else if (fname.empty() && l.file.is_open()) - { - cout.rdbuf(l.out.buf); - cin.rdbuf(l.in.buf); - l.file.close(); - } } }; diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 07b3027d..0cafd3e9 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -164,7 +164,7 @@ Option& Option::operator=(const string& v) { assert(!type.empty()); - if ( (type != "button" && v.empty()) + if ( (type != "button" && type != "string" && v.empty()) || (type == "check" && v != "true" && v != "false") || (type == "spin" && (stof(v) < min || stof(v) > max))) return *this; -- 2.39.2