X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f2bbe5b675f073fc6f7c6b249f6c5f480a17f027..855f31ebe72bef834a32df2c274b41fb282ad265:/src/common/wxchar.cpp diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 8176058d0d..cf4e0a5be5 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -217,7 +217,7 @@ enum wxPrintfArgType { 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 @@ -242,8 +242,8 @@ enum wxPrintfArgType { 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 @@ -351,7 +351,8 @@ bool wxPrintfConvSpec::Parse(const wxChar *format) // 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; @@ -421,6 +422,25 @@ bool wxPrintfConvSpec::Parse(const wxChar *format) 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; @@ -512,11 +532,11 @@ bool wxPrintfConvSpec::Parse(const wxChar *format) 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; @@ -682,11 +702,11 @@ bool wxPrintfConvSpec::LoadArg(wxPrintfArg *p, va_list &argptr) 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; @@ -766,7 +786,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t 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; @@ -932,7 +952,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p, size_t { case wxPAT_INT: case wxPAT_LONGINT: -#if SIZEOF_LONG_LONG +#ifdef wxLongLong_t case wxPAT_LONGLONGINT: #endif case wxPAT_SIZET: @@ -1179,7 +1199,11 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax, return lenMax+1; // not enough space in the output buffer ! } - wxASSERT(lenCur == wxStrlen(buf)); + // Don't do: + // wxASSERT(lenCur == wxStrlen(buf)); + // in fact if we embedded NULLs in the output buffer (using %c with a '\0') + // such check would fail + return lenCur; }