MCPcopy Create free account
hub / github.com/Koihik/LuaFormatter / convert_line_separator

Function convert_line_separator

src/lua-format.cpp:162–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162std::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}

Callers 2

handleLineSeparatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected