X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fdocstring.cpp;h=496d4c0242202014e0d85f7d98cd6a5f47b1d2f0;hb=557c2f2bf0b22fb72b3af385571ea7b33ff377fd;hp=30298b5f59a9a6e310847bcae490ee0c5e1597ee;hpb=430d03811e15c5f78e3c7110a95683a4e24d37fc;p=lyx.git diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index 30298b5f59..496d4c0242 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -19,12 +19,16 @@ #include +//Needed in Ubuntu +#include +#if ! defined(USE_WCHAR_T) && defined(__GNUC__) #include #include -#include +#endif using namespace std; +using lyx::support::isHexChar; namespace lyx { @@ -36,7 +40,7 @@ docstring const from_ascii(char const * ascii) char_type *d = &s[0]; while (--n >= 0) { d[n] = ascii[n]; - LASSERT(static_cast(ascii[n]) < 0x80, /**/); + LATTEST(static_cast(ascii[n]) < 0x80); } } return s; @@ -47,7 +51,7 @@ docstring const from_ascii(string const & ascii) { int const len = ascii.length(); for (int i = 0; i < len; ++i) - LASSERT(static_cast(ascii[i]) < 0x80, /**/); + LATTEST(static_cast(ascii[i]) < 0x80); return docstring(ascii.begin(), ascii.end()); } @@ -58,21 +62,13 @@ string const to_ascii(docstring const & ucs4) string ascii; ascii.resize(len); for (int i = 0; i < len; ++i) { - LASSERT(ucs4[i] < 0x80, /**/); + LATTEST(ucs4[i] < 0x80); ascii[i] = static_cast(ucs4[i]); } return ascii; } -IconvProcessor & utf8ToUcs4() -{ - static IconvProcessor iconv(ucs4_codeset, "UTF-8"); - return iconv; -} - - - void utf8_to_ucs4(string const & utf8, docstring & ucs4) { size_t n = utf8.size(); @@ -132,7 +128,7 @@ string const to_local8bit(docstring const & s) if (s.empty()) return string(); QByteArray const local = toqstr(s).toLocal8Bit(); - if (local.size() == 0) + if (local.isEmpty()) throw to_local8bit_failure(); return string(local.begin(), local.end()); } @@ -179,7 +175,7 @@ bool operator==(lyx::docstring const & l, char const * r) lyx::docstring::const_iterator it = l.begin(); lyx::docstring::const_iterator end = l.end(); for (; it != end; ++it, ++r) { - LASSERT(static_cast(*r) < 0x80, /**/); + LASSERT(static_cast(*r) < 0x80, return false); if (!*r) return false; if (*it != static_cast(*r)) @@ -193,7 +189,7 @@ lyx::docstring operator+(lyx::docstring const & l, char const * r) { lyx::docstring s(l); for (char const * c = r; *c; ++c) { - LASSERT(static_cast(*c) < 0x80, /**/); + LASSERT(static_cast(*c) < 0x80, return l); s.push_back(*c); } return s; @@ -204,7 +200,7 @@ lyx::docstring operator+(char const * l, lyx::docstring const & r) { lyx::docstring s; for (char const * c = l; *c; ++c) { - LASSERT(static_cast(*c) < 0x80, /**/); + LASSERT(static_cast(*c) < 0x80, return r); s.push_back(*c); } s += r; @@ -214,7 +210,7 @@ lyx::docstring operator+(char const * l, lyx::docstring const & r) lyx::docstring operator+(lyx::docstring const & l, char r) { - LASSERT(static_cast(r) < 0x80, /**/); + LASSERT(static_cast(r) < 0x80, return l); docstring s = l; s += docstring::value_type(r); return s; @@ -223,7 +219,7 @@ lyx::docstring operator+(lyx::docstring const & l, char r) lyx::docstring operator+(char l, lyx::docstring const & r) { - LASSERT(static_cast(l) < 0x80, /**/); + LASSERT(static_cast(l) < 0x80, return r); return lyx::docstring::value_type(l) + r; } @@ -231,7 +227,7 @@ lyx::docstring operator+(char l, lyx::docstring const & r) lyx::docstring & operator+=(lyx::docstring & l, char const * r) { for (char const * c = r; *c; ++c) { - LASSERT(static_cast(*c) < 0x80, /**/); + LASSERT(static_cast(*c) < 0x80, return l); l.push_back(*c); } return l; @@ -240,7 +236,7 @@ lyx::docstring & operator+=(lyx::docstring & l, char const * r) lyx::docstring & operator+=(lyx::docstring & l, char r) { - LASSERT(static_cast(r) < 0x80, /**/); + LASSERT(static_cast(r) < 0x80, return l); l.push_back(r); return l; } @@ -277,7 +273,7 @@ template<> char ctype::do_narrow(const lyx::char_type, char) const { return 0; } template<> const lyx::char_type * ctype::do_narrow(const lyx::char_type *, const lyx::char_type *, char, char *) const { return 0; } -} +} // namespace std namespace lyx { @@ -518,7 +514,7 @@ protected: return do_put_helper(oit, b, fill, v); } -#ifdef _GLIBCXX_USE_LONG_LONG +#ifdef LYX_USE_LONG_LONG iter_type do_put(iter_type oit, ios_base & b, char_type fill, long long v) const { @@ -679,7 +675,7 @@ protected: return do_get_integer(iit, eit, b, err, v); } -#ifdef _GLIBCXX_USE_LONG_LONG +#ifdef LYX_USE_LONG_LONG iter_type do_get(iter_type iit, iter_type eit, ios_base & b, ios_base::iostate & err, long long & v) const @@ -767,7 +763,6 @@ private: // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)? string s; s.reserve(64); - char c; numpunct_facet p; char const dot = p.decimal_point(); char const sep = p.thousands_sep(); @@ -825,6 +820,6 @@ namespace { /// make sure that our facets get used static locale_initializer initializer; -} -} +} // namespace +} // namespace lyx #endif