1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Small touches in set_option()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-07-17 12:26:50 +01:00
parent b8eb699db7
commit 07e0dd27fb

View file

@ -59,7 +59,7 @@ bool execute_uci_command(const string& cmd) {
UCIParser up(cmd); UCIParser up(cmd);
string token; string token;
up >> token; // operator>>() skips any whitespace up >> skipws >> token;
if (token == "quit") if (token == "quit")
return false; return false;
@ -123,7 +123,7 @@ namespace {
Move m; Move m;
string token, fen; string token, fen;
up >> token; // operator>>() skips any whitespace up >> token;
if (token == "startpos") if (token == "startpos")
{ {
@ -151,24 +151,20 @@ namespace {
void set_option(UCIParser& up) { void set_option(UCIParser& up) {
string token, name; string token, name, value;
string value = "true"; // UCI buttons don't have a "value" field
up >> token; // Consume "name" token up >> token; // Consume "name" token
up >> name; // Read option name
// Handle names with included spaces // Read option name (can contain spaces)
while (up >> token && token != "value") while (up >> token && token != "value")
name += " " + token; name += string(" ", !name.empty()) + token;
up >> value; // Read option value // Read option value (can contain spaces)
// Handle values with included spaces
while (up >> token) while (up >> token)
value += " " + token; value += string(" ", !value.empty()) + token;
if (Options.find(name) != Options.end()) if (Options.find(name) != Options.end())
Options[name].set_value(value); Options[name].set_value(value.empty() ? "true" : value); // UCI buttons don't have "value"
else else
cout << "No such option: " << name << endl; cout << "No such option: " << name << endl;
} }