| 610 | // The position of the first % character of the next nontrivial format spec is |
| 611 | // returned, or the end of string. |
| 612 | inline const char* printFormatStringLiteral(std::ostream& out, const char* fmt) |
| 613 | { |
| 614 | const char* c = fmt; |
| 615 | for (;; ++c) { |
| 616 | if (*c == '\0') { |
| 617 | out.write(fmt, c - fmt); |
| 618 | return c; |
| 619 | } |
| 620 | else if (*c == '%') { |
| 621 | out.write(fmt, c - fmt); |
| 622 | if (*(c+1) != '%') |
| 623 | return c; |
| 624 | // for "%%", tack trailing % onto next literal section. |
| 625 | fmt = ++c; |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | |
| 631 | // Parse a format string and set the stream state accordingly. |