aboutsummaryrefslogtreecommitdiff
path: root/boot/driver.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-20 12:26:29 +0200
committerEugen Wissner <belka@caraus.de>2026-07-20 13:33:08 +0200
commitcbbe1593bb0893654bd71e611ca610df03bac768 (patch)
tree9a2db686e108f4eb42bae1b9fde801c52349a355 /boot/driver.cc
parent38dc185ec0c6c010b2f2bbb06f52e41391c33194 (diff)
downloadelna-cbbe1593bb0893654bd71e611ca610df03bac768.tar.gz
Add newlines a tabs to supported string characters
Diffstat (limited to 'boot/driver.cc')
-rw-r--r--boot/driver.cc25
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;