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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-Thread: 11232c,59ec73856b699922 X-Google-Attributes: gid11232c,public X-Google-ArrivalTime: 2003-05-21 23:30:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: Dave Thompson Newsgroups: comp.lang.java.advocacy,comp.object,comp.lang.ada,misc.misc Subject: Re: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died) Message-ID: <5irocv86gpa6b71lke90apgv4tuv05ua0u@4ax.com> References: <9fa75d42.0305010621.55e99deb@posting.google.com> <254c16a.0305011035.13133e8d@posting.google.com> <9fa75d42.0305011727.5eae0222@posting.google.com> <17cd177c.0305072114.24f04783@posting.google.com> <9fa75d42.0305090612.261d5a5c@posting.google.com> <82347202.0305091052.d8161a4@posting.google.com> <1mrtbv48hufvmmk69gd60v7fm4csoks0nh@4ax.com> <3EC1B704.1070207@attbi.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 22 May 2003 06:30:17 GMT NNTP-Posting-Host: 12.89.165.209 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1053585017 12.89.165.209 (Thu, 22 May 2003 06:30:17 GMT) NNTP-Posting-Date: Thu, 22 May 2003 06:30:17 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.java.advocacy:64386 comp.object:63832 comp.lang.ada:37625 misc.misc:14352 Date: 2003-05-22T06:30:17+00:00 List-Id: On Wed, 14 May 2003 03:25:03 GMT, "Robert I. Eachus" wrote: > Dave Thompson wrote: > > > Not quite. Ada Get_Line is much closer to C fgets, > > although it does store the newline character (if it fits) > > and you must often deal with removing it, and it does > > not return the length explicitly (you must strlen for it). > Apparently my antecedent wasn't clear, sorry. > There are three errors here. The first is a category error. The > description of Ada.Text_IO.Get was just to show that in Ada, you can > never have a buffer overflow error. (Unless of course you go very far > out of your way to specifically program one. It can be done, but many > Ada programmer don't know how, and most Ada programmers would consider > going out of your way to construct an Ada program that had a potential > buffer overflow not as a challenge, but as a kind of pornography. > Yes, Ada protects against overrun unless deliberately and inconveniently overridden, as I agreed in a part you didn't quote. And I did and do agree that was the important point. > The second error is technical. If an Ada program copies a newline > character as part of a Get, that is an error. If the type of the text > file was incorrectly specified, for example as one where LF (linefeed) > is the representation of end of line, instead of CR LF, then you will > read a CR character. This occasionally used to happen when people > ported files between Windows and Unix. I think now thought that all Ada > compilers accept any combination of CR and LF as end of line, while > using the appropriate end of line marker for that system when writing > text files. > Other way. Ada Get_Line does not store anything for end-of-line, assuming it is recognized correctly as you allude to. If it matters whether you got a complete line, and it usually does, you must determine by whether the count hit the limit. C fgets *does* store the (single, but otherwise implementation-defined) character '\n' for a recognized (perhaps implementation-dependent) end-of-line. In the fairly common case you don't want the \n in your string, you have to explicitly delete it, or exclude from a copy operation. > Finally, in Ada the only cases where you need to call strlen is when > converting a C or C++ string to an Ada String. In Ada the name of the > length of the string named Foo is Foo'Length. But it is an explict > property of the string, just like Foo'First and Foo'Last. (Most Ada > compilers only store two of the three attributes as part of the > representation of a dynamic string. (A string whose length is not known > at compile time.) But that is an implementation detail. > Again I meant C: fgets does not return the length of the read data explicitly (nor is it an attribute of the buffer variable) so *if* you need the length, which is not always, you must call strlen (or equal). Agree that in Ada you don't need to do that except for C interfacing in which case the canonical way is Interfaces.C.Strings.Value which actually does strlen but type-safely; or some weird I/O. > The whole point here is that an Ada programmer never worries about the > length of a string or the any of the implicit checking that needs to be > explicit in C. In fact in Ada 95 [Bounded_String and Unbounded_String] Agreed. I was only correcting and somewhat expanding your example. - David.Thompson1 at worldnet.att.net