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]

[Ada] Block stream IO for strings


This patch modifies the expansion of stream attributes of strings to include
string subtypes.

Source:
   with Ada.Text_IO;              use Ada.Text_IO;
   with Ada.Streams;              use Ada.Streams;
   with Ada.Streams.Stream_IO;    use Ada.Streams.Stream_IO;
   with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;
   procedure StdIn_Reader is
      subtype MyStr is String(1 .. 60);
      Seq : MyStr;
      S : access Root_Stream_Type;
   begin
      S := Stream(Standard_Input);
      loop
         MyStr'Read(S,Seq);
      end loop;
   end StdIn_Reader;

Compilation:
   gnatmake -q -gnat05 -gnatD stdin_reader.adb

Execution and output:
   $ grep "stream_ops__string_read" stdin_reader.adb.dg
   $       $system__strings__stream_ops__string_read (s, seq, strmF => 1);

Tested on i686-pc-linux-gnu, committed on trunk

2008-07-31  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_attr.adb (Find_Stream_Subprogram): Check the base type instead
	of the type when looking for stream subprograms for type String,
	Wide_String and Wide_Wide_String.
	
	* s-ststop.adb: Change the initialization expression of constant
	Use_Block_IO.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]