diff options
author | Robert Dewar <dewar@adacore.com> | 2005-03-15 16:53:10 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2005-03-15 16:53:10 +0100 |
commit | 2f388d2db6113fc8113d983c7370b7c45b1024ab (patch) | |
tree | 5ce32e503ea5e4af6010553a51d8e39be3fbf801 /gcc/ada/a-stunau.adb | |
parent | 798a90555d7d72881c3d81d773328dc4156b4e6e (diff) | |
download | gcc-2f388d2db6113fc8113d983c7370b7c45b1024ab.zip gcc-2f388d2db6113fc8113d983c7370b7c45b1024ab.tar.gz gcc-2f388d2db6113fc8113d983c7370b7c45b1024ab.tar.bz2 |
re PR ada/13470 (64bits Ada bootstrap failure:xnmake etc. crash generating nmake.adb etc.)
2005-03-08 Robert Dewar <dewar@adacore.com>
PR ada/13470
* a-stunau.ads, a-stunau.adb:
Change interface to allow efficient (and correct) implementation
The previous changes to allow extra space in unbounded strings had
left this interface a bit broken.
* a-suteio.adb: Avoid unnecessary use of Get/Set_String
* g-spipat.ads, g-spipat.adb: New interface for Get_String
Minor reformatting (function specs)
* g-spitbo.adb: New interface for Get_String
* g-spitbo.ads: Minor reformatting
* a-swunau.ads, a-swunau.adb: New interface for Get_Wide_String
* a-szunau.ads, a-szunau.adb: New interface for Get_Wide_Wide_String
From-SVN: r96488
Diffstat (limited to 'gcc/ada/a-stunau.adb')
-rw-r--r-- | gcc/ada/a-stunau.adb | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/gcc/ada/a-stunau.adb b/gcc/ada/a-stunau.adb index 9b23cb2..0dbd3fd 100644 --- a/gcc/ada/a-stunau.adb +++ b/gcc/ada/a-stunau.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -37,31 +37,14 @@ package body Ada.Strings.Unbounded.Aux is -- Get_String -- ---------------- - function Get_String (U : Unbounded_String) return String_Access is + procedure Get_String + (U : Unbounded_String; + S : out String_Access; + L : out Natural) + is begin - if U.Last = U.Reference'Length then - return U.Reference; - - else - declare - type Unbounded_String_Access is access all Unbounded_String; - - U_Ptr : constant Unbounded_String_Access := U'Unrestricted_Access; - -- Unbounded_String is a controlled type which is always passed - -- by reference. It is always safe to take the pointer to such - -- object here. This pointer is used to set the U.Reference - -- value which would not be possible otherwise as U is read-only. - - Old : String_Access := U.Reference; - Ret : String_Access; - - begin - Ret := new String'(U.Reference (1 .. U.Last)); - U_Ptr.Reference := Ret; - Free (Old); - return Ret; - end; - end if; + S := U.Reference; + L := U.Last; end Get_String; ---------------- @@ -70,21 +53,13 @@ package body Ada.Strings.Unbounded.Aux is procedure Set_String (UP : in out Unbounded_String; S : String) is begin - if UP.Last = S'Length then - UP.Reference.all := S; - - else - declare - subtype String_1 is String (1 .. S'Length); - Tmp : String_Access; - - begin - Tmp := new String'(String_1 (S)); - Finalize (UP); - UP.Reference := Tmp; - UP.Last := UP.Reference'Length; - end; + if S'Length > UP.Last then + Finalize (UP); + UP.Reference := new String (1 .. S'Length); end if; + + UP.Reference (1 .. S'Length) := S; + UP.Last := S'Length; end Set_String; procedure Set_String (UP : in out Unbounded_String; S : String_Access) is |