for ( ;; )
{
wxStringBuffer tmp(*this, size + 1);
- wxChar* buf = tmp;
+ wxChar *buf = tmp;
if ( !buf )
{
// vsnprintf() may return either -1 (traditional Unix behaviour) or the
// total number of characters which would have been written if the
// buffer were large enough (newer standards such as Unix98)
- if ( len >= 0 && len <= size )
+ if ( len < 0 )
+ {
+ // still not enough, as we don't know how much we need, double the
+ // current size of the buffer
+ size *= 2;
+ }
+ else if ( len > size )
+ {
+ size = len;
+ }
+ else // ok, there was enough space
{
- // ok, there was enough space
break;
}
-
- // still not enough, double it again
- size *= 2;
}
// we could have overshot