summaryrefslogtreecommitdiff
path: root/gcc/ada/a-swunau.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-15 15:53:10 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-15 15:53:10 +0000
commit90fd25c58b1661a5ad762daba6800b86eb95485e (patch)
tree5ce32e503ea5e4af6010553a51d8e39be3fbf801 /gcc/ada/a-swunau.adb
parent20e42bc1b770789e9db37f51ca755d305f5b2eec (diff)
downloadgcc-90fd25c58b1661a5ad762daba6800b86eb95485e.tar.gz
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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96488 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-swunau.adb')
-rw-r--r--gcc/ada/a-swunau.adb50
1 files changed, 12 insertions, 38 deletions
diff --git a/gcc/ada/a-swunau.adb b/gcc/ada/a-swunau.adb
index 2d9a2dd0b1c..2f4c127b71b 100644
--- a/gcc/ada/a-swunau.adb
+++ b/gcc/ada/a-swunau.adb
@@ -37,33 +37,14 @@ package body Ada.Strings.Wide_Unbounded.Aux is
-- Get_Wide_String --
---------------------
- function Get_Wide_String
- (U : Unbounded_Wide_String) return Wide_String_Access
+ procedure Get_Wide_String
+ (U : Unbounded_Wide_String;
+ S : out Wide_String_Access;
+ L : out Natural)
is
begin
- if U.Last = U.Reference'Length then
- return U.Reference;
-
- else
- declare
- type Unbounded_Wide_String_Access is
- access all Unbounded_Wide_String;
-
- U_Ptr : constant Unbounded_Wide_String_Access :=
- U'Unrestricted_Access;
- -- Unbounded_Wide_String is a controlled type which is always
- -- passed by copy 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 : Wide_String_Access := U.Reference;
-
- begin
- U_Ptr.Reference := new Wide_String'(U.Reference (1 .. U.Last));
- Free (Old);
- return U.Reference;
- end;
- end if;
+ S := U.Reference;
+ L := U.Last;
end Get_Wide_String;
---------------------
@@ -75,20 +56,13 @@ package body Ada.Strings.Wide_Unbounded.Aux is
S : Wide_String)
is
begin
- if UP.Last = S'Length then
- UP.Reference.all := S;
-
- else
- declare
- subtype String_1 is Wide_String (1 .. S'Length);
- Tmp : Wide_String_Access;
- begin
- Tmp := new Wide_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 Wide_String (1 .. S'Length);
end if;
+
+ UP.Reference (1 .. S'Length) := S;
+ UP.Last := S'Length;
end Set_Wide_String;
procedure Set_Wide_String