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
This commit is contained in:
Enrico Forestieri 2007-07-31 13:14:50 +00:00
parent 0f85db4b41
commit ea191d9095

View File

@ -13,6 +13,7 @@
#include "docstring.h" #include "docstring.h"
#include "qstring_helpers.h" #include "qstring_helpers.h"
#include "unicode.h" #include "unicode.h"
#include "lstrings.h"
#include <locale> #include <locale>
#include <iostream> #include <iostream>
@ -572,33 +573,35 @@ protected:
do_get(iter_type iit, iter_type eit, std::ios_base & b, do_get(iter_type iit, iter_type eit, std::ios_base & b,
std::ios_base::iostate & err, bool & v) const std::ios_base::iostate & err, bool & v) const
{ {
// This facet has been adapted from the STLPort library
if (b.flags() & std::ios_base::boolalpha) { if (b.flags() & std::ios_base::boolalpha) {
numpunct_facet p; numpunct_facet p;
lyx::docstring const truename = from_local8bit(p.truename()); lyx::docstring const truename = from_local8bit(p.truename());
lyx::docstring const falsename = from_local8bit(p.falsename()); lyx::docstring const falsename = from_local8bit(p.falsename());
bool true_ok = true; lyx::docstring s;
bool false_ok = true; s.resize(16);
bool ok = true;
size_t n = 0; size_t n = 0;
size_t const tsize = truename.size();
size_t const fsize = falsename.size();
for (; iit != eit; ++iit) { for (; iit != eit; ++iit) {
lyx::char_type c = *iit; s += *iit;
true_ok = true_ok && (c == truename[n]);
false_ok = false_ok && (c == falsename[n]);
++n; ++n;
if ((!true_ok && !false_ok) || bool true_ok = lyx::support::prefixIs(truename, s);
(true_ok && n >= truename.size()) || bool false_ok = lyx::support::prefixIs(falsename, s);
(false_ok && n >= falsename.size())) { if (!true_ok && !false_ok) {
++iit;
ok = false;
break;
}
if ((true_ok && n == tsize) ||
(false_ok && n == fsize)) {
++iit; ++iit;
break; break;
} }
} }
if (true_ok && n < truename.size()) if (ok) {
true_ok = false;
if (false_ok && n < falsename.size())
false_ok = false;
if (true_ok || false_ok) {
err = std::ios_base::goodbit; err = std::ios_base::goodbit;
v = true_ok; v = truename == s ? true : false;
} else } else
err = std::ios_base::failbit; err = std::ios_base::failbit;
if (iit == eit) if (iit == eit)