Fixed negative infinity parsing

This commit is contained in:
Jesse Beder
2011-07-10 18:29:44 +00:00
parent 94dc63af04
commit 835b86d9f7
2 changed files with 16 additions and 9 deletions

View File

@@ -23,9 +23,11 @@ namespace YAML
YAML_CPP_API bool Convert(const std::string& input, _Null& output);
inline bool IsInfinity(const std::string& input) {
return input == ".inf" || input == ".Inf" || input == ".INF" ||
input == "+.inf" || input == "+.Inf" || input == "+.INF" ||
input == "-.inf" || input == "-.Inf" || input == "-.INF";
return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF";
}
inline bool IsNegativeInfinity(const std::string& input) {
return input == "-.inf" || input == "-.Inf" || input == "-.INF";
}
inline bool IsNaN(const std::string& input) {
@@ -41,9 +43,14 @@ namespace YAML
if(!!stream)
return true;
if(std::numeric_limits<T>::has_infinity && IsInfinity(input)) {
output = std::numeric_limits<T>::infinity();
return true;
if(std::numeric_limits<T>::has_infinity) {
if(IsInfinity(input)) {
output = std::numeric_limits<T>::infinity();
return true;
} else if(IsNegativeInfinity(input)) {
output = -std::numeric_limits<T>::infinity();
return true;
}
}
if(std::numeric_limits<T>::has_quiet_NaN && IsNaN(input)) {