Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
7585-json-Fix-missed-integer-callback-for-zero....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7585-json-Fix-missed-integer-callback-for-zero.patch of Package erlang
From 401d5d9b3a539006f20920c03100a50fa9c35c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muska=C5=82a?= <michal@muskala.eu> Date: Fri, 14 Jun 2024 19:22:34 +0200 Subject: [PATCH] [json] Fix missed integer callback for zero --- lib/stdlib/src/json.erl | 6 ++++-- lib/stdlib/test/json_SUITE.erl | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/stdlib/src/json.erl b/lib/stdlib/src/json.erl index 34d39fa128..971b5bf16a 100644 --- a/lib/stdlib/src/json.erl +++ b/lib/stdlib/src/json.erl @@ -828,9 +828,11 @@ number_zero(<<$., Rest/bits>>, Original, Skip, Acc, Stack, Decode, Len) -> number_zero(<<E, Rest/bits>>, Original, Skip, Acc, Stack, Decode, Len) when E =:= $E; E =:= $e -> number_exp_copy(Rest, Original, Skip, Acc, Stack, Decode, Len + 1, <<"0">>); number_zero(<<>>, Original, Skip, Acc, Stack, Decode, Len) -> - unexpected(Original, Skip, Acc, Stack, Decode, Len, 0, {number, 0}); + Value = (Decode#decode.integer)(<<"0">>), + unexpected(Original, Skip, Acc, Stack, Decode, Len, 0, {number, Value}); number_zero(Rest, Original, Skip, Acc, Stack, Decode, Len) -> - continue(Rest, Original, Skip+Len, Acc, Stack, Decode, 0). + Value = (Decode#decode.integer)(<<"0">>), + continue(Rest, Original, Skip+Len, Acc, Stack, Decode, Value). number(<<Num, Rest/bits>>, Original, Skip, Acc, Stack, Decode, Len) when ?is_0_to_9(Num) -> number(Rest, Original, Skip, Acc, Stack, Decode, Len + 1); diff --git a/lib/stdlib/test/json_SUITE.erl b/lib/stdlib/test/json_SUITE.erl index 6c4c5e13d6..23d0bf52a9 100644 --- a/lib/stdlib/test/json_SUITE.erl +++ b/lib/stdlib/test/json_SUITE.erl @@ -478,10 +478,10 @@ test_decode_api(_Config) -> null => nil }, - Data = <<"{\"a\": [[], {}, true, false, null, {\"foo\": \"baz\"}], \"b\": [1, 2.0, \"three\"]}">>, + Data = <<"{\"a\": [[], {}, true, false, null, {\"foo\": \"baz\"}], \"b\": [1, 2.0, \"three\", 0]}">>, {Decoded, Acc, <<>>} = json:decode(Data, {[], 0}, Decoders), - ?assertEqual({[], 24}, Acc), - Expected = #{a => [[], #{}, true, false, nil, #{foo => baz}], b => [1, 2.0, three]}, + ?assertEqual({[], 25}, Acc), + Expected = #{a => [[], #{}, true, false, nil, #{foo => baz}], b => [1, 2.0, three, 0]}, ?assertEqual(Expected, Decoded), ExpectedHistory = [ @@ -519,13 +519,15 @@ test_decode_api(_Config) -> {array_push, {2.0, {[1], 19}}, {[2.0, 1], 20}}, {string, <<"three">>, three}, {array_push, {three, {[2.0, 1], 20}}, {[three, 2.0, 1], 21}}, - {array_finish, {{[three, 2.0, 1], 21}, {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 17}}, - {[1, 2.0, three], {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 22}}}, - {object_push, {b, [1, 2.0, three], {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 22}}, { - [{b, [1, 2.0, three]}, {a, [[], #{}, true, false, nil, #{foo => baz}]}], 23 + {integer, <<"0">>, 0}, + {array_push, {0, {[three, 2.0, 1], 21}}, {[0, three, 2.0, 1], 22}}, + {array_finish, {{[0, three, 2.0, 1], 22}, {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 17}}, + {[1, 2.0, three, 0], {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 23}}}, + {object_push, {b, [1, 2.0, three, 0], {[{a, [[], #{}, true, false, nil, #{foo => baz}]}], 23}}, { + [{b, [1, 2.0, three, 0]}, {a, [[], #{}, true, false, nil, #{foo => baz}]}], 24 }}, - {object_finish, {{[{b, [1, 2.0, three]}, {a, [[], #{}, true, false, nil, #{foo => baz}]}], 23}, {[], 0}}, - {#{a => [[], #{}, true, false, nil, #{foo => baz}], b => [1, 2.0, three]}, {[], 24}}} + {object_finish, {{[{b, [1, 2.0, three, 0]}, {a, [[], #{}, true, false, nil, #{foo => baz}]}], 24}, {[], 0}}, + {#{a => [[], #{}, true, false, nil, #{foo => baz}], b => [1, 2.0, three, 0]}, {[], 25}}} ], ?assertEqual(ExpectedHistory, lists:reverse(get(history))). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor