mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Fix get_option_value() for strings with spaces
Problem is that istream& operator>> (istream& is, char* str ); according to C++ documentation "Ends extraction when the next character is either a valid whitespace or a null character, or if the End-Of-File is reached." So if the parameter value is a string with spaces the currently used instruction 'ss >> ret;' copies the chars only up to the first white space and not the whole string. Use a specialization of get_option_value() to fix this corner case. Bug reported by xiaozhi Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
c7a77dd3c0
commit
455993b289
1 changed files with 12 additions and 0 deletions
|
@ -169,6 +169,18 @@ namespace {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specialization for std::string where instruction 'ss >> ret;'
|
||||||
|
// would erroneusly tokenize a string with spaces.
|
||||||
|
|
||||||
|
template<>
|
||||||
|
string get_option_value<string>(const string& optionName) {
|
||||||
|
|
||||||
|
if (options.find(optionName) == options.end())
|
||||||
|
return string();
|
||||||
|
|
||||||
|
return options[optionName].currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
////
|
||||||
|
|
Loading…
Add table
Reference in a new issue