diff options
Diffstat (limited to 'boot/driver.cc')
| -rw-r--r-- | boot/driver.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/boot/driver.cc b/boot/driver.cc index 374bcc9..24a11fa 100644 --- a/boot/driver.cc +++ b/boot/driver.cc @@ -66,6 +66,29 @@ namespace elna::boot } } + void normalize_newlines(std::string& string) + { + std::string result; + auto length = string.size(); + + for (std::size_t i = 0; i < length; ++i) + { + if (string[i] == '\r') + { + if (i + 1 < length && string[i + 1] == '\n') + { + ++i; // Skip \n in \r\n pairs. + } + result.push_back('\n'); + } + else + { + result.push_back(string[i]); + } + } + string = std::move(result); + } + std::optional<std::string> escape_string(const char *escape) { std::string result; @@ -73,7 +96,7 @@ namespace elna::boot while (*current_position != '\0') { - if (*current_position == '\\' && *(current_position + 1) == 'x') + if (*current_position == '\\' && (*(current_position + 1) == 'x' || *(current_position + 1) == 'X')) { current_position += 2; |
