comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Parsing a line into strings
Date: 1998/07/09
Date: 1998-07-09T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.3.96.980709120550.22300A-100000@shell5.ba.best.com> (raw)
In-Reply-To: dewar.899946103@merv

On 8 Jul 1998, Robert Dewar wrote:
> 
> In fact GNAT.Spitbol uses Unrestricted_Access in a pretty fundamental
> way, having nothing at all to do with downward funargs!

That sound you hear is me removing my foot from my mouth :-)

In order to do penance, I have to post Ada code. Since the original poster 
was asking for the functionality of strtok in Ada, let me take a stab at
it; note that I won't diddle the state of the string like strtok does, but 
this is pretty much it. Since the caller knows the start position its easy
to use slices to extract the "tokens". Hacked and not tested, as usual :-)

-- Brian

with Ada.Strings.Maps;
use Ada.Strings.Maps;

procedure String_Separator_Position (Input : in String ; 
                                     Separators : in Character_Set;
                                     Start : in out Integer) is 
    Pos : Integer := Start;
begin
    if Start < Input'First or Start > Input'Last then 
        return; -- or raise an exception, or whatever...
    end if;

    for I in Start .. Input'Last loop
        if Is_In(Input(I),Separators) then 
            Start := I;
            return;
        end if;
    end loop;
end String_Separator_Position;


    





  reply	other threads:[~1998-07-09  0:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-08  0:00 Parsing a line into strings C N
1998-07-08  0:00 ` Samuel Tardieu
1998-07-08  0:00   ` C N
1998-07-09  0:00     ` Dmitriy Anisimkov
1998-07-08  0:00       ` Brian Rogoff
1998-07-08  0:00         ` nabbasi
1998-07-09  0:00           ` Robert Dewar
1998-07-09  0:00             ` Michael F Brenner
1998-07-14  0:00             ` Norman H. Cohen
1998-07-15  0:00               ` Robert I. Eachus
1998-07-18  0:00                 ` Robert Dewar
1998-07-08  0:00         ` Robert Dewar
1998-07-09  0:00           ` Brian Rogoff [this message]
1998-07-09  0:00 ` Dale Stanbrough
1998-07-09  0:00 ` dennison
1998-07-09  0:00 ` Darren Davenport
1998-07-10  0:00   ` Robert I. Eachus
1998-07-11  0:00 ` david.c.hoos.sr
replies disabled

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