From d0204feee61d9f62a151f7d08444ab9eb07cfc8d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Feb 2010 11:09:15 +0000 Subject: [PATCH] Compilation fixes for wide char functions under IRIX with mipsPro. Use correct (XPG5, not XPG4) version of wcsftime(). Bring the wide char functions only declared in std namespace into global one under IRIX. Declare vswscanf() ourselves as we just don't seem to get its declaration from C++ code (only from C99). Add a cast to fix incorrect putws() signature. All these fixes apply to IRIX 6.5.18 with mipsPro 7.4.2. It doesn't seem to add configure checks for most of the above fixes as previous versions of both the OS and the compiler should be completely extinct by now but we may need to do it if anybody is still found to use them. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/wxcrtbase.h | 27 +++++++++++++++++++++++---- src/common/wxcrt.cpp | 14 +++++++++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index 81957c596a..f683ab479d 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -643,10 +643,29 @@ WXDLLIMPEXP_BASE wchar_t * wxCRT_GetenvW(const wchar_t *name); ------------------------------------------------------------------------- */ #define wxCRT_StrftimeA strftime -#ifndef __WXPALMOS__ -/* FIXME-UTF8: when is this available? */ -#define wxCRT_StrftimeW wcsftime -#endif /* ! __WXPALMOS__ */ +#ifdef __SGI__ + /* + IRIX provides not one but two versions of wcsftime(): XPG4 one which + uses "const char*" for the third parameter and so can't be used and the + correct, XPG5, one. Unfortunately we can't just define _XOPEN_SOURCE + high enough to get XPG5 version as this undefines other symbols which + make other functions we use unavailable (see for gory + details). So just declare the XPG5 version ourselves, we're extremely + unlikely to ever be compiled on a system without it. But if we ever do, + a configure test would need to be added for it (and _MIPS_SYMBOL_PRESENT + should be used to check for its presence during run-time, i.e. it would + probably be simpler to just always use our own wxCRT_StrftimeW() below + if it does ever become a problem). + */ + extern "C" size_t + _xpg5_wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm * ); + #define wxCRT_StrftimeW _xpg5_wcsftime +#else + #ifndef __WXPALMOS__ + // assume it's always available, this does seem to be the case for now + #define wxCRT_StrftimeW wcsftime + #endif /* ! __WXPALMOS__ */ +#endif #ifndef wxCRT_StrftimeW WXDLLIMPEXP_BASE size_t wxCRT_StrftimeW(wchar_t *s, size_t max, diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 05909433d2..db16fa9b18 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -29,6 +29,16 @@ #include #include #include +#include + +#ifdef __SGI__ + // wide character functions are declared in std namespace under IRIX + using namespace std; + + // and this one is only declared if __c99 is defined which is not the case + // for C++ builds, so declare it ourselves + extern "C" int vswscanf(const wchar_t *, const wchar_t *, va_list); +#endif #ifndef __WXPALMOS5__ #ifndef __WXWINCE__ @@ -1246,9 +1256,11 @@ void wxUpdateLocaleIsUtf8() int wxPuts(const wxString& s) { + // under IRIX putws() takes a non-const argument so use wchar_str() instead + // of wc_str() CALL_ANSI_OR_UNICODE(return, wxCRT_PutsA(s.mb_str()), - wxCRT_PutsW(s.wc_str())); + wxCRT_PutsW(s.wchar_str())); } int wxFputs(const wxString& s, FILE *stream) -- 2.45.2