mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Fix decoding octal string escapes with 1-2 digits (#6108).
This commit is contained in:
+11
-4
@@ -160,16 +160,18 @@ string VString::unquoteSVString(const string& text, string& errOut) {
|
||||
if (std::isdigit(*cp)) {
|
||||
octal_val = octal_val * 8 + (*cp - '0');
|
||||
if (++octal_digits == 3) {
|
||||
octal_digits = 0;
|
||||
quoted = false;
|
||||
newtext += octal_val;
|
||||
octal_digits = 0;
|
||||
octal_val = 0;
|
||||
quoted = false;
|
||||
}
|
||||
} else {
|
||||
if (octal_digits) {
|
||||
// Spec allows 1-3 digits
|
||||
octal_digits = 0;
|
||||
quoted = false;
|
||||
newtext += octal_val;
|
||||
octal_digits = 0;
|
||||
octal_val = 0;
|
||||
quoted = false;
|
||||
--cp; // Backup to reprocess terminating character as non-escaped
|
||||
continue;
|
||||
}
|
||||
@@ -200,6 +202,11 @@ string VString::unquoteSVString(const string& text, string& errOut) {
|
||||
}
|
||||
}
|
||||
} else if (*cp == '\\') {
|
||||
if (octal_digits) {
|
||||
newtext += octal_val;
|
||||
octal_digits = 0;
|
||||
octal_val = 0;
|
||||
}
|
||||
quoted = true;
|
||||
octal_digits = 0;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user