From ea191d9095f7d138f1c8b37d7d4ea5ec86d9b0be Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 31 Jul 2007 13:14:50 +0000 Subject: [PATCH] Use home made code for the bool facet. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19251 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/docstring.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index e2a4e4e5b7..c232fec5fc 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -13,6 +13,7 @@ #include "docstring.h" #include "qstring_helpers.h" #include "unicode.h" +#include "lstrings.h" #include #include @@ -572,33 +573,35 @@ protected: do_get(iter_type iit, iter_type eit, std::ios_base & b, std::ios_base::iostate & err, bool & v) const { - // This facet has been adapted from the STLPort library if (b.flags() & std::ios_base::boolalpha) { numpunct_facet p; lyx::docstring const truename = from_local8bit(p.truename()); lyx::docstring const falsename = from_local8bit(p.falsename()); - bool true_ok = true; - bool false_ok = true; + lyx::docstring s; + s.resize(16); + bool ok = true; size_t n = 0; + size_t const tsize = truename.size(); + size_t const fsize = falsename.size(); for (; iit != eit; ++iit) { - lyx::char_type c = *iit; - true_ok = true_ok && (c == truename[n]); - false_ok = false_ok && (c == falsename[n]); + s += *iit; ++n; - if ((!true_ok && !false_ok) || - (true_ok && n >= truename.size()) || - (false_ok && n >= falsename.size())) { + bool true_ok = lyx::support::prefixIs(truename, s); + bool false_ok = lyx::support::prefixIs(falsename, s); + if (!true_ok && !false_ok) { + ++iit; + ok = false; + break; + } + if ((true_ok && n == tsize) || + (false_ok && n == fsize)) { ++iit; break; } } - if (true_ok && n < truename.size()) - true_ok = false; - if (false_ok && n < falsename.size()) - false_ok = false; - if (true_ok || false_ok) { + if (ok) { err = std::ios_base::goodbit; - v = true_ok; + v = truename == s ? true : false; } else err = std::ios_base::failbit; if (iit == eit)