lib/string: chomp do not try to chomp empty strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 11 Dec 2014 20:34:44 +0000 (15:34 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 12 Dec 2014 19:21:26 +0000 (14:21 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/standard/string.nit

index 604386f..def85f4 100644 (file)
@@ -394,7 +394,7 @@ abstract class Text
        # This method is mainly used to remove the LINE_FEED character from lines of text.
        fun chomp: SELFTYPE
        do
-               if self.chars.last != '\n' then return self
+               if self.is_empty or self.chars.last != '\n' then return self
                return substring(0, length-1)
        end