311 return strncmp (chars(), other.chars(), other.length()) == 0; |
310 return strncmp (chars(), other.chars(), other.length()) == 0; |
312 } |
311 } |
313 |
312 |
314 // ------------------------------------------------------------------------------------------------- |
313 // ------------------------------------------------------------------------------------------------- |
315 // |
314 // |
316 void String::sprintf (const char* fmtstr, ...) |
315 void __cdecl String::sprintf (const char* fmtstr, ...) |
|
316 { |
|
317 va_list args; |
|
318 va_start (args, fmtstr); |
|
319 this->vsprintf (fmtstr, args); |
|
320 va_end (args); |
|
321 } |
|
322 |
|
323 // ------------------------------------------------------------------------------------------------- |
|
324 // |
|
325 void String::vsprintf (const char* fmtstr, va_list args) |
317 { |
326 { |
318 char* buf = nullptr; |
327 char* buf = nullptr; |
319 int bufsize = 256; |
328 int bufsize = 256; |
320 va_list va; |
|
321 va_start (va, fmtstr); |
|
322 |
329 |
323 do |
330 do |
324 { |
331 { |
|
332 bufsize *= 2; |
325 delete[] buf; |
333 delete[] buf; |
326 buf = new char[bufsize]; |
334 buf = new char[bufsize]; |
327 } |
335 } |
328 while (vsnprintf (buf, bufsize, fmtstr, va) >= bufsize); |
336 while (vsnprintf (buf, bufsize, fmtstr, args) >= bufsize); |
329 |
337 |
330 va_end (va); |
|
331 m_string = buf; |
338 m_string = buf; |
332 delete[] buf; |
339 delete[] buf; |
333 } |
340 } |
334 |
341 |
335 // ------------------------------------------------------------------------------------------------- |
342 // ------------------------------------------------------------------------------------------------- |