comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Out_File , excess line
Date: Sat, 30 Jan 2016 09:44:24 +0000
Date: 2016-01-30T09:44:24+00:00	[thread overview]
Message-ID: <lyio2bv1tz.fsf@pushface.org> (raw)
In-Reply-To: ef074b1e-24f7-4501-8857-c4ed9ca74467@googlegroups.com

comicfanzine@gmail.com writes:

> I noticed that when i open a file ( empty or full ) in Out_file mode ,
> an extra line is created .
>
> Normally , on my system , when you open maually a file , there is one
> empty line by default .
>
> But , when i open this same file in Ada with Out_file Mode , and then
> manually , a second line appear .

ARM A.10.2(3)[1] says

   For the procedure Close: If the file has the current mode Out_File or
   Append_File, has the effect of calling New_Page, unless the current
   page is already terminated; then outputs a file terminator.

ARM A.10.5(15)[2] says

   procedure New_Page(File : in File_Type);
   procedure New_Page;

   Operates on a file of mode Out_File or Append_File. Outputs a line
   terminator if the current line is not terminated, or if the current
   page is empty (that is, if the current column and line numbers are
   both equal to one). Then outputs a page terminator, which terminates
   the current page. Adds one to the current page number and sets the
   current column and line numbers to one.

So, if you open a file in Out_File mode, the current (empty) line is not
terminated, and when you close the file and New_Page is called (or
possibly simulated), a line terminator is added.

You would expect a page terminator (FF) to be added as well; indeed, if
you call New_Page explicitly and then close the file GNAT does. I
suspect that the reason GNAT doesn't do this in the case of just closing
a file with an unterminated line is that that would be very surprising
indeed!

See Terminate_Line in a-textio.adb.

[1] http://www.ada-auth.org/standards/12rm/html/RM-A-10-2.html#p3
[2] http://www.ada-auth.org/standards/12rm/html/RM-A-10-5.html#p15


  parent reply	other threads:[~2016-01-30  9:44 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20  1:39 Out_File , excess line comicfanzine
2016-01-20 11:23 ` AdaMagica
2016-01-20 13:31 ` comicfanzine
2016-01-20 14:03 ` comicfanzine
2016-01-20 14:26   ` Dmitry A. Kazakov
2016-01-20 17:33   ` AdaMagica
2016-01-21  4:50 ` comicfanzine
2016-01-21 10:27   ` Jacob Sparre Andersen
2016-01-21 10:56     ` AdaMagica
2016-01-21 11:57       ` G.B.
2016-01-21 14:42         ` Dmitry A. Kazakov
2016-01-21 16:23           ` AdaMagica
2016-01-22  2:50             ` Dennis Lee Bieber
2016-01-21 13:38   ` Dennis Lee Bieber
2016-01-21 17:30 ` comicfanzine
2016-01-22  1:56   ` comicfanzine
2016-01-22 12:28   ` Brian Drummond
2016-01-22 20:01 ` comicfanzine
2016-01-23 20:06 ` comicfanzine
2016-01-27  9:26   ` Simon Wright
2016-01-27 19:32     ` Simon Wright
2016-01-27 21:31       ` Jeffrey R. Carter
2016-01-27 20:28     ` Dmitry A. Kazakov
2016-01-24 16:11 ` comicfanzine
2016-01-25 21:54 ` comicfanzine
2016-01-25 22:01   ` MM
2016-01-26  0:50     ` comicfanzine
2016-01-26 10:10 ` comicfanzine
2016-01-27  3:57 ` comicfanzine
2016-01-27  8:13   ` AdaMagica
2016-01-28  4:35 ` comicfanzine
2016-01-29 23:04 ` comicfanzine
2016-01-30  9:44 ` Simon Wright [this message]
2016-01-30 10:43   ` AdaMagica
2016-01-30 13:51     ` Simon Wright
2016-01-31  8:56 ` comicfanzine
2016-01-31 11:25   ` Simon Wright
2016-01-31 12:57     ` Dmitry A. Kazakov
2016-01-31 17:00       ` Simon Wright
2016-01-31 11:51   ` AdaMagica
2016-02-01  6:22 ` comicfanzine
2016-02-01  8:32   ` Dmitry A. Kazakov
2016-02-09 15:07 ` comicfanzine
2016-02-09 17:00   ` 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