From b7fd7bd91600bbb442c591330558d122fdff583a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 1 Mar 2005 14:52:36 +0000 Subject: [PATCH] Portability fixes. --- configure.in | 40 ++++++++++++++++++++++++++++++++++++++- src/common/common.cpp | 14 +++++++++----- src/common/commonebml.cpp | 8 +++++--- src/extract/cuesheets.cpp | 1 - 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 32b6abd67..52a377b14 100644 --- a/configure.in +++ b/configure.in @@ -369,7 +369,8 @@ size_t iconv(); [Define as const if the declaration of iconv() needs const.]) else echo '*** The iconv library is needed but could not be found.' - echo '*** Please install it and re-run configure.' + echo '*** Please install it and re-run configure. You can find iconv' + echo '*** at http://www.gnu.org/software/libiconv/' exit 1 fi ICONV_LIBS= @@ -380,6 +381,43 @@ size_t iconv(); AC_SUBST(ICONV_LIBS) +dnl +dnl Check for nl_langinfo or at least locale_charset +dnl +if test x"$MINGW" != "x1" ; then + AC_MSG_CHECKING(for nl_langinfo) + AC_CACHE_VAL(ac_cv_has_nl_langinfo,[ + AC_TRY_COMPILE([ +#include + ], + [nl_langinfo(CODESET);], + ac_cv_has_nl_langinfo=yes, + ac_cv_has_nl_langinfo=no) + ]) + AC_MSG_RESULT($ac_cv_has_nl_langinfo) + if test x"$ac_cv_has_nl_langinfo" = "xyes" ; then + AC_DEFINE(HAVE_NL_LANGINFO, 1, [nl_langinfo is available]) + else + AC_MSG_CHECKING(for locale_charset) + AC_CACHE_VAL(ac_cv_has_locale_charset,[ + AC_TRY_COMPILE([ +#include + ], + [locale_charset();], + ac_cv_has_locale_charset=yes, + ac_cv_has_locale_charset=no) + ]) + AC_MSG_RESULT($ac_cv_has_locale_charset) + if test x"$ac_cv_has_locale_charset" = "xyes" ; then + AC_DEFINE(HAVE_LOCALE_CHARSET, 1, [locale_charset is available]) + else + echo '*** Your system has neither nl_langinfo nor locale_charset.' + echo '*** Please install libcharset which is part of libiconv' + echo '*** available at http://www.gnu.org/software/libiconv/' + exit 1 + fi + fi +fi dnl dnl Check for libogg diff --git a/src/common/common.cpp b/src/common/common.cpp index dbd82eeff..1e68c3447 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -21,9 +21,11 @@ #include #include #if defined(COMP_MSC) -#include -#elif !defined(COMP_MINGW) -#include +# include +#elif HAVE_NL_LANGINFO +# include +#elif HAVE_LOCALE_CHARSET +# include #endif #include #include @@ -40,8 +42,8 @@ #include #endif #include -#include #if defined(SYS_WINDOWS) +#include #include #endif @@ -466,8 +468,10 @@ get_local_charset() { lc_charset = nl_langinfo(CODESET); if (parse_int(lc_charset, i)) lc_charset = string("ISO") + lc_charset + string("-US"); -#else +#elif HAVE_NL_LANGINFO lc_charset = nl_langinfo(CODESET); +#elif HAVE_LOCALE_CHARSET + lc_charset = locale_charset(); #endif return lc_charset; diff --git a/src/common/commonebml.cpp b/src/common/commonebml.cpp index 0df892a66..4b46c6e64 100644 --- a/src/common/commonebml.cpp +++ b/src/common/commonebml.cpp @@ -16,9 +16,11 @@ #include "os.h" #if defined(COMP_MSC) -#include -#elif !defined(COMP_MINGW) -#include +# include +#elif HAVE_NL_LANGINFO +# include +#elif HAVE_LOCALE_CHARSET +# include #endif #if defined(SYS_WINDOWS) #include diff --git a/src/extract/cuesheets.cpp b/src/extract/cuesheets.cpp index 53b56703c..430dbd68d 100644 --- a/src/extract/cuesheets.cpp +++ b/src/extract/cuesheets.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #if defined(COMP_MSC) #include