From 5cbe5cf5adbc8989ddec8aed408126255207c5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Wed, 27 Jun 2007 18:02:54 +0000 Subject: [PATCH] FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t support compiled in (Jean-Marc) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18913 a592a061-630c-0410-9148-cb99ea01b6c8 --- configure.ac | 14 ++++++++++++-- src/support/docstream.cpp | 2 +- src/support/docstring.cpp | 2 +- src/support/docstring.h | 2 +- src/support/types.h | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index d7a8fc7007..3c73eac3b1 100644 --- a/configure.ac +++ b/configure.ac @@ -383,8 +383,18 @@ int mkstemp(char*); # define WANT_GETFILEATTRIBUTESEX_WRAPPER 1 #endif -#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 -# define LIBC_WCTYPE_USES_UCS4 +/* + * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t + * support compiled in: + * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9 + * And we are not interested at all what libc + * does: What we need is a 32bit wide wchar_t, and a libstdc++ that + * has the needed wchar_t support and uses UCS4. Whether it + * implements this with the help of libc, or whether it has own code + * does not matter for us, because we don't use libc directly (Georg) +*/ +#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && ! defined(__FREEBSD__) +# define USE_WCHAR_T #endif #endif diff --git a/src/support/docstream.cpp b/src/support/docstream.cpp index c2193c8273..8f476376e6 100644 --- a/src/support/docstream.cpp +++ b/src/support/docstream.cpp @@ -322,7 +322,7 @@ odocstream & operator<<(odocstream & os, SetEnc e) } -#if (!defined(HAVE_WCHAR_T) || SIZEOF_WCHAR_T != 4) && defined(__GNUC__) +#if ! defined(USE_WCHAR_T) && defined(__GNUC__) // We get undefined references to these virtual methods. This looks like // a bug in gcc. The implementation here does not do anything useful, since // it is overriden in iconv_codecvt_facet. diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp index 3541493416..ba424cd2c7 100644 --- a/src/support/docstring.cpp +++ b/src/support/docstring.cpp @@ -217,7 +217,7 @@ lyx::docstring & operator+=(lyx::docstring & l, char r) } // namespace lyx -#if (!defined(HAVE_WCHAR_T) || SIZEOF_WCHAR_T != 4) && defined(__GNUC__) +#if ! defined(USE_WCHAR_T) && defined(__GNUC__) // gcc does not have proper locale facets for lyx::char_type if // sizeof(wchar_t) == 2, so we have to implement them on our own. diff --git a/src/support/docstring.h b/src/support/docstring.h index 6ee612bb3c..e974e4ea1f 100644 --- a/src/support/docstring.h +++ b/src/support/docstring.h @@ -98,7 +98,7 @@ lyx::docstring & operator+=(lyx::docstring & l, char r); } // namespace lyx -#if SIZEOF_WCHAR_T != 4 && defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4 +#if ! defined(USE_WCHAR_T) && 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 { diff --git a/src/support/types.h b/src/support/types.h index 446aa3d60f..6151a676e1 100644 --- a/src/support/types.h +++ b/src/support/types.h @@ -23,7 +23,7 @@ namespace lyx { /// The type used to hold characters in paragraphs -#if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 +#ifdef USE_WCHAR_T // Prefer this if possible because GNU libstdc++ has usable // std::ctype locale facets but not // std::ctype. gcc older than 3.4 is also missing