comp.lang.ada
 help / color / mirror / Atom feed
* Problem with unbounded string input
@ 2021-01-27 19:59 Brian McGuinness
  2021-01-27 21:42 ` Jeffrey R. Carter
  2021-01-27 23:09 ` Shark8
  0 siblings, 2 replies; 4+ messages in thread
From: Brian McGuinness @ 2021-01-27 19:59 UTC (permalink / raw)


I was having trouble reading unbounded strings, so I wrote a short test program and had the same problem.

with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;

procedure scan2 is
  use Ada.Strings.Unbounded;
  line : Ada.Strings.Unbounded.Unbounded_String;
begin
  loop
    Ada.Text_IO.Put ("-> ");
    line := Ada.Text_IO.Unbounded_IO.Get_Line;
    exit when line = "quit";
    Ada.Text_IO.Unbounded_IO.Put_Line ("""" & line & """");
  end loop;
end scan2;

When I compile this with gnatmake 8.3.0 under Linux Mint Debian edition 4 and run it, every so often when I type a line and hit Enter there is no response until I hit Enter again, and then everything typed before the first Enter is ignored.  The rest of the time the lines I type are read and returned correctly.  I am really puzzled by this.  Is this a bug in the Ada library or am I doing something wrong?

--- Brian McGuinness

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with unbounded string input
  2021-01-27 19:59 Problem with unbounded string input Brian McGuinness
@ 2021-01-27 21:42 ` Jeffrey R. Carter
  2021-01-27 23:09 ` Shark8
  1 sibling, 0 replies; 4+ messages in thread
From: Jeffrey R. Carter @ 2021-01-27 21:42 UTC (permalink / raw)


On 1/27/21 8:59 PM, Brian McGuinness wrote:
> 
> When I compile this with gnatmake 8.3.0 under Linux Mint Debian edition 4 and run it, every so often when I type a line and hit Enter there is no response until I hit Enter again, and then everything typed before the first Enter is ignored.  The rest of the time the lines I type are read and returned correctly.  I am really puzzled by this.  Is this a bug in the Ada library or am I doing something wrong?

You didn't say how often "every so often" tends to be, but with GNAT 9.3/Xubuntu 
20.10 I input several dozen lines without problem.

Why do you use """" when '"' is clearer?

-- 
Jeff Carter
"[T]he language [Ada] incorporates many excellent structural
features which have proved their value in many precursor
languages ..."
C. A. R. Hoare
180

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with unbounded string input
  2021-01-27 19:59 Problem with unbounded string input Brian McGuinness
  2021-01-27 21:42 ` Jeffrey R. Carter
@ 2021-01-27 23:09 ` Shark8
  2021-01-28 18:58   ` Brian McGuinness
  1 sibling, 1 reply; 4+ messages in thread
From: Shark8 @ 2021-01-27 23:09 UTC (permalink / raw)


On Wednesday, January 27, 2021 at 12:59:18 PM UTC-7, Brian McGuinness wrote:
> I was having trouble reading unbounded strings, so I wrote a short test program and had the same problem. 
> 
> 
> When I compile this with gnatmake 8.3.0 under Linux Mint Debian edition 4 and run it, every so often when I type a line and hit Enter there is no response until I hit Enter again, and then everything typed before the first Enter is ignored. The rest of the time the lines I type are read and returned correctly. I am really puzzled by this. Is this a bug in the Ada library or am I doing something wrong? 

I've had this problem before, though it was using normal strings; IIRC the issue is that sometimes there's "stuff" in your input buffer and this can be handled [IIRC] via flush.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with unbounded string input
  2021-01-27 23:09 ` Shark8
@ 2021-01-28 18:58   ` Brian McGuinness
  0 siblings, 0 replies; 4+ messages in thread
From: Brian McGuinness @ 2021-01-28 18:58 UTC (permalink / raw)


On Wednesday, January 27, 2021 at 6:09:18 PM UTC-5, Shark8 wrote:
> On Wednesday, January 27, 2021 at 12:59:18 PM UTC-7, Brian McGuinness wrote: 
> > I was having trouble reading unbounded strings, so I wrote a short test program and had the same problem. 
> > 
> >
> > When I compile this with gnatmake 8.3.0 under Linux Mint Debian edition 4 and run it, every so often when I type a line and hit Enter there is no response until I hit Enter again, and then everything typed before the first Enter is ignored. The rest of the time the lines I type are read and returned correctly. I am really puzzled by this. Is this a bug in the Ada library or am I doing something wrong?
> I've had this problem before, though it was using normal strings; IIRC the issue is that sometimes there's "stuff" in your input buffer and this can be handled [IIRC] via flush.

Ok.  Thanks for the help.

I used """" because I was thinking of later adding more text between the quotes, but your point is good.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-28 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 19:59 Problem with unbounded string input Brian McGuinness
2021-01-27 21:42 ` Jeffrey R. Carter
2021-01-27 23:09 ` Shark8
2021-01-28 18:58   ` Brian McGuinness

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox