Am Mittwoch, 13. September 2006 21:36 schrieb Lars Gullik Bjønnes:
> Georg Baum <[EMAIL PROTECTED]> writes:
> 
> | Am Mittwoch, 13. September 2006 20:50 schrieb Lars Gullik Bjønnes:
> | > Georg Baum <[EMAIL PROTECTED]> writes:
> | > | 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>
> | > 
> | > this us used below, you cannot delete it.
> | 
> | It is included in docstring.h. Do you still think I should not delete 
it?
> 
> Hmmm why is types.h in docstring again?

I guess you mean boost/cstdint.hpp, not types.h.

> It shouldn't be in docstring if lyx::char_type is used there.
> 
> Then it should be switched around.

That is cleaner indeed, although it requires some more changes. This patch 
goes now in.

Log:
Use wchar_t as lyx::char_type if it is 32 bit wide.

No scons and cmake support! scons and cmake need to find out the size of
wchar_t and define this macro in config.h (example for 32bit wchar_t):

* The size of a `wchar_t', as computed by sizeof. */
#define SIZEOF_WCHAR_T 4

        * configure.ac: Test size of wchar_t

        * src/support/types.h: don't include docstring.h anymore.
        Use wchar_t as lyx::char_type if it is 32 bit wide.

        * src/support/docstring.h: Use lyx::char_type for defining docstring

        * src/metricsinfo.h: include support/docstring.h instead of
        support/types.h
        * src/lyxlex.h: ditto
        * src/frontends/font_metrics.h: ditto
        * src/frontends/qt4/qt_helpers.h: ditto
        * src/frontends/Painter.h: ditto
        * src/errorlist.h: ditto
        * src/support/lstrings.h: ditto
        * src/lyxfunc.h: ditto
        * src/LaTeX.h: ditto


Georg
Index: src/metricsinfo.h
===================================================================
--- src/metricsinfo.h	(Revision 14987)
+++ src/metricsinfo.h	(Arbeitskopie)
@@ -13,9 +13,7 @@
 #define METRICSINFO_H
 
 #include "lyxfont.h"
-#include "support/types.h"
-
-#include <string>
+#include "support/docstring.h"
 
 class BufferView;
 
Index: src/lyxlex.h
===================================================================
--- src/lyxlex.h	(Revision 14987)
+++ src/lyxlex.h	(Arbeitskopie)
@@ -17,12 +17,11 @@
 #ifndef LYXLEX_H
 #define LYXLEX_H
 
-#include "support/types.h"
+#include "support/docstring.h"
 
 #include <boost/utility.hpp>
 
 #include <iosfwd>
-#include <string>
 
 
 ///
Index: src/frontends/font_metrics.h
===================================================================
--- src/frontends/font_metrics.h	(Revision 14987)
+++ src/frontends/font_metrics.h	(Arbeitskopie)
@@ -13,9 +13,7 @@
 #ifndef FONT_METRICS_H
 #define FONT_METRICS_H
 
-#include "support/types.h"
-
-#include <string>
+#include "support/docstring.h"
 
 
 class LyXFont;
Index: src/frontends/qt4/qt_helpers.h
===================================================================
--- src/frontends/qt4/qt_helpers.h	(Revision 14987)
+++ src/frontends/qt4/qt_helpers.h	(Arbeitskopie)
@@ -17,7 +17,7 @@
 #include "lyxlength.h"
 //#include "lengthcombo.h"
 
-#include "support/types.h"
+#include "support/docstring.h"
 
 #include <vector>
 
Index: src/frontends/Painter.h
===================================================================
--- src/frontends/Painter.h	(Revision 14987)
+++ src/frontends/Painter.h	(Arbeitskopie)
@@ -15,9 +15,7 @@
 
 #include "LColor.h"
 
-#include "support/types.h"
-
-#include <string>
+#include "support/docstring.h"
 
 
 class LyXFont;
Index: src/errorlist.h
===================================================================
--- src/errorlist.h	(Revision 14987)
+++ src/errorlist.h	(Arbeitskopie)
@@ -12,7 +12,7 @@
 #ifndef ERRORLIST_H
 #define ERRORLIST_H
 
-#include "support/types.h"
+#include "support/docstring.h"
 
 #include <vector>
 #include <string>
Index: src/support/types.h
===================================================================
--- src/support/types.h	(Revision 14987)
+++ src/support/types.h	(Arbeitskopie)
@@ -16,21 +16,22 @@
 #ifndef LYX_TYPES_H
 #define LYX_TYPES_H
 
-#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/lstrings.h
===================================================================
--- src/support/lstrings.h	(Revision 14987)
+++ src/support/lstrings.h	(Arbeitskopie)
@@ -16,7 +16,7 @@
 #ifndef LSTRINGS_H
 #define LSTRINGS_H
 
-#include "support/types.h"
+#include "support/docstring.h"
 
 #include <vector>
 
Index: src/support/docstring.h
===================================================================
--- src/support/docstring.h	(Revision 14987)
+++ src/support/docstring.h	(Arbeitskopie)
@@ -13,13 +13,14 @@
 #ifndef LYX_DOCSTRING_H
 #define LYX_DOCSTRING_H
 
-#include <boost/cstdint.hpp>
+#include "support/types.h"
+
 #include <string>
 
 namespace lyx {
 
 /// String type for storing the main text in UCS4 encoding
-typedef std::basic_string<boost::uint32_t> docstring;
+typedef std::basic_string<char_type> docstring;
 
 /// Creates a docstring from a C string of ASCII characters
 docstring const from_ascii(char const *);
@@ -60,7 +61,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: src/lyxfunc.h
===================================================================
--- src/lyxfunc.h	(Revision 14987)
+++ src/lyxfunc.h	(Arbeitskopie)
@@ -18,7 +18,7 @@
 #include "kbsequence.h"
 #include "lfuns.h"
 
-#include "support/types.h"
+#include "support/docstring.h"
 
 #include <boost/shared_ptr.hpp>
 #include <boost/signals/trackable.hpp>
Index: src/LaTeX.h
===================================================================
--- src/LaTeX.h	(Revision 14987)
+++ src/LaTeX.h	(Arbeitskopie)
@@ -16,6 +16,8 @@
 
 #include "outputparams.h"
 
+#include "support/docstring.h"
+
 #include <boost/utility.hpp>
 #include <boost/signal.hpp>
 
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

Reply via email to