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-7-bit X-Google-Thread: 103376,fb00b4031f5d9d4a X-Google-Attributes: gid103376,public From: Pascal MALAISE Subject: Re: GNAT's Text_IO & empty files Date: 1998/07/06 Message-ID: <35A12B47.1E9B74B7@magic.fr>#1/1 X-Deja-AN: 369025204 Content-Transfer-Encoding: 7bit References: <35A0B7C5.1011D794@Maths.UniNe.CH> Mime-Version: 1.0 NNTP-Posting-Date: 6 Jul 1998 19:53:43 GMT Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ulysse.magic.fr X-Trace: ulysse.magic.fr 899754823 256 127.0.0.1 (6 Jul 1998 19:53:43 GMT) Organization: Magic On Line Newsgroups: comp.lang.ada Date: 1998-07-06T19:53:43+00:00 List-Id: Gautier de Montmollin wrote: > > When you create a text file and close it without writing > anything in it, you get an empty line. This is due to an > explicit statement in procedure Terminate_Line from Ada.Text_IO. > > This causes an annoying compatibility problem a in DOS or Windows > context, since you get a 1-line, 2-bytes text instead of a 0-line, > 0-byte one. What I see is a 1-line 0-bytes file (with gnat 3.10p on linux) > ls -al toto -rw-r--r-- 1 malaise users 1 Jul 6 20:40 toto > od -x toto 0000000 000a 0000001 On which platform did you make your test on? Dos? Which bytes do you get? CR LF? or LF ^Z? Some Unix tools don't like a file ending in the middle of an "active" line, (it is better to add an empty line at the end of text files). This is what Gnat does. If you put en "T" in the file, you'll get 54 0a, and, if you put_line "T", you get 54 0a as well :-) There is no concept of file terminator (EOF) on Unix. >From the original empty file (0a) on unix, unix2dos generates 0d 0a 1a (a CR LF sequence, which is the dos format of a new line, plus the famous ^Z, which is a Dos convention for the end of file). I think that it is what ftp in ASCII more would generate from a Unix machine to a Dos one (LF becomes CR LF and ^Z is appended). What would be gnat reaction reading such a file?? Creating such empty file on Dos (with an old Meridain, I don't have gnat on dos) generates an empty file, and with a put("T") generates a 1-byte file with 54. My conclusion is that it is a file formatting question (including file terminator). - Unix has a "kind" of standard and Gnat on Linux complies to it. - Dos has another standard (CR/LF and CtrlZ) but many tools I tried on Dos don't comply to it (even an ada compiler). Perhaps this convention is becomming obsolete. - If you remove this new_line, check that text_io is still able to read such a file and that it can read a file with some text but no line terminator as well. - From the LRM "...the package Text_IO, which provides facilities for input and output in human-readable form". Readable with what? :-) Some editing tools of the same platform? Then there is a need for a "standard" for ascii text on the platform. -- Pascal MALAISE | E-mail: 22 Avenue de CHOISY | (priv) malaise@magic.fr 75013 PARIS | (prof) malaise@fr.airsysatm.thomson-csf.com FRANCE