yamerl_node_int: Remove base2_to_integer/2 and base16_to_integer/3

This node type doesn't support base 2 or base 60 integers.
This commit is contained in:
Jean-Sébastien Pédron 2016-11-13 16:52:19 +01:00
parent 4454551bfc
commit 91c75e33a3
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC

View File

@ -39,12 +39,14 @@
try_construct_token/3,
construct_token/3,
node_pres/1,
string_to_integer/1,
base2_to_integer/2,
string_to_integer/1
]).
%% Internal use only.
-export([
base8_to_integer/2,
base10_to_integer/2,
base16_to_integer/2,
base60_to_integer/3
base16_to_integer/2
]).
-define(TAG, "tag:yaml.org,2002:int").
@ -128,14 +130,6 @@ base10_to_integer([], Int) ->
base10_to_integer(_, _) ->
error.
base2_to_integer([C | Rest], Int) when C == $0 orelse C == $1 ->
Int1 = (Int * 2) + (C - $0),
base2_to_integer(Rest, Int1);
base2_to_integer([], Int) ->
Int;
base2_to_integer(_, _) ->
error.
base8_to_integer([C | Rest], Int) when C >= $0 andalso C =< $7 ->
Int1 = (Int * 8) + (C - $0),
base8_to_integer(Rest, Int1);
@ -158,17 +152,6 @@ base16_to_integer([], Int) ->
base16_to_integer(_, _) ->
error.
base60_to_integer([C | Rest], Current, Int) when C >= $0 andalso C =< $9 ->
Current1 = (Current * 10) + (C - $0),
base60_to_integer(Rest, Current1, Int);
base60_to_integer([$: | Rest], Current, Int) ->
Int1 = (Int * 60) + Current,
base60_to_integer(Rest, 0, Int1);
base60_to_integer([], Current, Int) ->
(Int * 60) + Current;
base60_to_integer(_, _, _) ->
error.
exception(Token) ->
Error = #yamerl_parsing_error{
name = not_an_integer,