]> git.lyx.org Git - features.git/commitdiff
Use home made code for the bool facet.
authorEnrico Forestieri <forenr@lyx.org>
Tue, 31 Jul 2007 13:13:23 +0000 (13:13 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 31 Jul 2007 13:13:23 +0000 (13:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19250 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/docstring.cpp

index e2a4e4e5b75b0f4286e6df86dc2461f8ff86201b..c232fec5fc91d23b00184e3d728165458de4e1e0 100644 (file)
@@ -13,6 +13,7 @@
 #include "docstring.h"
 #include "qstring_helpers.h"
 #include "unicode.h"
+#include "lstrings.h"
 
 #include <locale>
 #include <iostream>
@@ -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)