From 5f68a48139fdd6c1ff609b5253dcd79b501a94e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 11 Jan 2016 23:00:59 -0500 Subject: [PATCH] lib/core: remove support for ',' in `is_numeric` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/core/text/abstract_text.nit | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/core/text/abstract_text.nit b/lib/core/text/abstract_text.nit index 401f32c..4770977 100644 --- a/lib/core/text/abstract_text.nit +++ b/lib/core/text/abstract_text.nit @@ -310,19 +310,18 @@ abstract class Text # assert "123".is_numeric == true # assert "1.2".is_numeric == true # assert "-1.2".is_numeric == true - # assert "1,2".is_numeric == true # assert "-1.23e-2".is_numeric == true # assert "1..2".is_numeric == false # assert "".is_numeric == false fun is_numeric: Bool do - var has_point_or_comma = false + var has_point = false var e_index = -1 for i in [0..length[ do var c = chars[i] if not c.is_numeric then - if (c == '.' or c == ',') and not has_point_or_comma then - has_point_or_comma = true + if c == '.' and not has_point then + has_point = true else if c == 'e' and e_index == -1 and i > 0 and i < length - 1 and chars[i-1] != '-' then e_index = i else if c == '-' and i == e_index + 1 and i < length - 1 then -- 1.7.9.5