frontend: json: parse negative values

Signed-off-by: Karol Gugala <kgugala@antmicro.com>
This commit is contained in:
Karol Gugala 2021-01-27 20:34:00 +01:00 committed by Marcelina Kościelnicka
parent 4746ffd7b2
commit cc7d18d29a
1 changed files with 10 additions and 2 deletions

View File

@ -72,10 +72,17 @@ struct JsonNode
break;
}
if ('0' <= ch && ch <= '9')
if (('0' <= ch && ch <= '9') || ch == '-')
{
bool negative = false;
type = 'N';
data_number = ch - '0';
if (ch == '-') {
data_number = 0;
negative = true;
} else {
data_number = ch - '0';
}
data_string += ch;
while (1)
@ -97,6 +104,7 @@ struct JsonNode
data_string += ch;
}
data_number = negative ? -data_number : data_number;
data_string = "";
break;