mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Shell: Add support for octal escapes in strings
This adds all three common prefixes (\0, \o and \c).
This commit is contained in:
parent
ce4396d6ff
commit
6adf1be06b
Notes:
sideshowbarker
2024-07-17 07:20:49 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6adf1be06b Pull-request: https://github.com/SerenityOS/serenity/pull/23668
1 changed files with 19 additions and 0 deletions
|
@ -1485,6 +1485,25 @@ RefPtr<AST::Node> Parser::parse_string_inner(StringEndCondition condition)
|
|||
|
||||
break;
|
||||
}
|
||||
case '0':
|
||||
case 'o':
|
||||
case 'c': {
|
||||
auto read_anything = false;
|
||||
u8 byte = 0;
|
||||
auto start = m_offset;
|
||||
while (!at_end() && is_ascii_octal_digit(peek())) {
|
||||
if (byte > 32)
|
||||
break;
|
||||
read_anything = true;
|
||||
byte *= 8;
|
||||
byte += consume() - '0';
|
||||
}
|
||||
if (read_anything)
|
||||
builder.append(byte);
|
||||
else
|
||||
builder.append(m_input.substring_view(start, m_offset - start));
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
builder.append('\a');
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue