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 X-Google-Thread: 103376,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-18 00:35:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: Fri, 18 Jul 2003 09:36:41 +0200 Message-ID: <198fhv0avvpqc39dq7paiqpf3lntca8v4g@4ax.com> References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 1058513706 12800718 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:40454 Date: 2003-07-18T09:36:41+02:00 List-Id: On Thu, 17 Jul 2003 19:36:19 +0200, "Jean-Pierre Rosen" wrote: > >"Wesley Groleau" a �crit dans le message news: >evacnf433pJrU4uiXTWJgA@gbronline.com... >> Preben Randhol wrote: >> > I sometimes use this procedure: >> > >> > procedure Get_Whole_Line >> > (File : in File_Type; >> > Item : out String; >> > Last : out Natural) >> > is >> >> I often use a function, which reads >> from the file into a temporary, >> and then returns Temp (1 .. Last) >> >> The difficulty is knowing how big to make >> the temporary. >> >This one reads a line with no length limit: > >function Get_Line return String is > Buffer : String (1..500); -- or whatever > Last : Natural; >begin > Get_Line (Buffer, Last); > if Last < Buffer'Last then > return Buffer (1..Last); > else > return Buffer & Get_Line; > end if; >end Get_Line; > >In most cases, there will be only one call, while having no upper limit. >The size of the buffer is just a matter of optimization. ARM states for Get_Line: "... Reading stops if the end of the string is met. Reading also stops if the end of the line is met before meeting the end of the string; in this case Skip_Line is (in effect) called with a spacing of 1. The values of characters not assigned are not specified." What will happen if a line is exactly of 500 character length? From the quote above I suppose that Get_Line will boldly go to the next line. If so, then your program would merge all lines of 500 character length into one adding the first shorter line, or raise an unexpected End_Error if there is no one. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de