| 27 | |
| 28 | |
| 29 | void init(TextWriter *ss, string content, FormatOptions options, ProgramPtr program) { |
| 30 | string line; |
| 31 | content.push_back('\n'); // easiest way to flush the last line |
| 32 | for (const auto c: content) { |
| 33 | if (c != '\n') { |
| 34 | line.push_back(c); |
| 35 | } else { |
| 36 | state.content_.emplace_back(das::move(line)); |
| 37 | line.clear(); |
| 38 | } |
| 39 | } |
| 40 | state.ss = ss; |
| 41 | state.enabled = true; |
| 42 | state.last = Pos{1, 0}; |
| 43 | state.program = program; |
| 44 | state.options = das::move(options); |
| 45 | if ((state.content_.empty() || state.content_.front().substr(0, strlen("options gen2")) != "options gen2") && |
| 46 | state.options.contains(FormatOpt::V2Syntax)) { |
| 47 | *state.ss << "options gen2"; |
| 48 | if (state.options.contains(FormatOpt::SemicolonEOL)) { |
| 49 | *state.ss << ";"; |
| 50 | } |
| 51 | *state.ss << "\n"; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void destroy() { |
| 56 | if (!state.content_.empty()) { |
no test coverage detected