| 160 | } |
| 161 | |
| 162 | std::string convert_line_separator(const std::string& input, const std::string& line_sep) { |
| 163 | constexpr char CR = '\r'; |
| 164 | constexpr char LF = '\n'; |
| 165 | const auto length = input.length(); |
| 166 | |
| 167 | std::string result; |
| 168 | for (size_t i = 0; i < length; i++) { |
| 169 | const auto cur = input[i]; |
| 170 | if (cur == LF) { |
| 171 | result += line_sep; |
| 172 | } else if (cur == CR) { |
| 173 | const auto next = input[i + 1]; |
| 174 | if (next == LF) { |
| 175 | result += line_sep; |
| 176 | i++; |
| 177 | } else { |
| 178 | result += line_sep; |
| 179 | } |
| 180 | } else { |
| 181 | result += cur; |
| 182 | } |
| 183 | } |
| 184 | return result; |
| 185 | } |
no outgoing calls
no test coverage detected