From 91c75e33a363ba278e267688c0795cc26c1b07ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Sun, 13 Nov 2016 16:52:19 +0100 Subject: [PATCH] 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. --- src/yamerl_node_int.erl | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/yamerl_node_int.erl b/src/yamerl_node_int.erl index 223b6a2..9b2bed4 100644 --- a/src/yamerl_node_int.erl +++ b/src/yamerl_node_int.erl @@ -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,