projects
/
yosys.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4746ffd
)
frontend: json: parse negative values
author
Karol Gugala
<kgugala@antmicro.com>
Wed, 27 Jan 2021 19:34:00 +0000
(20:34 +0100)
committer
Marcelina KoĆcielnicka
<mwk@0x04.net>
Mon, 22 Feb 2021 23:26:11 +0000
(
00:26
+0100)
Signed-off-by: Karol Gugala <kgugala@antmicro.com>
frontends/json/jsonparse.cc
patch
|
blob
|
history
diff --git
a/frontends/json/jsonparse.cc
b/frontends/json/jsonparse.cc
index 1b34aaf3af7421bc841cab59d74749e116ba5653..312f6d3be505069021b7039258746b5077b2d4dc 100644
(file)
--- a/
frontends/json/jsonparse.cc
+++ b/
frontends/json/jsonparse.cc
@@
-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;