From 99a872a8b100d5644b69f9c46a85af0b243bd0f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 15 Apr 2016 18:01:35 -0400 Subject: [PATCH] lib/core: intro to_s_with_copy_and_length MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/core/text/flat.nit | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/text/flat.nit b/lib/core/text/flat.nit index 18fdabe..3647344 100644 --- a/lib/core/text/flat.nit +++ b/lib/core/text/flat.nit @@ -1185,9 +1185,11 @@ redef class NativeString end # Returns `self` as a new String. - redef fun to_s_with_copy: FlatString + redef fun to_s_with_copy do return to_s_with_copy_and_length(cstring_length) + + # Get a `String` from `length` bytes at `self` copied into Nit memory + fun to_s_with_copy_and_length(length: Int): String do - var length = cstring_length var r = clean_utf8(length) if r.items != self then return r var new_self = new NativeString(length + 1) -- 1.7.9.5