]> git.lyx.org Git - lyx.git/blobdiff - src/support/docstring.C
Don't use a global variable for avoiding removal of the system temp dir
[lyx.git] / src / support / docstring.C
index e440b38b70a360778bb0ee222d31cc39bc16d223..0b7f796628286eb5cd0b1c4daf99b60f83dcbd42 100644 (file)
@@ -440,52 +440,68 @@ public:
 
 protected:
        iter_type
-       do_put(iter_type oit, std::ios_base & b, char_type fill, long v) const
+       do_put(iter_type oit, std::ios_base & b, char_type fill, bool v) const
        {
-               if (fill >= 0x80)
-                       throw num_put_failure();
-
-               std::string s;
-               // 64 is large enough
-               s.resize(64);
-               string_num_put_facet f;
-               std::string::const_iterator cit = s.begin();
-               std::string::const_iterator end =
-                       f.put(s.begin(), b, fill, v);
-               for (; cit != end; ++cit, ++oit)
-                       *oit = *cit;
+               return do_put_helper(oit, b, fill, v);
+       }
 
-               return oit;
+       iter_type
+       do_put(iter_type oit, std::ios_base & b, char_type fill, long v) const
+       {
+               return do_put_helper(oit, b, fill, v);
        }
 
        iter_type
        do_put(iter_type oit, std::ios_base & b, char_type fill, unsigned long v) const
        {
-               if (fill >= 0x80)
-                       throw num_put_failure();
+               return do_put_helper(oit, b, fill, v);
+       }
 
-               std::string s;
-               // 64 is large enough
-               s.resize(64);
-               string_num_put_facet f;
-               std::string::const_iterator cit = s.begin();
-               std::string::const_iterator end =
-                       f.put(s.begin(), b, fill, v);
-               for (; cit != end; ++cit, ++oit)
-                       *oit = *cit;
+#ifdef _GLIBCXX_USE_LONG_LONG
+       iter_type
+       do_put(iter_type oit, std::ios_base & b, char_type fill, long long v) const
+       {
+               return do_put_helper(oit, b, fill, v);
+       }
 
-               return oit;
+       iter_type
+       do_put(iter_type oit, std::ios_base & b, char_type fill, unsigned long long v) const
+       {
+               return do_put_helper(oit, b, fill, v);
        }
+#endif
 
        iter_type
        do_put(iter_type oit, std::ios_base & b, char_type fill, double v) const
+       {
+               return do_put_helper(oit, b, fill, v);
+       }
+
+       iter_type
+       do_put(iter_type oit, std::ios_base & b, char_type fill, long double v) const
+       {
+               return do_put_helper(oit, b, fill, v);
+       }
+
+       iter_type
+       do_put(iter_type oit, std::ios_base & b, char_type fill, void const * v) const
+       {
+               return do_put_helper(oit, b, fill, v);
+       }
+
+private:
+       template <typename ValueType>
+       iter_type
+       do_put_helper(iter_type oit, std::ios_base & b, char_type fill, ValueType v) const
        {
                if (fill >= 0x80)
                        throw num_put_failure();
 
-               std::string s;
-               // 64 is large enough
-               s.resize(64);
+               std::streamsize const sz = b.width() > b.precision() ?
+                                          b.width() : b.precision();
+               // 64 is large enough, unless width or precision are bigger
+               std::streamsize const wd = (sz > 56 ? sz : 56) + 8;
+               std::string s(wd, '\0');
                string_num_put_facet f;
                std::string::const_iterator cit = s.begin();
                std::string::const_iterator end =