From cbbe1593bb0893654bd71e611ca610df03bac768 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 20 Jul 2026 12:26:29 +0200 Subject: Add newlines a tabs to supported string characters --- boot/driver.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'boot/driver.cc') 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 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; -- cgit v1.2.3