|
@@ -1160,7 +1160,7 @@ end;
|
|
|
|
|
|
{$ifndef FPC_HAS_POS_UNICODESTR_UNICODESTR}
|
|
{$ifndef FPC_HAS_POS_UNICODESTR_UNICODESTR}
|
|
{$define FPC_HAS_POS_UNICODESTR_UNICODESTR}
|
|
{$define FPC_HAS_POS_UNICODESTR_UNICODESTR}
|
|
-Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString) : SizeInt;
|
|
var
|
|
var
|
|
i,MaxLen : SizeInt;
|
|
i,MaxLen : SizeInt;
|
|
pc : punicodechar;
|
|
pc : punicodechar;
|
|
@@ -1168,9 +1168,9 @@ begin
|
|
Pos:=0;
|
|
Pos:=0;
|
|
if Length(SubStr)>0 then
|
|
if Length(SubStr)>0 then
|
|
begin
|
|
begin
|
|
- MaxLen:=Length(source)-Length(SubStr)-(OffSet-1);
|
|
|
|
|
|
+ MaxLen:=Length(source)-Length(SubStr);
|
|
i:=0;
|
|
i:=0;
|
|
- pc:=@source[OffSet];
|
|
|
|
|
|
+ pc:=@source[1];
|
|
while (i<=MaxLen) do
|
|
while (i<=MaxLen) do
|
|
begin
|
|
begin
|
|
inc(i);
|
|
inc(i);
|
|
@@ -1190,13 +1190,13 @@ end;
|
|
{$ifndef FPC_HAS_POS_UNICODECHAR_UNICODESTR}
|
|
{$ifndef FPC_HAS_POS_UNICODECHAR_UNICODESTR}
|
|
{$define FPC_HAS_POS_UNICODECHAR_UNICODESTR}
|
|
{$define FPC_HAS_POS_UNICODECHAR_UNICODESTR}
|
|
{ Faster version for a unicodechar alone }
|
|
{ Faster version for a unicodechar alone }
|
|
-Function Pos (c : UnicodeChar; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (c : UnicodeChar; Const s : UnicodeString) : SizeInt;
|
|
var
|
|
var
|
|
i: SizeInt;
|
|
i: SizeInt;
|
|
pc : punicodechar;
|
|
pc : punicodechar;
|
|
begin
|
|
begin
|
|
- pc:=@s[OffSet];
|
|
|
|
- for i:=OffSet to length(s) do
|
|
|
|
|
|
+ pc:=@s[1];
|
|
|
|
+ for i:=1 to length(s) do
|
|
begin
|
|
begin
|
|
if pc^=c then
|
|
if pc^=c then
|
|
begin
|
|
begin
|
|
@@ -1212,21 +1212,21 @@ end;
|
|
|
|
|
|
{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
|
|
{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
|
|
block, which is significant bloat without any sensible speed improvement. }
|
|
block, which is significant bloat without any sensible speed improvement. }
|
|
-Function Pos (const c : RawByteString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (const c : RawByteString; Const s : UnicodeString) : SizeInt;
|
|
begin
|
|
begin
|
|
- result:=Pos(UnicodeString(c),s,offset);
|
|
|
|
|
|
+ result:=Pos(UnicodeString(c),s);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-Function Pos (const c : ShortString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (const c : ShortString; Const s : UnicodeString) : SizeInt;
|
|
begin
|
|
begin
|
|
- result:=Pos(UnicodeString(c),s,OffSet);
|
|
|
|
|
|
+ result:=Pos(UnicodeString(c),s);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-Function Pos (const c : UnicodeString; Const s : RawByteString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (const c : UnicodeString; Const s : RawByteString) : SizeInt;
|
|
begin
|
|
begin
|
|
- result:=Pos(c,UnicodeString(s),OffSet);
|
|
|
|
|
|
+ result:=Pos(c,UnicodeString(s));
|
|
end;
|
|
end;
|
|
|
|
|
|
{$ifndef FPC_HAS_POS_CHAR_UNICODESTR}
|
|
{$ifndef FPC_HAS_POS_CHAR_UNICODESTR}
|
|
@@ -1235,15 +1235,15 @@ Function Pos (const c : UnicodeString; Const s : RawByteString; Offset: Sizeint
|
|
{ pos(c: char; const s: shortstring) also exists, so otherwise }
|
|
{ pos(c: char; const s: shortstring) also exists, so otherwise }
|
|
{ using pos(char,pchar) will always call the shortstring version }
|
|
{ using pos(char,pchar) will always call the shortstring version }
|
|
{ (exact match for first argument), also with $h+ (JM) }
|
|
{ (exact match for first argument), also with $h+ (JM) }
|
|
-Function Pos (c : Char; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
|
|
|
|
|
|
+Function Pos (c : Char; Const s : UnicodeString) : SizeInt;
|
|
var
|
|
var
|
|
i: SizeInt;
|
|
i: SizeInt;
|
|
wc : unicodechar;
|
|
wc : unicodechar;
|
|
pc : punicodechar;
|
|
pc : punicodechar;
|
|
begin
|
|
begin
|
|
wc:=c;
|
|
wc:=c;
|
|
- pc:=@s[OffSet];
|
|
|
|
- for i:=OffSet to length(s) do
|
|
|
|
|
|
+ pc:=@s[1];
|
|
|
|
+ for i:=1 to length(s) do
|
|
begin
|
|
begin
|
|
if pc^=wc then
|
|
if pc^=wc then
|
|
begin
|
|
begin
|