comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: Ada.Streams.Stream_IO.File_Type
Date: Fri, 18 Jul 2003 03:10:35 +1200
Date: 2003-07-18T03:10:35+12:00	[thread overview]
Message-ID: <mt7chvs7heoihdv7a3a6psh5h8v1b46i2i@4ax.com> (raw)
In-Reply-To: RfZQa.71833$N7.8631@sccrnsc03


On Tue, 15 Jul 2003 20:13:37 GMT, tmoran@acm.org wrote:

---------------------------
>Why is this [Ada.Streams.Stream_IO.File_Type] not a descendant of
>  Ada.Finalization.Limited_Controlled?
---------------------------

That would be done to allow no call to Close(). Close might raise errors.
 GNAT's already code has the doubly linked list (in GNAT-'only' package
 System.File_Control_Block).

---

From another thread (mis)titled "Re: Terminating a task"

It was on the 2nd computer language shootout contest:
  http://dada.perl.it/shootout/  (wc example: counting words in binary)

---------------------------
On Tue, 15 Jul 2003 13:30:33 -0500, "David C. Hoos" 
>The package Ada.TextIO.Text_Streams allows one to obtain the stream
> object corresponding to the standard input -- i.e.:
>
>Standard_Input_Stream : Ada.Text_IO.Text_Streams.Stream_Access =
>   Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Input);
---------------------------

This comment is not on Text_Streams:

---------------------------
From: "Randy Brukardt" <randy@rrsoftware.com>
Newsgroups: comp.lang.ada
Subject: Re: Fill string with multiple lines from standard_input
Date: Fri, 16 Aug 2002 21:26:29 -0500

...
Keep in mind that Stream_IO was virtually untested by the ACATS until
recently, and even now the standard has serious problems which can make
the use of Stream_IO non-portable (since compilers pretty much all do
the wrong thing). So even an implementation which passes the ACATS tests
may still have problems in some cases (having to do with writing, [...]
---------------------------

It is a problem with the design rather than the testing. ACT doesn't
 like the design.

A fix would be to add this next line to Ada.Streams.Stream_IO:

    function Standard_Input return File_Type;

Anyone know why it is not in there already?. Portable Ada programs
 handling piping or CGI I/O may need that unless using C (etc.).

I looked for an AI or comment at Ada-Comment, hinting that a fix is
 desired or intended, but found nothing.

Using C's setmode() and read() seems to be a good solution.

--

Currently GNAT 3.15's Text_IO.Text_Streams feature stops reading, on
 encountering a ASCII.SUB character (= character 10#26#). Presumably
 they don't like the RM's design.

Demo code:   % cat data | tr \\032-\\032 " " | wc
----------------------------------
   type Tio is Ada.Text_IO;
   In_Stream   : Tio.Text_Streams.Stream_Access;
   Out_Stream  : Tio.Text_Streams.Stream_Access;
   Input_Chars : Ada.Streams.Stream_Element_Array (1 .. 1024);
   Last        : Ada.Streams.Stream_Element_Offset;
...
      --  Now use the "do a type conversions on a pointer" package:
   In_Stream := Tio.Text_Streams.Stream (Tio.Current_Input);
   Out_Stream := Tio.Text_Streams.Stream (Tio.Current_Output);
      --  Now use the text package to handle binary I/O:
   loop
      Ada.Streams.Read (In_Stream.all, Input_Chars, Last);
      exit when Last = 0;    --  Quit on the first ASCII.SUB character
      Ada.Streams.Write (Out_Stream.all, Input_Chars (1 .. Last));
   end loop;
----------------------------------


AARM A.12.2: Package Text_IO.Text_Streams:
   http://www.adaic.org/standards/95aarm/html/AA-A-12-2.html

AARM 13.13.1: Package Streams:
   http://www.adaic.org/standards/95aarm/html/AA-13-13-1.html

AARM A.12.1: Package Streams.Stream_IO:
   http://www.adaic.org/standards/95aarm/html/AA-A-12-1.html


______

- Craig Carey

How to Cross-Compiled in FreeBSD to/for a x86 Linux target:
 http://www.ijs.co.nz/code/ada95-freebsd-to-linux-cross-compiler.txt






  reply	other threads:[~2003-07-17 15:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-15 20:13 Ada.Streams.Stream_IO.File_Type tmoran
2003-07-17 15:10 ` Craig Carey [this message]
2003-07-17 16:42   ` Ada.Streams.Stream_IO.File_Type Nick Roberts
2003-07-18 17:34     ` Ada.Streams.Stream_IO.File_Type Matthew Heaney
2003-07-18 18:25       ` Ada.Streams.Stream_IO.File_Type David C. Hoos
2003-07-17 16:01 ` Ada.Streams.Stream_IO.File_Type Nick Roberts
2003-07-20 11:27   ` Ada.Streams.Stream_IO.File_Type Mário Amado Alves
2003-07-20 14:25     ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus
2003-07-21  4:03       ` Ada.Streams.Stream_IO.File_Type Nick Roberts
2003-07-21  9:47         ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus
2003-07-18  7:46 ` Ada.Streams.Stream_IO.File_Type Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox