lib/standard/string: Fixed bug in to_s implementations in NativeString
authorLucas Bajolet <r4pass@hotmail.com>
Tue, 4 Nov 2014 20:43:18 +0000 (15:43 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 4 Nov 2014 20:44:27 +0000 (15:44 -0500)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/string.nit

index 0529b60..ba41bf9 100644 (file)
@@ -2050,7 +2050,6 @@ extern class NativeString `{ char* `}
        do
                assert length >= 0
                var str = new FlatString.with_infos(self, length, 0, length - 1)
-               str.real_items = self
                return str
        end
 
@@ -2060,7 +2059,8 @@ extern class NativeString `{ char* `}
                var new_self = calloc_string(length + 1)
                copy_to(new_self, length, 0, 0)
                var str = new FlatString.with_infos(new_self, length, 0, length - 1)
-               str.real_items = self
+               new_self[length] = '\0'
+               str.real_items = new_self
                return str
        end
 end