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,d54559bde05f5bb8,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!w39g2000prb.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Weird string I/O problem Date: Tue, 25 Nov 2008 21:52:02 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 75.171.118.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1227678723 24129 127.0.0.1 (26 Nov 2008 05:52:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 26 Nov 2008 05:52:03 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w39g2000prb.googlegroups.com; posting-host=75.171.118.178; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/525.18 (KHTML, like Gecko, Safari/525.20) OmniWeb/v622.3.0.105198,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2792 Date: 2008-11-25T21:52:02-08:00 List-Id: The following program misbehaves if the line Get(A_Float); -- PROBLEMATIC LINE is present; the call to Get_Line is made but there is no opportunity for the user to enter a string--the program continues (I suppose) as though the user entered a line terminator, causing the following output: Enter a float: 12.3 Enter a string: Hello from Get_Line. Your string was It was 0 long. However, if the problematic line is commented out, the following occurs: Enter a float: Enter a string: Hello from Get_Line. bla bla Your string was bla bla It was 7 long. Here is the program: with Ada.Text_IO, Ada.Float_Text_IO, Ada.Strings.Unbounded; use Ada.Text_IO, Ada.Float_Text_IO, Ada.Strings.Unbounded; procedure temp1 is -- Crude Get_Line for unbounded strings. procedure Get_Line(An_Unbounded_String : out Unbounded_String) is Max_Length : Integer := 256; A_String : String(1 .. Max_Length); Length : Integer; begin Put_Line("Hello from Get_Line."); Get_Line(A_String, Length); An_Unbounded_String := To_Unbounded_String(A_String(1 .. Length)); end Get_Line; UBS : Unbounded_String; A_Float : Float; begin Put("Enter a float: "); Get(A_Float); -- PROBLEMATIC LINE Put("Enter a string: "); Get_Line(UBS); Put_Line("Your string was " & To_String(UBS)); Put_Line("It was" & Length(UBS)'img & " long."); end temp1; What is going on here? I am running GNAT 4.3 on OS X 10.4. Jerry