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: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public From: behrends@cse.msu.edu (Reimer Behrends) Subject: Re: Software landmines (loops) Date: 1998/09/17 Message-ID: #1/1 X-Deja-AN: 391981531 References: <35f51e53.48044143@ <35EEF597.A1119EF4@draper.com> <35F5B529.6DC6A59A@draper.com> Organization: Michigan State University Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-17T00:00:00+00:00 List-Id: Matthew Heaney (matthew_heaney@acm.org) wrote: [...] > Last : Natural := 0; > begin > for Index in reverse S'Range loop > if S (Index) /= ' ' then > Last := Index; > exit; > end if; > end loop; > > {R: Last = 0 or else S (Last) /= ' '} feature { ANY } last_non_blank(s: STRING): INTEGER is local pos: INTEGER do from pos := s.count until pos = 0 or else s @ pos /= ' ' loop pos := pos - 1 end Result := pos ensure Result = 0 or else s @ Result /= ' ' end Reimer Behrends