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: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-30 05:33:46 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-text.cableinet.net.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.4.030702.0 Subject: Re: Is the Writing on the Wall for Ada? From: "(see below)" Newsgroups: comp.lang.ada Message-ID: References: <3F78E850.8010401@comcast.net> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Tue, 30 Sep 2003 12:33:45 GMT NNTP-Posting-Host: 82.41.184.118 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-text.cableinet.net 1064925225 82.41.184.118 (Tue, 30 Sep 2003 13:33:45 BST) NNTP-Posting-Date: Tue, 30 Sep 2003 13:33:45 BST Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:7 Date: 2003-09-30T12:33:45+00:00 List-Id: On 30/9/03 04:24, in article VH6eb.632855$YN5.465410@sccrnsc01, "tmoran@acm.org" wrote: >> As for a Get_Line function returning an Unbounded_String, > Isn't that an open invitation to a denial-of-service buffer > (available RAM) overflow? I use the following package a lot. If you are prepared to risk Storage_Error, instantiate with Max_Length => Integer'Last. It would probably be better (more modular and perhaps more efficient) to have the functions return Unbounded_String and leave conversion to Bounded_String or String to the client. with Ada.Text_IO; use Ada.Text_IO; generic Max_Length : in Positive := 260; Default_Initial_Length : in Positive := 32; Length_Expansion_Numerator : in Positive := 3; Length_Expansion_Denominator : in Positive := 2; -- N.B. 260 = 32 + 32*3/2 + (32*3/2)*3/2 + ((32*3/2)*3/2)*3/2 -- giving efficiency points at 32, 80, 152, 260, ... package Generic_Get_Line_Functions is -- To get a string of bounded, but unknown, length, -- from a text file; as a (fixed) String. -- These functions ALWAYS consume the end-of-line mark. -- The following return a string of generic maximum length Max_Length. function Get_Line return String; --from Current_Input function Get_Line (Source : File_Type) return String; -- from Source -- The following return a string of specified maximum length Max_Length. function Get_Line (Estimated_Initial_Length, Max_Length : Positive) return String; --from Current_Input function Get_Line (Source : File_Type; Estimated_Initial_Length, Max_Length : Positive) return String; -- from Source end Generic_Get_Line_Functions; -- Bill:Findlay chez Blue:Yonder dot:co:dot:uk (":" => "")