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