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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7fc767abbf17c947 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Parsing a line into strings Date: 1998/07/09 Message-ID: #1/1 X-Deja-AN: 369962861 References: <35A3A199.D55C3153@oit.edu> <35A3AB67.9039CBA9@oit.edu> <35A40A94.6DB73E65@chat.ru> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: 900012729 29842 bpr 206.184.139.132 Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-07-09T00:00:00+00:00 List-Id: 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;