Am Mittwoch, 13. September 2006 18:17 schrieb Lars Gullik Bjønnes: > Georg Baum <[EMAIL PROTECTED]> writes: > > | Index: src/support/docstring.h > | =================================================================== > | --- src/support/docstring.h (Revision 14982) > | +++ src/support/docstring.h (Arbeitskopie) > | @@ -18,8 +18,19 @@ > | > | namespace lyx { > | > | +/// The type used to hold characters in paragraphs > | +#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 > | +// Prefer this if possible because GNU libstdc++ has usable std::ctype<wchar_t> > | +// locale facets but not std::ctype<boost::uint32_t>. gcc older than 3.4 is > | +// also missing usable std::char_traits<boost::uint32_t>. > | +typedef wchar_t char_type; > | +#else > | +// This works on msvc > | +typedef boost::uint32_t char_type; > | +#endif > > I think I'd like to keep this in types.h.
I knew that would come ;-) When I wrote the above I did not think of std::wstring. I committed the boost::uint32_t->lyx::char_type patch, so the boost::uint32_t -> wchar_t change looks like the attached now. > Should we have AC_CHECK_TYPES(wchar_t) as well? > (for completeness.) AC_CHECK_SIZEOF does this for us. Shall I put this in? Georg
Index: src/support/types.h =================================================================== --- src/support/types.h (Revision 14987) +++ src/support/types.h (Arbeitskopie) @@ -18,19 +18,20 @@ #include "docstring.h" -#include <boost/cstdint.hpp> - #include <cstddef> -#include <string> namespace lyx { - // The type used to hold characters in paragraphs - typedef boost::uint32_t char_type; // Possibly the ucs-4 type we will use - //typedef wchar_t char_type; // The wide char type CJK-LyX uses - //typedef char char_type; // Current narrow char type in use - - //typedef std::wstring docstring; + /// The type used to hold characters in paragraphs +#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 + // Prefer this if possible because GNU libstdc++ has usable + // std::ctype<wchar_t> locale facets but not + // std::ctype<boost::uint32_t>. gcc older than 3.4 is also missing + // usable std::char_traits<boost::uint32_t>. + typedef wchar_t char_type; +#else + typedef boost::uint32_t char_type; +#endif /// a type for positions used in paragraphs // needs to be signed for a while to hold the special value -1 that is Index: src/support/docstring.h =================================================================== --- src/support/docstring.h (Revision 14987) +++ src/support/docstring.h (Arbeitskopie) @@ -19,7 +19,14 @@ namespace lyx { /// String type for storing the main text in UCS4 encoding +#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 +// Prefer this if possible because GNU libstdc++ has usable std::ctype<wchar_t> +// locale facets but not std::ctype<boost::uint32_t>. gcc older than 3.4 is +// also missing usable std::char_traits<boost::uint32_t>. +typedef std::wstring docstring; +#else typedef std::basic_string<boost::uint32_t> docstring; +#endif /// Creates a docstring from a C string of ASCII characters docstring const from_ascii(char const *); @@ -60,7 +67,7 @@ lyx::docstring operator+(lyx::docstring lyx::docstring operator+(char l, lyx::docstring const & r); -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4 +#if SIZEOF_WCHAR_T != 4 && defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4 // Missing char_traits methods in gcc 3.3 and older. Taken from gcc 4.2svn. namespace std { Index: configure.ac =================================================================== --- configure.ac (Revision 14987) +++ configure.ac (Arbeitskopie) @@ -147,6 +147,9 @@ AC_SUBST(AIKSAURUS_LIBS) LYX_USE_INCLUDED_BOOST +# Needed for our char_type +AC_CHECK_SIZEOF(wchar_t) + ### Setup libtool dnl Dirty trick ahead: disable libtool checking for a fortran compiler dnl see http://permalink.gmane.org/gmane.comp.gnu.libtool.general/6699