From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Out_File , excess line Date: Sat, 30 Jan 2016 09:44:24 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="d1f7d2633ee45ab9629ebafbf83c9647"; logging-data="20616"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+M/9B0XeLzYsS1VXbVK8V2oyANFW3kdBY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:lASmCX5ZYsmcYxfV+N4lB6Yi4e0= sha1:CC6HLJUa+DgVRGOeSwEj9geXOEI= Xref: news.eternal-september.org comp.lang.ada:29290 Date: 2016-01-30T09:44:24+00:00 List-Id: 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