From 9c5396a95d7cb467fe1c943927c9b699311f325a Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Mon, 16 May 2016 15:59:03 -0400 Subject: [PATCH] lib/core: Fix substring in `ASCIIFlatString` Signed-off-by: Lucas Bajolet --- lib/core/text/flat.nit | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/text/flat.nit b/lib/core/text/flat.nit index b7e8e61..2fa0bcb 100644 --- a/lib/core/text/flat.nit +++ b/lib/core/text/flat.nit @@ -666,15 +666,15 @@ private class ASCIIFlatString end redef fun substring(from, count) do + var ln = _length + if count <= 0 then return "" + if (count + from) > ln then count = ln - from if count <= 0 then return "" - if from < 0 then count += from - if count < 0 then return "" + if count <= 0 then return "" from = 0 end - var ln = _length - if (count + from) > ln then count = ln - from return new ASCIIFlatString.full_data(_items, count, from + _first_byte, count) end -- 1.7.9.5