Permalink
Browse files

Remove String::Stream and with it the locale hacks.

Also fixes the crash when compiled with -O
  • Loading branch information...
mniip committed May 3, 2018
1 parent ecb4166 commit 5d80d77f55fc54369868d31bc81738775a29d5ec
Showing with 0 additions and 134 deletions.
  1. +0 −132 src/common/String.cpp
  2. +0 −2 src/common/String.h
@@ -437,135 +437,3 @@ String::Split String::SplitFloat(double &value, size_t pos, std::ios_base::fmtfl
LocaleImpl.FlushWStream();
return split;
}
template<> std::ctype<char32_t>::~ctype()
{
}
template<> std::numpunct<char32_t>::numpunct(size_t ref): std::locale::facet(ref)
{
}
template<> std::numpunct<char32_t>::~numpunct()
{
}
static struct Locale32Impl
{
std::ctype<wchar_t> const &ctype16;
std::numpunct<wchar_t> const &numpunct16;
Locale32Impl():
ctype16(std::use_facet<std::ctype<wchar_t> >(std::locale())),
numpunct16(std::use_facet<std::numpunct<wchar_t> >(std::locale()))
{
std::locale::global(std::locale(std::locale(), new std::ctype<char32_t>()));
std::locale::global(std::locale(std::locale(), new std::numpunct<char32_t>()));
std::locale::global(std::locale(std::locale(), new std::num_put<char32_t>()));
}
}
Locale32Impl;
template<> bool std::ctype<char32_t>::do_is(mask m, char32_t ch) const
{
return ch <= 0xFFFF ? Locale32Impl.ctype16.is(m, ch) : (m & print);
}
template<> char32_t const *std::ctype<char32_t>::do_is(char32_t const *low, char32_t const *high, mask *vec) const
{
while(low < high)
{
if(*low <= 0xFFFF)
{
wchar_t l = *low;
Locale32Impl.ctype16.is(&l, &l + 1, vec);
}
else
*vec = print;
low++;
}
return high;
}
template<> char32_t const *std::ctype<char32_t>::do_scan_is(mask m, char32_t const *beg, char32_t const *end) const
{
while(beg < end)
if(do_is(m, *beg))
return beg;
else
beg++;
return end;
}
template<> char32_t const *std::ctype<char32_t>::do_scan_not(mask m, char32_t const *beg, char32_t const *end) const
{
while(beg < end)
if(!do_is(m, *beg))
return beg;
else
beg++;
return end;
}
template<> char32_t std::ctype<char32_t>::do_toupper(char32_t ch) const
{
return ch <= 0xFFFF ? Locale32Impl.ctype16.toupper(ch) : ch;
}
template<> char32_t const *std::ctype<char32_t>::do_toupper(char32_t *beg, char32_t const *end) const
{
while(beg < end)
{
*beg = do_toupper(*beg);
beg++;
}
return end;
}
template<> char32_t std::ctype<char32_t>::do_tolower(char32_t ch) const
{
return ch <= 0xFFFF ? Locale32Impl.ctype16.tolower(ch) : ch;
}
template<> char32_t const *std::ctype<char32_t>::do_tolower(char32_t *beg, char32_t const *end) const
{
while(beg < end)
{
*beg = do_tolower(*beg);
beg++;
}
return end;
}
template<> char32_t std::ctype<char32_t>::do_widen(char ch) const
{
return Locale32Impl.ctype16.widen(ch);
}
template<> char const *std::ctype<char32_t>::do_widen(char const *beg, char const *end, char32_t *dst) const
{
while(beg < end)
*(dst++) = do_widen(*(beg++));
return end;
}
template<> char std::ctype<char32_t>::do_narrow(char32_t ch, char dflt) const
{
return ch <= 0xFFFF ? Locale32Impl.ctype16.narrow(ch, dflt) : dflt;
}
template<> char32_t const *std::ctype<char32_t>::do_narrow(char32_t const *beg, char32_t const *end, char dflt, char *dst) const
{
while(beg < end)
*(dst++) = do_narrow(*(beg++), dflt);
return end;
}
template<> char32_t std::numpunct<char32_t>::do_decimal_point() const
{
return Locale32Impl.numpunct16.decimal_point();
}
template<> char32_t std::numpunct<char32_t>::do_thousands_sep() const
{
return Locale32Impl.numpunct16.thousands_sep();
}
template<> std::string std::numpunct<char32_t>::do_grouping() const
{
return Locale32Impl.numpunct16.grouping();
}
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_truename() const
{
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.truename();
return std::basic_string<char32_t>(name.begin(), name.end());
}
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_falsename() const
{
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.falsename();
return std::basic_string<char32_t>(name.begin(), name.end());
}
@@ -259,8 +259,6 @@ class String : public std::basic_string<char32_t>
ByteString ToUtf8() const;
ByteString ToAscii() const;
template<typename... Ts> static String Build(Ts&&... args);
using Stream = std::basic_stringstream<value_type>;
};
inline String operator+(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }

0 comments on commit 5d80d77

Please sign in to comment.