From 8b4c5f1d1009d12e69c7a89950cea2625e20abba Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 18 Jun 2010 12:29:49 +0000 Subject: * g-spipat.adb, a-swunau.adb, a-swunau.ads, g-spitbo.adb, a-szunau.adb, a-szunau.ads, a-stunau.adb, a-stunau.ads, a-strunb.adb (Big_String. Big_String_Access): New type. From-SVN: r160981 --- gcc/ada/a-strunb.adb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'gcc/ada/a-strunb.adb') diff --git a/gcc/ada/a-strunb.adb b/gcc/ada/a-strunb.adb index 7634e65..cc5b92b 100644 --- a/gcc/ada/a-strunb.adb +++ b/gcc/ada/a-strunb.adb @@ -914,9 +914,14 @@ package body Ada.Strings.Unbounded is function To_Unbounded_String (Source : String) return Unbounded_String is Result : Unbounded_String; begin - Result.Last := Source'Length; - Result.Reference := new String (1 .. Source'Length); - Result.Reference.all := Source; + -- Do not allocate an empty string: keep the default + + if Source'Length > 0 then + Result.Last := Source'Length; + Result.Reference := new String (1 .. Source'Length); + Result.Reference.all := Source; + end if; + return Result; end To_Unbounded_String; @@ -924,9 +929,15 @@ package body Ada.Strings.Unbounded is (Length : Natural) return Unbounded_String is Result : Unbounded_String; + begin - Result.Last := Length; - Result.Reference := new String (1 .. Length); + -- Do not allocate an empty string: keep the default + + if Length > 0 then + Result.Last := Length; + Result.Reference := new String (1 .. Length); + end if; + return Result; end To_Unbounded_String; -- cgit v1.1