#if !defined(wxVsnprintf_)
+#if !wxUSE_WXVSNPRINTF
+ #error wxUSE_WXVSNPRINTF must be 1 if our wxVsnprintf_ is used
+#endif
+
// wxUSE_STRUTILS says our wxVsnprintf_ implementation to use or not to
// use wxStrlen and wxStrncpy functions over one-char processing loops.
//
wxPAT_INT, // %d, %i, %o, %u, %x, %X
wxPAT_LONGINT, // %ld, etc
-#if SIZEOF_LONG_LONG
+#ifdef wxLongLong_t
wxPAT_LONGLONGINT, // %Ld, etc
#endif
wxPAT_SIZET, // %Zd, etc
typedef union {
int pad_int; // %d, %i, %o, %u, %x, %X
long int pad_longint; // %ld, etc
-#if SIZEOF_LONG_LONG
- long long int pad_longlongint; // %Ld, etc
+#ifdef wxLongLong_t
+ wxLongLong_t pad_longlongint; // %Ld, etc
#endif
size_t pad_sizet; // %Zd, etc
// temporary parse data
size_t flagofs = 1;
- bool in_prec, prec_dot;
+ bool in_prec, // true if we found the dot in some previous iteration
+ prec_dot; // true if the dot has been already added to m_szFlags
int ilen = 0;
m_bAlignLeft = in_prec = prec_dot = false;
CHECK_PREC
m_szFlags[flagofs++] = char(ch);
break;
+#ifdef __WXMSW__
+ // under Windows we support the special '%I64' notation as longlong
+ // integer conversion specifier for MSVC compatibility
+ // (it behaves exactly as '%lli' or '%Li' or '%qi')
+ case wxT('I'):
+ if (*(m_pArgEnd+1) != wxT('6') ||
+ *(m_pArgEnd+2) != wxT('4'))
+ return false; // bad format
+
+ m_pArgEnd++;
+ m_pArgEnd++;
+
+ ilen = 2;
+ CHECK_PREC
+ m_szFlags[flagofs++] = char(ch);
+ m_szFlags[flagofs++] = '6';
+ m_szFlags[flagofs++] = '4';
+ break;
+#endif // __WXMSW__
case wxT('Z'):
ilen = 3;
else if (ilen == 1)
m_type = wxPAT_LONGINT;
else if (ilen == 2)
-#if SIZEOF_LONG_LONG
+#ifdef wxLongLong_t
m_type = wxPAT_LONGLONGINT;
-#else // !long long
+#else // !wxLongLong_t
m_type = wxPAT_LONGINT;
-#endif // long long/!long long
+#endif // wxLongLong_t/!wxLongLong_t
else if (ilen == 3)
m_type = wxPAT_SIZET;
done = true;
case wxPAT_LONGINT:
p->pad_longint = va_arg(argptr, long int);
break;
-#if SIZEOF_LONG_LONG
+#ifdef wxLongLong_t
case wxPAT_LONGLONGINT:
- p->pad_longlongint = va_arg(argptr, long long int);
+ p->pad_longlongint = va_arg(argptr, wxLongLong_t);
break;
-#endif
+#endif // wxLongLong_t
case wxPAT_SIZET:
p->pad_sizet = va_arg(argptr, size_t);
break;
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longint);
break;
-#if SIZEOF_LONG_LONG
+#ifdef wxLongLong_t
case wxPAT_LONGLONGINT:
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longlongint);
break;
{
case wxPAT_INT:
case wxPAT_LONGINT:
-#if SIZEOF_LONG_LONG
+#ifdef wxLongLong_t
case wxPAT_LONGLONGINT:
#endif
case wxPAT_SIZET:
va_end(ap);
// something failed while loading arguments from the variable list...
+ // (e.g. the user repeated twice the same positional argument)
if (!ok)
{
buf[0] = 0;
if (lenCur == lenMax)
{
buf[lenMax - 1] = 0;
- return -1;
+ return lenMax+1; // not enough space in the output buffer !
}
// process this specifier directly in the output buffer
if (n == -1)
{
buf[lenMax-1] = wxT('\0'); // be sure to always NUL-terminate the string
- return -1; // not enough space in the output buffer !
+ return lenMax+1; // not enough space in the output buffer !
}
lenCur += n;
if (buf[lenCur])
{
buf[lenCur] = 0;
- return -1;
+ return lenMax+1; // not enough space in the output buffer !
}
wxASSERT(lenCur == wxStrlen(buf));
#undef APPEND_STR
#undef CHECK_PREC
-#endif // !wxVsnprintfA
+#else // wxVsnprintf_ is defined
+
+#if wxUSE_WXVSNPRINTF
+ #error wxUSE_WXVSNPRINTF must be 0 if our wxVsnprintf_ is not used
+#endif
+
+#endif // !wxVsnprintf_
#if !defined(wxSnprintf_)
int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
#ifdef wxNEED_FPUTS
int wxFputs(const wchar_t *ws, FILE *stream)
{
+ wxCharBuffer buf(wxConvLibc.cWC2MB(ws));
+ if ( !buf )
+ return -1;
+
// counting the number of wide characters written isn't worth the trouble,
// simply distinguish between ok and error
- return fputs(wxConvLibc.cWC2MB(ws), stream) == -1 ? -1 : 0;
+ return fputs(buf, stream) == -1 ? -1 : 0;
}
#endif // wxNEED_FPUTS