diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index ec22a250b0..f7241ef287 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -520,6 +520,24 @@ begin end; +{ Faster version for a char alone. Must be implemented because } +{ pos(c: char; const s: shortstring) also exists, so otherwise } +{ using pos(char,pchar) will always call the shortstring version } +{ (exact match for first argument), also with $h+ (JM) } +Function Pos (c : Char; Const s : AnsiString) : Longint; +var + i: longint; +begin + for i:=1 to length(s) do + if s[i]=c then + begin + pos:=i; + exit; + end; + pos:=0; +end; + + Function ValAnsiFloat(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR']; Var SS : String; @@ -668,7 +686,13 @@ end; { $Log$ - Revision 1.7 2000-11-06 20:34:24 peter + Revision 1.8 2000-12-08 14:04:43 jonas + + added pos(char,ansistring), because there is also a pos(char,shortstring) + and without the ansistring version, the shortstring version is always + called when calling pos(char,pchar), even when using $h+ (because the + first parameter matches exactly) (merged) + + Revision 1.7 2000/11/06 20:34:24 peter * changed ver1_0 defines to temporary defs Revision 1.6 2000/10/21 18:20:17 florian diff --git a/rtl/inc/systemh.inc b/rtl/inc/systemh.inc index f61b65dd52..1b6b45dcd7 100644 --- a/rtl/inc/systemh.inc +++ b/rtl/inc/systemh.inc @@ -312,6 +312,7 @@ Procedure UniqueString (Var S : AnsiString); Function Length (Const S : AnsiString) : Longint; Function Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString; Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : Longint; +Function Pos (c : Char; Const s : AnsiString) : Longint; Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : Longint); Procedure Delete (Var S : AnsiString; Index,Size: Longint); Function StringOfChar(c : char;l : longint) : AnsiString; @@ -485,7 +486,13 @@ const { $Log$ - Revision 1.13 2000-12-07 17:19:47 jonas + Revision 1.14 2000-12-08 14:04:43 jonas + + added pos(char,ansistring), because there is also a pos(char,shortstring) + and without the ansistring version, the shortstring version is always + called when calling pos(char,pchar), even when using $h+ (because the + first parameter matches exactly) (merged) + + Revision 1.13 2000/12/07 17:19:47 jonas * new constant handling: from now on, hex constants >$7fffffff are parsed as unsigned constants (otherwise, $80000000 got sign extended and became $ffffffff80000000), all constants in the longint range