[ 1517666 ] suppression of wxVsnprintf() warnings - with little extensions.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -186,7 +186,7 @@ bool WXDLLEXPORT wxOKlibc()
|
||||
#define wxMAX_SVNPRINTF_ARGUMENTS 64
|
||||
#define wxMAX_SVNPRINTF_FLAGBUFFER_LEN 32
|
||||
|
||||
// the conversion specifiers accepted by wxMyPosVsnprintf_
|
||||
// the conversion specifiers accepted by wxVsnprintf_
|
||||
enum wxPrintfArgType {
|
||||
wxPAT_INVALID = -1,
|
||||
|
||||
@@ -213,7 +213,7 @@ enum wxPrintfArgType {
|
||||
wxPAT_NLONGINT // %ln
|
||||
};
|
||||
|
||||
// an argument passed to wxMyPosVsnprintf_
|
||||
// an argument passed to wxVsnprintf_
|
||||
typedef union {
|
||||
int pad_int; // %d, %i, %o, %u, %x, %X
|
||||
long int pad_longint; // %ld, etc
|
||||
@@ -240,7 +240,7 @@ typedef union {
|
||||
|
||||
|
||||
// Contains parsed data relative to a conversion specifier given to
|
||||
// wxMyPosVsnprintf_ and parsed from the format string
|
||||
// wxVsnprintf_ and parsed from the format string
|
||||
// NOTE: in C++ there is almost no difference between struct & classes thus
|
||||
// there is no performance gain by using a struct here...
|
||||
class wxPrintfConvSpec
|
||||
@@ -274,13 +274,16 @@ public:
|
||||
|
||||
// a little buffer where formatting flags like #+\.hlqLZ are stored by Parse()
|
||||
// for use in Process()
|
||||
// NB: this buffer can be safely a char buffer instead of a wchar_t buffer
|
||||
// since it's used only for numeric conversion specifier and always
|
||||
// with sprintf().
|
||||
char szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN];
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// we don't declare this as a constructor otherwise it would be called
|
||||
// automatically and we don't want this: to be optimized, wxMyPosVsnprintf_
|
||||
// automatically and we don't want this: to be optimized, wxVsnprintf_
|
||||
// calls this function only on really-used instances of this class.
|
||||
void Init();
|
||||
|
||||
@@ -310,7 +313,10 @@ void wxPrintfConvSpec::Init()
|
||||
adj_left = false;
|
||||
argpos = argend = NULL;
|
||||
type = wxPAT_INVALID;
|
||||
szFlags[0] = wxT('%');
|
||||
|
||||
// this character will never be removed from szFlags array and
|
||||
// is important when calling sprintf() in wxPrintfConvSpec::Process() !
|
||||
szFlags[0] = '%';
|
||||
}
|
||||
|
||||
bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
@@ -329,7 +335,7 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
#define CHECK_PREC \
|
||||
if (in_prec && !prec_dot) \
|
||||
{ \
|
||||
szFlags[flagofs++] = '.'; \
|
||||
szFlags[flagofs++] = (char)'.'; \
|
||||
prec_dot = true; \
|
||||
}
|
||||
|
||||
@@ -349,13 +355,13 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
case wxT('+'):
|
||||
case wxT('\''):
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('-'):
|
||||
CHECK_PREC
|
||||
adj_left = true;
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('.'):
|
||||
@@ -370,26 +376,26 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
case wxT('h'):
|
||||
ilen = -1;
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('l'):
|
||||
ilen = 1;
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('q'):
|
||||
case wxT('L'):
|
||||
ilen = 2;
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('Z'):
|
||||
ilen = 3;
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('*'):
|
||||
@@ -410,7 +416,7 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
|
||||
// save the * in our formatting buffer...
|
||||
// will be replaced later by Process()
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
break;
|
||||
|
||||
case wxT('1'): case wxT('2'): case wxT('3'):
|
||||
@@ -422,7 +428,7 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
while ( (*argend >= wxT('0')) &&
|
||||
(*argend <= wxT('9')) )
|
||||
{
|
||||
szFlags[flagofs++] = *argend;
|
||||
szFlags[flagofs++] = (char)(*argend);
|
||||
len = len*10 + (*argend - wxT('0'));
|
||||
argend++;
|
||||
}
|
||||
@@ -464,8 +470,8 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
case wxT('x'):
|
||||
case wxT('X'):
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs] = '\0';
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
szFlags[flagofs] = (char)'\0';
|
||||
if (ilen == 0)
|
||||
type = wxPAT_INT;
|
||||
else if (ilen == -1)
|
||||
@@ -492,8 +498,8 @@ bool wxPrintfConvSpec::Parse(const wxChar *format)
|
||||
case wxT('g'):
|
||||
case wxT('G'):
|
||||
CHECK_PREC
|
||||
szFlags[flagofs++] = ch;
|
||||
szFlags[flagofs] = '\0';
|
||||
szFlags[flagofs++] = (char)ch;
|
||||
szFlags[flagofs] = (char)'\0';
|
||||
if (ilen == 2)
|
||||
type = wxPAT_LONGDOUBLE;
|
||||
else
|
||||
@@ -652,10 +658,10 @@ bool wxPrintfConvSpec::LoadArg(wxPrintfArg *p, va_list &argptr)
|
||||
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 = va_arg(argptr, int); // char is promoted to int when passed through '...'
|
||||
p->pad_wchar = (wchar_t)va_arg(argptr, int); // char is promoted to int when passed through '...'
|
||||
break;
|
||||
|
||||
case wxPAT_PCHAR:
|
||||
@@ -853,7 +859,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
|
||||
break;
|
||||
|
||||
case wxPAT_NSHORTINT:
|
||||
*p->pad_nshortint = lenCur;
|
||||
*p->pad_nshortint = (short int)lenCur;
|
||||
break;
|
||||
|
||||
case wxPAT_NLONGINT:
|
||||
|
Reference in New Issue
Block a user