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-Thread: 103376,a0833bbed8752e1f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!proxad.net!freenix!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Sender: obry@PASCAL Newsgroups: comp.lang.ada Subject: Re: variable lenght strings References: <1861614.TWv5A9FgVL@linux1.krischik.com> <4178e979_1@baen1673807.greenlnk.net> <1195374.UMjBCk7lO1@linux1.krischik.com> <1154613.ipZcUgduzp@linux1.krischik.com> <1174011.lJ1dcgRM3Q@linux1.krischik.com> From: Pascal Obry Date: 26 Oct 2004 19:37:12 +0200 Message-ID: Organization: Home - http://www.obry.org User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: AVelizy-151-2-3-137.w82-120.abo.wanadoo.fr X-Trace: 1098812237 news.wanadoo.fr 3797 82.120.29.137:2106 X-Complaints-To: abuse@wanadoo.fr Xref: g2news1.google.com comp.lang.ada:5727 Date: 2004-10-26T19:37:12+02:00 List-Id: Martin Krischik writes: > ���function�Get_Line�( > ������File�:�in�IO.File_Type) > ���return > ������String > ���is > ������Buffer�:�String�(1�..�BufferSize); > ������Last���:�Natural; > ���begin > ������IO.Get_Line�( > ���������File�=>�File, > ���������Item�=>�Buffer, > ���������Last�=>�Last); > > ������if�Last�<�Buffer'Last�then > ���������return�Buffer�(1�..�Last); > ������elsif�IO.End_Of_File�(File)�then > ���������return�Buffer; > ������else > ���������return�Buffer�&�Get_Line�(File); ^^^^^^^^^^^^^^^^^^^^^^^^^^ This kind of recursivity is very dangerous and could cause a stack overflow. It is better to use a non recursive version and to store the result into an Unbounded_String for example. PAscal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.org --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595