From 812925e66904adf1b760102ff36de27713c52e59 Mon Sep 17 00:00:00 2001 From: jez Date: Wed, 6 Aug 2008 22:31:39 +0100 Subject: [PATCH] Added configure tests for std::mbstate_t and/or mbstate_t. Some platforms don't have it (VxWorks, for example). --- configure.ac | 1 + include/Arabica/mbstate.hpp | 23 +++++++++++++++++++++++ include/convert/base64codecvt.hpp | 1 + include/convert/iso88591utf8codecvt.hpp | 1 + include/convert/rot13codecvt.hpp | 1 + include/convert/ucs2utf8codecvt.hpp | 6 ++---- include/convert/utf16beucs2codecvt.hpp | 2 +- include/convert/utf16leucs2codecvt.hpp | 2 +- include/convert/utf16utf8codecvt.hpp | 2 +- include/convert/utf8iso88591codecvt.hpp | 1 + include/convert/utf8ucs2codecvt.hpp | 5 ++--- include/io/convert_adaptor.hpp | 1 + m4/mbstate_t.m4 | 22 ++++++++++++++++++++++ 13 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 include/Arabica/mbstate.hpp create mode 100644 m4/mbstate_t.m4 diff --git a/configure.ac b/configure.ac index d27789e5..d1afd445 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,7 @@ ARABICA_HAS_LIBXML2 ARABICA_HAS_XERCES ARABICA_USE_GARDEN ARABICA_HAS_XML_PARSER +ARABICA_HAS_MBSTATE_T ARABICA_HAS_STD_WSTRING ARABICA_CHECK_CODECVT_SPECIALISATIONS ARABICA_CHECK_SOCKETS diff --git a/include/Arabica/mbstate.hpp b/include/Arabica/mbstate.hpp new file mode 100644 index 00000000..6edf7268 --- /dev/null +++ b/include/Arabica/mbstate.hpp @@ -0,0 +1,23 @@ +#ifndef ARABICA_MBSTATE_T +#define ARABICA_MBSTATE_T + +#ifdef ARABICA_NO_STD_MBSTATE_T + +#ifndef ARABICA_NO_MBSTATE_T +#include +namespace std { + using ::mbstate_t; +} +#else +namespace std { + typedef struct + { + int dummy; /* So that {0} is a valid constant initializer. */ + } mbstate_t; +} +#endif + + +#endif + +#endif diff --git a/include/convert/base64codecvt.hpp b/include/convert/base64codecvt.hpp index 51017156..0feec939 100644 --- a/include/convert/base64codecvt.hpp +++ b/include/convert/base64codecvt.hpp @@ -8,6 +8,7 @@ #include #include +#include #ifdef ARABICA_VS6_WORKAROUND #include diff --git a/include/convert/iso88591utf8codecvt.hpp b/include/convert/iso88591utf8codecvt.hpp index 83260872..f61f1e5e 100644 --- a/include/convert/iso88591utf8codecvt.hpp +++ b/include/convert/iso88591utf8codecvt.hpp @@ -2,6 +2,7 @@ #define ARABICA_ISO88591UTF8ISO88591_CODECVT_H #include #include +#include #ifdef ARABICA_VS6_WORKAROUND namespace std { diff --git a/include/convert/rot13codecvt.hpp b/include/convert/rot13codecvt.hpp index 7daed183..7cd7d621 100644 --- a/include/convert/rot13codecvt.hpp +++ b/include/convert/rot13codecvt.hpp @@ -8,6 +8,7 @@ #include #include +#include #ifdef ARABICA_VS6_WORKAROUND #include #endif diff --git a/include/convert/ucs2utf8codecvt.hpp b/include/convert/ucs2utf8codecvt.hpp index 2bf29756..74910733 100644 --- a/include/convert/ucs2utf8codecvt.hpp +++ b/include/convert/ucs2utf8codecvt.hpp @@ -9,12 +9,10 @@ // The C++ Standard (ISO/IEC 14882 to be pedantic). // // I got my information about UTF-8 from RFC 2044. -// -// $Id$ //--------------------------------------------------------------------------- -#include - #include +#include +#include #ifndef ARABICA_NO_CODECVT_SPECIALISATIONS #include diff --git a/include/convert/utf16beucs2codecvt.hpp b/include/convert/utf16beucs2codecvt.hpp index e96fd163..4251229c 100644 --- a/include/convert/utf16beucs2codecvt.hpp +++ b/include/convert/utf16beucs2codecvt.hpp @@ -9,7 +9,7 @@ //--------------------------------------------------------------------------- #include #ifndef ARABICA_NO_WCHAR_T - +#include #include #ifndef ARABICA_NO_CODECVT_SPECIALISATIONS diff --git a/include/convert/utf16leucs2codecvt.hpp b/include/convert/utf16leucs2codecvt.hpp index 17ef50e6..15b963ec 100644 --- a/include/convert/utf16leucs2codecvt.hpp +++ b/include/convert/utf16leucs2codecvt.hpp @@ -9,7 +9,7 @@ //--------------------------------------------------------------------------- #include #ifndef ARABICA_NO_WCHAR_T - +#include #include #ifndef ARABICA_NO_CODECVT_SPECIALISATIONS diff --git a/include/convert/utf16utf8codecvt.hpp b/include/convert/utf16utf8codecvt.hpp index 5daab11e..b46ffc83 100644 --- a/include/convert/utf16utf8codecvt.hpp +++ b/include/convert/utf16utf8codecvt.hpp @@ -13,7 +13,7 @@ // $Id$ //--------------------------------------------------------------------------- #include - +#include #include #ifndef ARABICA_NO_CODECVT_SPECIALISATIONS diff --git a/include/convert/utf8iso88591codecvt.hpp b/include/convert/utf8iso88591codecvt.hpp index 2898453b..74898c24 100644 --- a/include/convert/utf8iso88591codecvt.hpp +++ b/include/convert/utf8iso88591codecvt.hpp @@ -2,6 +2,7 @@ #define ARABICA_UTF8ISO88591_CODECVT_H #include #include +#include #ifdef ARABICA_VS6_WORKAROUND namespace std { diff --git a/include/convert/utf8ucs2codecvt.hpp b/include/convert/utf8ucs2codecvt.hpp index 48d29ab4..1d339e77 100644 --- a/include/convert/utf8ucs2codecvt.hpp +++ b/include/convert/utf8ucs2codecvt.hpp @@ -9,12 +9,11 @@ // The C++ Standard (ISO/IEC 14882 to be pedantic). // // I got my information about UTF-8 from RFC 2044. -// -// $Id$ //--------------------------------------------------------------------------- #include -#ifndef ARABICA_NO_WCHAR_T +#ifndef ARABICA_NO_WCHAR_T +#include #include #ifndef ARABICA_NO_CODECVT_SPECIALISATIONS diff --git a/include/io/convert_adaptor.hpp b/include/io/convert_adaptor.hpp index 59b8ea82..0332e555 100644 --- a/include/io/convert_adaptor.hpp +++ b/include/io/convert_adaptor.hpp @@ -21,6 +21,7 @@ #include #include +#include #ifdef ARABICA_VS6_WORKAROUND #include #endif diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4 new file mode 100644 index 00000000..d5c59f65 --- /dev/null +++ b/m4/mbstate_t.m4 @@ -0,0 +1,22 @@ +AC_DEFUN([ARABICA_HAS_MBSTATE_T], +[ + AC_MSG_CHECKING([for std::mbstate_t]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[std::mbstate_t mb; return sizeof(mb);]])], + [mbstate_available=yes], + [mbstate_available=no]) + AC_MSG_RESULT([$mbstate_available]) + if test $mbstate_available = no; then + AC_DEFINE([ARABICA_NO_STD_MBSTATE_T], ,[no std::mbstate_t]) + + AC_MSG_CHECKING([for mbstate_t]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[mbstate_t mb; return sizeof(mb);]])], + [mbstate_available=yes], + [mbstate_available=no]) + AC_MSG_RESULT([$mbstate_available]) + if test $mbstate_available = no; then + AC_DEFINE([ARABICA_NO_MBSTATE_T], ,[no mbstate_t]) + fi + fi +]) \ No newline at end of file