From 455993b289b3c8f1c9c73af5876eb0190cde537c Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 28 Nov 2009 17:31:56 +0100 Subject: [PATCH] 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 --- src/ucioption.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 1b866554..d1326a4c 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -169,6 +169,18 @@ namespace { return ret; } + // Specialization for std::string where instruction 'ss >> ret;' + // would erroneusly tokenize a string with spaces. + + template<> + string get_option_value(const string& optionName) { + + if (options.find(optionName) == options.end()) + return string(); + + return options[optionName].currentValue; + } + } //// -- 2.39.2