]> git.sesse.net Git - stockfish/commitdiff
Improve handling of the debug log file.
authorTomasz Sobczyk <tomasz.sobczyk1997@gmail.com>
Fri, 13 Aug 2021 20:20:11 +0000 (22:20 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Fri, 20 Aug 2021 05:57:09 +0000 (07:57 +0200)
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
src/misc.cpp
src/ucioption.cpp

diff --git a/AUTHORS b/AUTHORS
index d7f90de0e35586152d9e72671dbde6191878fe29..5b5bbf22b67c7bb01ccc87e34b51791286bca96a 100644 (file)
--- 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)
index 3b071ccb108ca25a841eb81d95ff9f5b1a9558f6..f9c123374f25162dc23e1af70dc7a1fe4076a5af 100644 (file)
@@ -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();
-    }
   }
 };
 
index 07b3027da707e11f239724f31576306efd40f289..0cafd3e92d03010eb32f3f77db69758617cb40c2 100644 (file)
@@ -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;