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,d93b7c6dd17cbc81 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Strings and reading from a file Date: 1999/05/13 Message-ID: #1/1 X-Deja-AN: 477555896 References: <7han2q$jkp$1@news.iinet.net.au> <37399913.BD928DD1@pwfl.com> <7hevh1$g08$1@nnrp1.deja.com> <7hf2bc$imm$1@nnrp1.deja.com> <7hf611$16i$1@cnn.Princeton.EDU> <373B271F.EA28F9C8@pwfl.com> X-Complaints-To: usenet@nusku.cts.com X-Trace: nusku.cts.com 926628789 15470 198.68.168.21 (13 May 1999 20:53:09 GMT) Organization: CTS Network Services NNTP-Posting-Date: 13 May 1999 20:53:09 GMT Newsgroups: comp.lang.ada Date: 1999-05-13T20:53:09+00:00 List-Id: Marin David Condic writes: [...] > However - enamoured as I am with the "perfect" solution that works for > any case that may arise - I'd wonder if in practice it isn't a bit of > overkill. In my experience with text files, most lines are less than the > 80 character width of a punchcard or glass-teletype. Probably 95% of > text lines are within twice that number. I can't recall ever seeing a > text line (in a standard text file like what would be used for some word > processing app - not a custom data file) which ever exceeded a 256 byte > string. No, it's not overkill. I commonly work with text files containing lines hundreds, or even thousands, of characters long. Most of them are machine-generated (log files and such). If you're writing something that will have to deal with arbitrary text files as input, make sure it will handle arbitrarily long lines. Even if you can guarantee (or enforce) that your input lines will never be longer than some fixed limit, make sure your code fails gracefully if that limit is exceeded. Truncation may be acceptable; random misbehavior is not. One advantage of Ada is that, even if you don't specifically think to handle long input lines, you're not likely to step on memory if you receive unexpected input. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Techno-geek. Mouse bigger than phone. Bites heads off virtual chickens.