| 620 | // The position of the first % character of the next nontrivial format spec is |
| 621 | // returned, or the end of string. |
| 622 | inline const char* printFormatStringLiteral(std::ostream& out, const char* fmt) |
| 623 | { |
| 624 | const char* c = fmt; |
| 625 | for (;; ++c) { |
| 626 | if (*c == '\0') { |
| 627 | out.write(fmt, c - fmt); |
| 628 | return c; |
| 629 | } |
| 630 | else if (*c == '%') { |
| 631 | out.write(fmt, c - fmt); |
| 632 | if (*(c+1) != '%') |
| 633 | return c; |
| 634 | // for "%%", tack trailing % onto next literal section. |
| 635 | fmt = ++c; |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | |
| 641 | // Parse a format string and set the stream state accordingly. |