aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-strunb.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2010-06-18 12:29:49 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2010-06-18 14:29:49 +0200
commit8b4c5f1d1009d12e69c7a89950cea2625e20abba (patch)
tree1005e9ee2894b1411be31e22a219e5ab16847f6c /gcc/ada/a-strunb.adb
parented2233dc6daaa5066470858c3ff939392b2f42ff (diff)
downloadgcc-8b4c5f1d1009d12e69c7a89950cea2625e20abba.zip
gcc-8b4c5f1d1009d12e69c7a89950cea2625e20abba.tar.gz
gcc-8b4c5f1d1009d12e69c7a89950cea2625e20abba.tar.bz2
* 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
Diffstat (limited to 'gcc/ada/a-strunb.adb')
-rw-r--r--gcc/ada/a-strunb.adb21
1 files changed, 16 insertions, 5 deletions
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;