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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8bb703cc61967d22 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-30 08:27:33 PST Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!darwin.sura.net!source.asset.com!source.asset.com!not-for-mail From: weisek@source.asset.com (Kevin Weise) Newsgroups: comp.lang.ada Subject: Re: GNAT not 'getting' CR or LF? Date: 30 Dec 1994 10:23:45 -0500 Organization: Asset Source for Software Engineering Technology Distribution: na Message-ID: <3e18m1$9eu@source.asset.com> References: <1994Dec29.230538.15695@nmt.edu> NNTP-Posting-Host: 530tr0 Date: 1994-12-30T10:23:45-05:00 List-Id: In article <1994Dec29.230538.15695@nmt.edu>, Smilin' Ron Finkbine wrote: >I am using the gnat system (DOS version) and am writing a >Fortran scanner. I am having a problem with the Text_IO.get >function getting a character. It seems to ignore the carriage >return and linefeed characters. > >What knowledge about gnat am I missing? > I haven't looked closely at the Ada95 RM for Text_IO; but I know that in Ada83, line terminators are considered implementation dependent, and therefore (in the interest of portability) not returned to the user. That is, if you are reading input one character at a time, then you should not count on receiving any kind of line terminator character. This is pretty easy to understand, Unix uses a newline (ASCII linefeed), VAX/VMS uses a CR/LF (ASCII carriage return-linefeed combination) on *one* kind of textfile, MS-DOS uses (I've never been certain if it was a CR only or a CR-LF), some computers have no line terminator (but I don't know of anyone using CDC Cybers anymore). If you write a program that expects, e.g. a newline as a line terminator, then that program does not necessarily quickly/easily port to anything except a Unix look-alike. To do what you want, I believe you have two major options: 1. Test using Text_IO.End_of_Line before each character read (quick, but real dirty & inefficient) or, 2. Buffer your own input, reading an entire line at a time using Text_IO.Get_Line, and then appending your own line terminator character of choice after the last character of each line. Then, you do character-at-a time fetches from this line buffer, filling it with the next line each time you return the last character. (You would be wise to put a file terminator character of choice after Text_IO.End_of_File, too.) Both these options are truly portable. My guess is, in order to preserve semantics of existing software, Ada95 (and thus GNAT) works the same way. ---------------------------------------------------------------- Kevin J. Weise weisek@source.asset.com COLSA Corporation Voice - (205) 922-1512 ext. 2115 6726 Odyssey Drive FAX - (205) 971-0002 Huntsville, AL 35806 {Standard Disclaimers about my opinions & my employer's opinions} {... which are in conflict often enough} ---------------------------------------------------------------- "Admire those who seek the truth; avoid those who find it." Marcel Proust