[fpc-devel]Fix To StrUtils.PosExe

Marco van de Voort marcov at stack.nl
Mon May 17 09:31:30 CEST 2004

> Here is the fixed version:
> Function PosEx(const SubStr, S: string; Offset: Cardinal): Integer;
> var i : pchar;
> begin
>    if (offset<1) or (offset>length(s)) then exit(0);
>    i:=strpos(@s[offset], at substr[1]); //Changed here
>    if i=nil then
>      PosEx:=0
>    else
>      PosEx:=Succ(i-pchar(s)); // And here
> end;
> In my program it is working properly, but more tests are wellcome/necessary

Committed, thnx the old code (mine actually) was totally flawed (and
untested). I added most of the string routines in 1 1/2 hour.

If you find more problems, don't hesitate to report them :-)

More information about the fpc-devel mailing list