diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-06-19 11:43:05 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-06-19 14:32:59 +0200 |
commit | fb0d8859042570a15e0477f1ba6adf638b01db0f (patch) | |
tree | 588cbde20b82652dd11f4abb76d40e5fdbdf6016 /config | |
parent | a0b7b206752e54118ef0b0ce88987e88ddb2d689 (diff) |
Move locale insensitive stdtod to vespalib
Diffstat (limited to 'config')
-rw-r--r-- | config/src/vespa/config/common/configparser.cpp | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/config/src/vespa/config/common/configparser.cpp b/config/src/vespa/config/common/configparser.cpp index 1f303c49871..6784f0793e9 100644 --- a/config/src/vespa/config/common/configparser.cpp +++ b/config/src/vespa/config/common/configparser.cpp @@ -4,7 +4,7 @@ #include "exceptions.h" #include "misc.h" #include <vespa/vespalib/stllike/asciistream.h> -#include <cassert> +#include <vespa/vespalib/locale/c.h> namespace config { @@ -339,25 +339,6 @@ ConfigParser::convert<int64_t>(const vsvector & config) return ret; } -namespace { - -class Locale { -public: - Locale() : Locale(LC_ALL_MASK, "C") { } - Locale(int category, const char *locale) : _locale(newlocale(category, locale, nullptr)) - { - perror("newlocale failed"); - assert(_locale != nullptr); - } - ~Locale() { freelocale(_locale); } - locale_t get() const { return _locale; } -private: - locale_t _locale; -}; - -Locale _G_C_Locale; -} - template<> double ConfigParser::convert<double>(const vsvector & config) @@ -371,7 +352,7 @@ ConfigParser::convert<double>(const vsvector & config) const char *startp = value.c_str(); char *endp; errno = 0; - double ret = strtod_l(startp, &endp, _G_C_Locale.get()); + double ret = vespalib::locale::c::strtod(startp, &endp); int err = errno; if (err == ERANGE || (*endp != '\0')) { throw InvalidConfigException("Value " + value + " is not a legal double", VESPA_STRLOC); |