- 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 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 : String_Access := U.Reference;
-
- begin
- U_Ptr.Reference := new String'(U.Reference (1 .. U.Last));
- Free (Old);
- return U.Reference;
- end;
- end if;