| 414 | #endif |
| 415 | |
| 416 | void AbstractString::vprintf(const char* format, va_list params) |
| 417 | { |
| 418 | #ifndef HAVE_VSNPRINTF |
| 419 | #error NS: I am lazy to implement version of this routine based on plain vsprintf. |
| 420 | #error Please find an implementation of vsnprintf function for your platform. |
| 421 | #error For example, consider importing library from http://www.ijs.si/software/snprintf/ |
| 422 | #error to Firebird extern repository |
| 423 | #endif |
| 424 | enum { tempsize = 256 }; |
| 425 | char temp[tempsize]; |
| 426 | va_list paramsCopy; |
| 427 | FB_VA_COPY(paramsCopy, params); |
| 428 | int l = VSNPRINTF(temp, tempsize, format, paramsCopy); |
| 429 | FB_CLOSE_VACOPY(paramsCopy); |
| 430 | if (l < 0) |
| 431 | { |
| 432 | size_type n = sizeof(temp); |
| 433 | while (true) |
| 434 | { |
| 435 | n *= 2; |
| 436 | if (n > getMaxLength()) |
| 437 | n = getMaxLength(); |
| 438 | FB_VA_COPY(paramsCopy, params); |
| 439 | l = VSNPRINTF(baseAssign(n), n + 1, format, paramsCopy); |
| 440 | FB_CLOSE_VACOPY(paramsCopy); |
| 441 | if (l >= 0) |
| 442 | break; |
| 443 | if (n >= getMaxLength()) |
| 444 | { |
| 445 | stringBuffer[getMaxLength()] = 0; |
| 446 | return; |
| 447 | } |
| 448 | } |
| 449 | resize(l); |
| 450 | return; |
| 451 | } |
| 452 | temp[tempsize - 1] = 0; |
| 453 | if (l < tempsize) { |
| 454 | memcpy(baseAssign(l), temp, l); |
| 455 | } |
| 456 | else |
| 457 | { |
| 458 | resize(l); |
| 459 | FB_VA_COPY(paramsCopy, params); |
| 460 | VSNPRINTF(begin(), l + 1, format, paramsCopy); |
| 461 | FB_CLOSE_VACOPY(paramsCopy); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | unsigned int AbstractString::hash(const_pointer string, const size_type tableSize) |
| 466 | { |
no test coverage detected