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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c689b55786a9f2bd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!news.k-dsl.de!eternal-september.org!.POSTED!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: for S'Image use Func?? Date: Tue, 11 May 2010 16:49:09 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <4be417b4$0$6992$9b4e6d93@newsspool4.arcor-online.net> <1qcb6z4i20dyb.1dz2hd4c0vx69.dlg@40tude.net> <84r4k5Ftk8U1@mid.individual.net> <84sfkjF3btU1@mid.individual.net> Injection-Date: Tue, 11 May 2010 16:49:09 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="9f8M0iN5t54V+4DF/iqO8g"; logging-data="28153"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HkBbboqY5uGjv5H39zKdq9cj2VteZeDY=" User-Agent: Xnews/5.04.25 X-Face: &6@]C2>ZS=NM|HE-^zWuryN#Z/2_.s9E|G&~DRi|sav9{E}XQJb*\_>=a5"q]\%A;5}LKP][1mA{gZ,Q!j Cancel-Lock: sha1:nsx5NDBA5A7R+FLAgX/LFDOe9XU= Xref: g2news2.google.com comp.lang.ada:11507 Date: 2010-05-11T16:49:09+00:00 List-Id: Niklas Holsti expounded in news:84sfkjF3btU1@mid.individual.net: > Warren wrote: >> Niklas Holsti expounded in news:84r4k5Ftk8U1@mid.individual.net: >>> ... if you read character by character, use the function >>> Text_IO.End_Of_Line to detect the end of an input line. This works >>> the same way in all systems, whatever line termination character >>> (sequence), if any, is used. Follow with Skip_Line to go to the start >>> of the next line. >> >> I assume that is true before you read the next "char". If I >> then Skip_Line as you say, will I also get End_Of_Line true >> if the next line is empty (null)? > > Yes, with one problem, which is that it is hard (that is, I don't know > how) to detect when the very last line in the input file is null. This > is because End_Of_Line returns true also at end of file, and End_Of_File > returns true also when the data remaining in the file is an end-of-line > (and end-of-page) before the true end of file. One consequence is that a > truly empty file (like /dev/null) looks the same as a file with one null > line (like echo ""). I see. In my current app, that's not a big deal, but it is good to be aware of that. One thing that comes up in C based streams is that sometimes the last line does not end in a LF (and/or CR). So then you get EOF, but no indication of a line ending. So usually you code it to "fix the line" when you see that. > Try this program on a file with some empty lines: I see. With 2 null input lines, it reports: $ ./linelen