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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 From: "Arie van Wingerden" Newsgroups: comp.lang.ada References: In-Reply-To: Subject: Re: Question on bounded / unbounded strings Date: Wed, 14 Sep 2016 14:57:32 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 Message-ID: Organization: Powered by cheapnews.eu Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feed.abavia.com!fbe001.abavia.com!abp001.abavia.com!news.cheapnews.eu!not-for-mail Injection-Date: Wed, 14 Sep 2016 14:57:35 +0200 Injection-Info: news.cheapnews.eu; mail-complaints-to="abuse@cheapnews.eu" Xref: news.eternal-september.org comp.lang.ada:31785 Date: 2016-09-14T14:57:32+02:00 List-Id: I finished the program. It appears to be working correctly (only in Windows, because of the path separator). Any comments to improve? Code follows: =========== with Ada.Text_Io; with Ada.Environment_Variables; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; procedure Fip is package ATIO renames Ada.Text_IO; package AEV renames Ada.Environment_Variables; package ASF renames Ada.Strings.Fixed; package ASMC renames Ada.Strings.Maps.Constants; Path : string := ASF.Translate(AEV.Value("Path"), ASMC.Lower_Case_Map); Match : string := ASF.Translate(ATIO.Get_Line, ASMC.Lower_Case_Map); procedure FindMatch (Match : in string; Path : in string; StartPos : in positive; Len : in natural) is EndPos : positive; begin if Len > 0 then -- Ignore case of an unnecessary semi colon EndPos := StartPos + Len - 1; if ASF.Index(Source => Path(StartPos .. EndPos), Pattern => Match) > 0 then ATIO.Put_Line(Path(StartPos .. EndPos)); end if; end if; end FindMatch; procedure Match_Path (Match : in string; Path : in string) is StartPos : positive := 1; Len : natural := 0; begin for I in Path'Range loop if Path(I) = ';' then FindMatch(Match, Path, StartPos, Len); StartPos := I + 1; Len := 0; else Len := Len + 1; end if; end loop; end Match_Path; begin Match_Path(Match, Path); ATIO.Flush; end Fip;