vvp: Remove null-bytes when converting string literals to SV strings

The `%pushi/str` and `%concati/str` instructions should remove null-bytes
from the string literal when converting it to a string. This is defined in
section 6.16 ("String data type") of the LRM (1800-2017).

This is already handled correctly when converting a vector from the stack
to a SV string, just not when converting a string literal to SV string.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-01-01 18:46:17 -08:00
parent 23e51ef7a8
commit 4ddf234c32
1 changed files with 5 additions and 1 deletions

View File

@ -399,7 +399,11 @@ static string filter_string(const char*text)
cnt -= 1;
ptr += 1;
}
tmp[dst++] = byte;
// null-bytes are supposed to be removed when assigning a string
// literal to a string.
if (byte != '\0')
tmp[dst++] = byte;
// After the while loop above, the ptr points to the next character,
// but the for-loop condition is assuming that ptr points to the last