Fix broken escape sequence parsing after octal/hex escape
The parser code just added the first character after an octal/hex sequence as raw text, resulting in erroneous data whenever another escape sequence follows directly after.
This commit is contained in:
@@ -961,6 +961,32 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
void parse(const char_type t_char, const int line, const int col, const std::string &filename) {
|
||||
const bool is_octal_char = t_char >= '0' && t_char <= '7';
|
||||
|
||||
if (is_octal) {
|
||||
if (is_octal_char) {
|
||||
octal_matches.push_back(t_char);
|
||||
|
||||
if (octal_matches.size() == 3) {
|
||||
process_octal();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
process_octal();
|
||||
}
|
||||
} else if (is_hex) {
|
||||
const bool is_hex_char = (t_char >= '0' && t_char <= '9')
|
||||
|| (t_char >= 'a' && t_char <= 'f')
|
||||
|| (t_char >= 'A' && t_char <= 'F');
|
||||
|
||||
if (is_hex_char) {
|
||||
hex_matches.push_back(t_char);
|
||||
return;
|
||||
} else {
|
||||
process_hex();
|
||||
}
|
||||
}
|
||||
|
||||
if (t_char == '\\') {
|
||||
if (is_escaped) {
|
||||
match.push_back('\\');
|
||||
@@ -970,31 +996,7 @@ namespace chaiscript
|
||||
}
|
||||
} else {
|
||||
if (is_escaped) {
|
||||
const bool is_octal_char = t_char >= '0' && t_char <= '7';
|
||||
|
||||
if (is_octal) {
|
||||
if (is_octal_char) {
|
||||
octal_matches.push_back(t_char);
|
||||
|
||||
if (octal_matches.size() == 3) {
|
||||
process_octal();
|
||||
}
|
||||
} else {
|
||||
process_octal();
|
||||
match.push_back(t_char);
|
||||
}
|
||||
} else if (is_hex) {
|
||||
const bool is_hex_char = (t_char >= '0' && t_char <= '9')
|
||||
|| (t_char >= 'a' && t_char <= 'f')
|
||||
|| (t_char >= 'A' && t_char <= 'F');
|
||||
|
||||
if (is_hex_char) {
|
||||
hex_matches.push_back(t_char);
|
||||
} else {
|
||||
process_hex();
|
||||
match.push_back(t_char);
|
||||
}
|
||||
} else if (is_octal_char) {
|
||||
if (is_octal_char) {
|
||||
is_octal = true;
|
||||
octal_matches.push_back(t_char);
|
||||
} else if (t_char == 'x') {
|
||||
|
Reference in New Issue
Block a user