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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,fb00b4031f5d9d4a X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: Re: GNAT's Text_IO & empty files Date: 1998/07/07 Message-ID: <35A21B66.1509490B@cl.cam.ac.uk>#1/1 X-Deja-AN: 369210399 Content-Transfer-Encoding: 8bit References: <35A0B7C5.1011D794@Maths.UniNe.CH> Content-Type: text/plain; charset=iso-8859-1 Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-07-07T00:00:00+00:00 List-Id: Robert Dewar wrote: > -- 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; > > > Most certainly if you comment these lines out, your resulting runtime will > not be compliant with annex A of the reference manual. These lines were not > put in for amusement! Having just read RM A.10 �7, I think the Ada standard is badly formulated here. It is not clear how a file or a page with zero lines or a file with zero pages has to be encoded. The standard writes that a file is a sequence of pages and a page is a sequence of lines, but it does not handle the obvious border case of zero-length sequences adequatly. It would have been better to write just that every line terminates with a line terminator, and every page terminates with a page terminator, and then everything would have been clear and consistent. With a bit good will, the Ada RM language can even be interpreted that way. Back to my Unix convention remark: Although vi cannot produce a file in which the last line does not end with LF, it can very well produce a file that contains zero lines and is therefore zero bytes long. Markus -- Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK email: mkuhn at acm.org, home page: