| 612 | } |
| 613 | |
| 614 | bool gnprintf(char *buffer, |
| 615 | size_t maxlen, |
| 616 | const char *format, |
| 617 | IPhraseCollection *pPhrases, |
| 618 | void **params, |
| 619 | unsigned int numparams, |
| 620 | unsigned int &curparam, |
| 621 | size_t *pOutLength, |
| 622 | const char **pFailPhrase) |
| 623 | { |
| 624 | if (!buffer || !maxlen) |
| 625 | { |
| 626 | if (pOutLength != NULL) |
| 627 | { |
| 628 | *pOutLength = 0; |
| 629 | } |
| 630 | return true; |
| 631 | } |
| 632 | |
| 633 | if (numparams > MAX_TRANSLATE_PARAMS) |
| 634 | { |
| 635 | if (pFailPhrase != NULL) |
| 636 | { |
| 637 | *pFailPhrase = NULL; |
| 638 | } |
| 639 | return false; |
| 640 | } |
| 641 | |
| 642 | int arg = 0; |
| 643 | char *buf_p; |
| 644 | char ch; |
| 645 | int flags; |
| 646 | int width; |
| 647 | int prec; |
| 648 | int n; |
| 649 | char sign; |
| 650 | const char *fmt; |
| 651 | size_t llen = maxlen - 1; |
| 652 | |
| 653 | buf_p = buffer; |
| 654 | fmt = format; |
| 655 | |
| 656 | while (true) |
| 657 | { |
| 658 | // run through the format string until we hit a '%' or '\0' |
| 659 | for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++) |
| 660 | { |
| 661 | *buf_p++ = ch; |
| 662 | llen--; |
| 663 | } |
| 664 | if ((ch == '\0') || (llen <= 0)) |
| 665 | { |
| 666 | goto done; |
| 667 | } |
| 668 | |
| 669 | // skip over the '%' |
| 670 | fmt++; |
| 671 |
no test coverage detected