#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,
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
// 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
// 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();
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)
#define CHECK_PREC \
if (in_prec && !prec_dot) \
{ \
- szFlags[flagofs++] = '.'; \
+ szFlags[flagofs++] = (char)'.'; \
prec_dot = true; \
}
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('.'):
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('*'):
// 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'):
while ( (*argend >= wxT('0')) &&
(*argend <= wxT('9')) )
{
- szFlags[flagofs++] = *argend;
+ szFlags[flagofs++] = (char)(*argend);
len = len*10 + (*argend - wxT('0'));
argend++;
}
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)
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
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:
break;
case wxPAT_NSHORTINT:
- *p->pad_nshortint = lenCur;
+ *p->pad_nshortint = (short int)lenCur;
break;
case wxPAT_NLONGINT: