comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthewjheaney@earthlink.net>
Subject: Re: Terminating a task
Date: Wed, 16 Jul 2003 05:00:41 GMT
Date: 2003-07-16T05:00:41+00:00	[thread overview]
Message-ID: <ZZ4Ra.103363$Io.8887132@newsread2.prod.itd.earthlink.net> (raw)
In-Reply-To: 3F148227.6060702@attbi.com


"Robert I. Eachus" <rieachus@attbi.com> wrote in message
news:3F148227.6060702@attbi.com...
>
> If you change:
>         if Last < Line'Last then...
>
> to:
>         if End_of_Line then
>            Word := False;
>            NL := NL + 1;
>         end if;
>
> maybe that will end the 'discussion' about whether it is possible to
> count lines properly in Ada.

Why should this make a difference?  The idiom in my example is per Ada83
AI-50.

What does End_Of_Line do, that Last < Line'Last does not?


>Oh, you might want to stick:
>
>      exit when End_of_File;
>
> after the call to Get_Line.  Of course the need to do that or not
> depends on the number of lines and characters you want to count for the
> implict End_of_Page at the end of the file.

The canonical wc program in the shootout seems to count the line terminator
among the count of characters.  The program I posted does not.  To make the
outputs match all you'd need to do is add the line count to the character
count, to make up the difference.

Other than that, given the input.txt file at the shootout page, the wc
program I posted gives the correct results.  So I'm not sure why anyone
thinks there is a problem.  Except for the interpretation of character
count, as far as I can tell the program I wrote is correct as is.

> Notice that with these
> changes your program should work fine even if you set Line to
> String(1..10);

But that's true even without your changes.  In fact before I posted the
program, I tested it using String (1 .. 5) as the subtype indication, and it
worked fine.

-Matt





  reply	other threads:[~2003-07-16  5:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-12 14:03 Terminating a task kat-Zygfryd
2003-07-12 14:37 ` kat-Zygfryd
2003-07-14  9:34   ` Craig Carey
2003-07-14 23:45     ` Matthew Heaney
2003-07-15 17:49       ` Craig Carey
2003-07-15 18:30         ` David C. Hoos
2003-07-16  5:26         ` Matthew Heaney
2003-07-15 22:37       ` Robert I. Eachus
2003-07-16  5:00         ` Matthew Heaney [this message]
2003-07-16 18:19           ` Robert I. Eachus
replies disabled

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