summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-10-23 22:08:07 +1100
committerMaxime Coste <mawww@kakoune.org>2019-10-23 22:08:07 +1100
commitdb2db951c39154dc7256efeb55bff4c6a4202dd6 (patch)
tree991b960bd3ebe7415a2a4f7ce817787c665eb914 /src
parentc792986768a2f3d42fc6113fb8b5459fdbf5a0fc (diff)
Only allow minus at the begining of json numbers
Diffstat (limited to 'src')
-rw-r--r--src/json_ui.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/json_ui.cc b/src/json_ui.cc
index a0294f3e..f4f39b84 100644
--- a/src/json_ui.cc
+++ b/src/json_ui.cc
@@ -257,7 +257,7 @@ void JsonUI::set_on_key(OnKeyCallback callback)
using JsonArray = Vector<Value>;
using JsonObject = HashMap<String, Value>;
-static bool is_digit_or_minus(char c) { return (c >= '0' and c <= '9') or c == '-'; }
+static bool is_digit(char c) { return c >= '0' and c <= '9'; }
struct JsonResult { Value value; const char* new_pos; };
@@ -266,10 +266,10 @@ JsonResult parse_json(const char* pos, const char* end)
if (not skip_while(pos, end, is_blank))
return {};
- if (is_digit_or_minus(*pos))
+ if (is_digit(*pos) or *pos == '-')
{
- auto digit_end = pos;
- skip_while(digit_end, end, is_digit_or_minus);
+ auto digit_end = pos + 1;
+ skip_while(digit_end, end, is_digit);
return { Value{str_to_int({pos, digit_end})}, digit_end };
}
if (end - pos > 4 and StringView{pos, pos+4} == "true")