From: Bj�rn Persson <bjorn_persson.spam-is-evil@sverige.nu>
Subject: Re: Can I treat Current_Output as a file of bytes?
Date: Thu, 07 Nov 2002 19:01:05 GMT
Date: 2002-11-07T19:01:05+00:00 [thread overview]
Message-ID: <20021107200106.69c213fa.bjorn_persson.spam-is-evil@sverige.nu> (raw)
In-Reply-To: 4519e058.0211062004.4a55ab0e@posting.google.com
On 6 Nov 2002 20:04:25 -0800
dennison@telepath.com (Ted Dennison) wrote:
> "Randy Brukardt" <randy@rrsoftware.com> wrote in message news:<usja17cbnvhc65@corp.supernews.com>...
> > I would be very surprised if a compiler implementer went out of their
> > way to add stuff there that OS does not add. In this case, neither
> > Windows nor Unix adds any line breaks to standard output, so why would
> > an Ada compiler? (If you're not using Windows or Unix, your mileage may
>
> The OP seemed to think that the line break was getting added on the
> "Close" call, if I was reading him correctly. Seeing as this method
> would require calling the exact same "Close" routine, I think you can
> perhaps see the source of my concern.
Gnat's Ada.Text_IO does it in a procedure called Terminate_Line that
gets called when closing or resetting a text file:
procedure Terminate_Line (File : File_Type) is
begin
FIO.Check_File_Open (AP (File));
-- For file other than In_File, test for needing to terminate last line
if Mode (File) /= In_File then
-- If not at start of line definition need new line
if File.Col /= 1 then
New_Line (File);
-- For files other than standard error and standard output, we
-- make sure that an empty file has a single line feed, so that
-- it is properly formatted. We avoid this for the standard files
-- because it is too much of a nuisance to have these odd line
-- feeds when nothing has been written to the file.
elsif (File /= Standard_Err and then File /= Standard_Out)
and then (File.Line = 1 and then File.Page = 1)
then
New_Line (File);
end if;
end if;
end Terminate_Line;
As you can see, standard out and standard error are excepted if the
page, line and column numbers are all 1, and since stream operations
don't affect these numbers, I get rid of the line break if I write
everything through the stream. For disk files the line break is always
added, but for those I can use Sequential_IO, which will hopefully
only write what I tell it to write.
Bj�rn Persson
next prev parent reply other threads:[~2002-11-07 19:01 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-04 22:34 Can I treat Current_Output as a file of bytes? Bj�rn Persson
2002-11-05 14:30 ` Ted Dennison
2002-11-05 16:01 ` Bj�rn Persson
2002-11-05 18:13 ` Warren W. Gay VE3WWG
2002-11-05 22:14 ` Bj�rn Persson
2002-11-05 22:48 ` Robert A Duff
2002-11-06 0:42 ` Jeffrey Creem
2002-11-06 7:14 ` Dale Stanbrough
2002-11-06 8:45 ` Fraser Wilson
2002-11-08 10:03 ` Jacob Sparre Andersen
2002-11-05 22:27 ` Ted Dennison
2002-11-06 23:40 ` Randy Brukardt
2002-11-07 2:45 ` Larry Kilgallen
2002-11-07 4:04 ` Ted Dennison
2002-11-07 19:01 ` Bj�rn Persson [this message]
2002-11-07 21:04 ` Randy Brukardt
2002-11-08 0:03 ` Bj�rn Persson
2002-11-08 1:36 ` Larry Kilgallen
2002-11-08 14:53 ` Stephen Leake
2002-11-09 14:33 ` Marin David Condic
2002-11-09 15:26 ` Preben Randhol
2002-11-09 14:36 ` Larry Kilgallen
2002-11-10 15:37 ` Marin David Condic
2002-11-08 16:40 ` Bj�rn Persson
2002-11-08 15:55 ` Larry Kilgallen
2002-11-08 18:07 ` Bj�rn Persson
2002-11-08 19:09 ` Matthew Woodcraft
2002-11-08 20:34 ` Randy Brukardt
2002-11-08 15:10 ` Ted Dennison
2002-11-08 15:57 ` Larry Kilgallen
2002-11-08 16:16 ` Preben Randhol
2002-11-08 17:30 ` Bj�rn Persson
2002-11-08 20:32 ` Randy Brukardt
2002-11-07 0:44 ` Bj�rn Persson
2002-11-07 14:41 ` Ted Dennison
2002-11-07 17:41 ` Bj�rn Persson
2002-11-09 11:37 ` Georg Bauhaus
2002-11-06 8:26 ` Pascal Obry
-- strict thread matches above, loose matches on Subject: below --
2002-11-06 5:54 Grein, Christoph
2002-11-07 6:28 Grein, Christoph
2002-11-07 17:04 ` Bj�rn Persson
2002-11-07 19:05 Kees de LezenneCoulander
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox