]> git.sesse.net Git - stockfish/commitdiff
Standardize set_option function
authorJoona Kiiski <joona.kiiski@gmail.com>
Wed, 27 Jan 2010 08:37:12 +0000 (10:37 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 27 Jan 2010 19:03:44 +0000 (20:03 +0100)
Previously input like "setoption name Use Search Log value true "
(note space at the end of the line) didn't work.

Now parse value same way as option name. This way we implicitly
left- and right-trim value.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/uci.cpp

index 6fa55912f7f6761a35f1e35d2f5b9d34560e192c..e35ea97766d50f7ac84964312022f57870b2a47f 100644 (file)
@@ -224,7 +224,7 @@ namespace {
 
   void set_option(UCIInputParser& uip) {
 
-    string token, name;
+    string token, name, value;
 
     if (!(uip >> token)) // operator>>() skips any whitespace
         return;
@@ -234,13 +234,12 @@ namespace {
         while (uip >> token && token != "value")
             name += (" " + token);
 
-        if (token == "value")
+        if (token == "value" && uip >> value)
         {
-            // Reads until end of line and left trim white space
-            getline(uip, token);
-            token.erase(0, token.find_first_not_of(" \n\r\t"));
+            while (uip >> token)
+                value += (" " + token);
 
-            set_option_value(name, token);
+            set_option_value(name, value);
         } else
             push_button(name);
     }