#pragma hdrstop
#endif
+#include "wx/wxchar.h"
+
#define _ISOC9X_SOURCE 1 // to get vsscanf()
#define _BSD_SOURCE 1 // to still get strdup()
#endif
#ifndef WX_PRECOMP
- #include "wx/wxchar.h"
#include "wx/string.h"
#include "wx/hash.h"
+ #include "wx/utils.h" // for wxMin and wxMax
+ #include "wx/log.h"
#endif
- #include "wx/utils.h" // for wxMin and wxMax
#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
#include <windef.h>
// result in an endless recursion and thus in a stack overflow
#if wxUSE_UNICODE
- #if defined(__WXWINCE__) || ( defined(__VISUALC__) && __VISUALC__ <= 1200 )
+ #if defined(__WINDOWS__)
+ // all compilers under Windows should have swprintf()
+ #define HAVE_SWPRINTF
+ #endif
+
+ // NB: MSVC 6 has only non-standard swprintf() declaration and while MSVC 7
+ // and 7.1 do have the standard one, it's completely broken unless
+ // /Zc:wchar_t is used while the other one works so use it instead, and
+ // only VC8 has a working standard-compliant swprintf()
+ #if defined(__WXWINCE__) || \
+ (defined(__VISUALC__) && __VISUALC__ < 1400) || \
+ defined(__GNUWIN32__) || \
+ defined(__BORLANDC__)
#define HAVE_BROKEN_SWPRINTF_DECL
#endif
#define CHECK_PREC \
if (in_prec && !prec_dot) \
{ \
- m_szFlags[flagofs++] = '.'; \
+ m_szFlags[flagofs++] = wxT('.'); \
prec_dot = true; \
}
case wxT('X'):
CHECK_PREC
m_szFlags[flagofs++] = ch;
- m_szFlags[flagofs] = '\0';
+ m_szFlags[flagofs] = wxT('\0');
if (ilen == 0)
m_type = wxPAT_INT;
else if (ilen == -1)
case wxT('G'):
CHECK_PREC
m_szFlags[flagofs++] = ch;
- m_szFlags[flagofs] = '\0';
+ m_szFlags[flagofs] = wxT('\0');
if (ilen == 2)
m_type = wxPAT_LONGDOUBLE;
else
int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) / sizeof(wxChar);
int offset = system_sprintf(pwidth, maxlen, wxT("%d"), abs(width));
+#ifdef HAVE_BROKEN_SWPRINTF_DECL
+ wxUnusedVar(maxlen); // avoid dummy warnings
+#endif
+
// restore after the expanded * what was following it
wxStrcpy(pwidth+offset, temp);
}
break;
case wxPAT_CHAR:
- p->pad_char = va_arg(argptr, int); // char is promoted to int when passed through '...'
+ p->pad_char = (char)va_arg(argptr, int); // char is promoted to int when passed through '...'
break;
case wxPAT_WCHAR:
p->pad_wchar = (wchar_t)va_arg(argptr, int); // char is promoted to int when passed through '...'
return -1;
}
+#ifdef HAVE_BROKEN_SWPRINTF_DECL
+ wxUnusedVar(lenScratch); // avoid dummy warnings
+#endif
+
// if we used system's sprintf() then we now need to append the s_szScratch
// buffer to the given one...
switch (m_type)