This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Tested on i686-linux. Committed on mainline.
Implement the new subprograms for Unbounded that are
introduced by AI-301. A full description with RM changes is in:
http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00301.TXT?rev=1.13.
The new routines are new Index functions with a From parameter, a new
Index_Non_Blank function with a From parameter, two new Unbounded_Slice
subprograms and finally a Set_Unbounded_String procedure. We also use
this opportunity to do some formatting cleanup in the unbounded string
package. The Wide and Wide_Wide packages have been regenerated to include
the same changes.
This patch also improves the efficiency of the Get_Line procedure for
unbounded strings (in packages Text_IO.Unbounded_IO, and in the
GNAT package Unbounded.Text_IO). The change reuses the existing
space if possible, avoiding unnecessary reallocation. The base
Unbounded package is changed to move Realloc_For_Chunk to the
private part so it is accessible to children. As part of this
change, we also add pragma Ada_05 statements to the Unbounded_IO
package (these were forgotten first time around). Wide and
Wide_Wide packages are changed accordingly.
A test program which should run silently when compiled with the
-gnat05 flag is:
with Ada.Text_IO;
with Ada.Wide_Text_IO;
with Ada.Wide_Wide_Text_IO;
with Ada.Strings.Unbounded;
with Ada.Strings.Wide_Unbounded;
with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Text_IO.Unbounded_IO;
with Ada.Wide_Text_IO.Wide_Unbounded_IO;
with Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO;
procedure K is
begin
declare
use Ada.Text_IO;
use Ada.Strings.Unbounded;
use Ada.Text_IO.Unbounded_IO;
F : File_Type;
S : String := "ABCDE";
U : Unbounded_String;
begin
Create (F, Out_File, "log1");
Put_Line (F, S);
Close (F);
Open (F, In_File, "log1");
Get_Line (F, U);
if To_String (U) /= S then
raise Program_Error;
end if;
Close (F);
Open (F, In_File, "log1");
Get_Line (F, U);
if To_String (U) /= S then
raise Program_Error;
end if;
end;
declare
use Ada.Wide_Text_IO;
use Ada.Strings.Wide_Unbounded;
use Ada.Wide_Text_IO.Wide_Unbounded_IO;
F : File_Type;
S : Wide_String := "ABCDE";
U : Unbounded_Wide_String;
begin
Create (F, Out_File, "log2");
Put_Line (F, S);
Close (F);
Open (F, In_File, "log2");
U := Get_Line (F);
if To_Wide_String (U) /= S then
raise Program_Error;
end if;
Close (F);
Open (F, In_File, "log2");
Get_Line (F, U);
if To_Wide_String (U) /= S then
raise Program_Error;
end if;
end;
declare
use Ada.Wide_Wide_Text_IO;
use Ada.Strings.Wide_Wide_Unbounded;
use Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO;
F : File_Type;
S : Wide_Wide_String := "ABCDE";
U : Unbounded_Wide_Wide_String;
begin
Create (F, Out_File, "log3");
Put_Line (F, S);
Close (F);
Open (F, In_File, "log3");
Get_Line (F, U);
if To_Wide_Wide_String (U) /= S then
raise Program_Error;
end if;
Close (F);
Open (F, In_File, "log3");
Get_Line (F, U);
if To_Wide_Wide_String (U) /= S then
raise Program_Error;
end if;
end;
end K;
2005-03-08 Robert Dewar <dewar@adacore.com>
* a-stzunb.adb, a-stzunb.adb a-stzunb.ads, a-stzunb.ads,
a-stwiun.ads, a-stwiun.adb, a-strunb.ads, a-strunb.adb: Move
Realloc_For_Chunk to private part of package.
New subprograms for AI-301
* a-szuzti.adb, a-suteio.adb, a-swuwti.adb: Improve efficiency of
Get_Line procedure.
Avoid unnecessary use of Get/Set_Wide_String
Attachment:
difs.8
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |