summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2016-05-25 20:35:29 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2016-05-25 20:35:29 +0000
commit8a6271dbd40eba8435ca70555fbe5881c25d19f4 (patch)
tree9cb85e614d4cfefe976da861bd84a675da8b455e
parentdd09e33215e8ce56117e93042ace7aa0581966f8 (diff)
downloadfpc-8a6271dbd40eba8435ca70555fbe5881c25d19f4.tar.gz
reverse merge of r31464,r31468,r33056
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/fixes_3_0@33802 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/inc/astrings.inc25
-rw-r--r--rtl/inc/sstrings.inc21
-rw-r--r--rtl/inc/systemh.inc12
-rw-r--r--rtl/inc/ustringh.inc12
-rw-r--r--rtl/inc/ustrings.inc30
-rw-r--r--rtl/inc/wstrings.inc43
-rw-r--r--rtl/java/jsystemh.inc2
7 files changed, 67 insertions, 78 deletions
diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc
index dfd2f4c2e2..af86f334c4 100644
--- a/rtl/inc/astrings.inc
+++ b/rtl/inc/astrings.inc
@@ -915,18 +915,18 @@ end;
{$ifndef FPC_HAS_POS_SHORTSTR_ANSISTR}
{$define FPC_HAS_POS_SHORTSTR_ANSISTR}
-Function Pos(Const Substr : ShortString; Const Source : RawByteString; Offset : Sizeint = 1) : SizeInt;
+Function Pos(Const Substr : ShortString; Const Source : RawByteString) : SizeInt;
var
i,MaxLen : SizeInt;
pc : PAnsiChar;
begin
Pos:=0;
- if (Length(SubStr)>0) and (Offset>0) and (Offset<=Length(Source)) then
+ if Length(SubStr)>0 then
begin
MaxLen:=Length(source)-Length(SubStr);
- i:=Offset-1;
- pc:=@source[Offset];
+ i:=0;
+ pc:=@source[1];
while (i<=MaxLen) do
begin
inc(i);
@@ -945,17 +945,17 @@ end;
{$ifndef FPC_HAS_POS_ANSISTR_ANSISTR}
{$define FPC_HAS_POS_ANSISTR_ANSISTR}
-Function Pos(Const Substr : RawByteString; Const Source : RawByteString; Offset : Sizeint = 1) : SizeInt;
+Function Pos(Const Substr : RawByteString; Const Source : RawByteString) : SizeInt;
var
i,MaxLen : SizeInt;
pc : PAnsiChar;
begin
Pos:=0;
- if (Length(SubStr)>0) and (Offset>0) and (Offset<=Length(Source)) then
+ if Length(SubStr)>0 then
begin
MaxLen:=Length(source)-Length(SubStr);
- i:=Offset-1;
- pc:=@source[Offset];
+ i:=0;
+ pc:=@source[1];
while (i<=MaxLen) do
begin
inc(i);
@@ -978,16 +978,13 @@ end;
{ 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 : AnsiChar; Const s : RawByteString; Offset : Sizeint = 1) : SizeInt;
+Function Pos(c : AnsiChar; Const s : RawByteString) : SizeInt;
var
i: SizeInt;
pc : PAnsiChar;
begin
- Pos:=0;
- If (Offset<1) or (Offset>Length(S)) then
- exit;
- pc:=@s[OffSet];
- for i:=Offset to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=c then
begin
diff --git a/rtl/inc/sstrings.inc b/rtl/inc/sstrings.inc
index 62147205b4..f16f2c910f 100644
--- a/rtl/inc/sstrings.inc
+++ b/rtl/inc/sstrings.inc
@@ -125,17 +125,17 @@ end;
{$ifndef FPC_HAS_SHORTSTR_POS_SHORTSTR}
{$define FPC_HAS_SHORTSTR_POS_SHORTSTR}
-function pos(const substr : shortstring;const s : shortstring; Offset : Sizeint = 1):SizeInt;
+function pos(const substr : shortstring;const s : shortstring):SizeInt;
var
i,MaxLen : SizeInt;
pc : pchar;
begin
Pos:=0;
- if (Length(SubStr)>0) and (Offset>0) and (Offset<=Length(S)) then
+ if Length(SubStr)>0 then
begin
MaxLen:=sizeint(Length(s))-Length(SubStr);
- i:=Offset-1;
- pc:=@s[Offset];
+ i:=0;
+ pc:=@s[1];
while (i<=MaxLen) do
begin
inc(i);
@@ -155,16 +155,13 @@ end;
{$ifndef FPC_HAS_SHORTSTR_POS_CHAR}
{$define FPC_HAS_SHORTSTR_POS_CHAR}
{Faster when looking for a single char...}
-function pos(c:char;const s:shortstring; Offset : Sizeint = 1 ):SizeInt;
+function pos(c:char;const s:shortstring):SizeInt;
var
i : SizeInt;
pc : pchar;
begin
- Pos:=0;
- if (Offset<1) or (Offset>Length(S)) then
- exit;
- pc:=@s[Offset];
- for i:=Offset to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=c then
begin
@@ -186,9 +183,9 @@ begin
fpc_char_Copy:='';
end;
-function pos(const substr : shortstring;c:char; Offset : Sizeint = 1): SizeInt;
+function pos(const substr : shortstring;c:char): SizeInt;
begin
- if (length(substr)=1) and (substr[1]=c) and (Offset=1) then
+ if (length(substr)=1) and (substr[1]=c) then
Pos:=1
else
Pos:=0;
diff --git a/rtl/inc/systemh.inc b/rtl/inc/systemh.inc
index 9874ad176c..5f7ed3fb93 100644
--- a/rtl/inc/systemh.inc
+++ b/rtl/inc/systemh.inc
@@ -1082,10 +1082,10 @@ function Utf8CodePointLen(P: PAnsiChar; MaxLookAhead: SizeInt; IncludeCombiningD
Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);
Procedure Insert(const source:shortstring;var s:shortstring;index:SizeInt);
Procedure Insert(source:Char;var s:shortstring;index:SizeInt);
-Function Pos(const substr:shortstring;const s:shortstring; Offset: Sizeint = 1):SizeInt;
-Function Pos(C:Char;const s:shortstring; Offset: Sizeint = 1):SizeInt;
+Function Pos(const substr:shortstring;const s:shortstring):SizeInt;
+Function Pos(C:Char;const s:shortstring):SizeInt;
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-Function Pos(const Substr : ShortString; const Source : RawByteString; Offset: Sizeint = 1) : SizeInt;
+Function Pos(const Substr : ShortString; const Source : RawByteString) : SizeInt;
{$ifdef FPC_HAS_CPSTRING}
Procedure fpc_setstring_ansistr_pansichar(out S : RawByteString; Buf : PAnsiChar; Len : SizeInt; cp: TSystemCodePage); rtlproc; compilerproc;
@@ -1121,7 +1121,7 @@ Function hexStr(Val:Pointer):shortstring;
Function chr(b : byte) : Char; [INTERNPROC: fpc_in_chr_byte];
Function upCase(c:Char):Char;
Function lowerCase(c:Char):Char; overload;
-function pos(const substr : shortstring;c:char; Offset: Sizeint = 1): SizeInt;
+function pos(const substr : shortstring;c:char): SizeInt;
{****************************************************************************
@@ -1130,8 +1130,8 @@ function pos(const substr : shortstring;c:char; Offset: Sizeint = 1): SizeInt;
{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
Procedure UniqueString(var S : RawByteString);{$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif FPC_HAS_CPSTRING}external name 'FPC_ANSISTR_UNIQUE';
-Function Pos (const Substr : RawByteString; const Source : RawByteString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (c : AnsiChar; const s : RawByteString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (const Substr : RawByteString; const Source : RawByteString) : SizeInt;
+Function Pos (c : AnsiChar; const s : RawByteString) : SizeInt;
Procedure Insert (const Source : RawByteString; var S : RawByteString; Index : SizeInt);{$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif FPC_HAS_CPSTRING}
Procedure Delete (var S : RawByteString; Index,Size: SizeInt);{$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif FPC_HAS_CPSTRING}
Function StringOfChar(c : Ansichar;l : SizeInt) : AnsiString;
diff --git a/rtl/inc/ustringh.inc b/rtl/inc/ustringh.inc
index 7fa95686f1..502e9bd852 100644
--- a/rtl/inc/ustringh.inc
+++ b/rtl/inc/ustringh.inc
@@ -16,12 +16,12 @@
Procedure UniqueString (Var S : UnicodeString);external name 'FPC_UNICODESTR_UNIQUE';
-Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (c : Char; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (c : UnicodeChar; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (const c : RawByteString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (const c : UnicodeString; Const s : RawByteString; Offset: Sizeint = 1) : SizeInt;
-Function Pos (const c : ShortString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (Const Substr : UnicodeString; Const Source : UnicodeString) : SizeInt;
+Function Pos (c : Char; Const s : UnicodeString) : SizeInt;
+Function Pos (c : UnicodeChar; Const s : UnicodeString) : SizeInt;
+Function Pos (const c : RawByteString; Const s : UnicodeString) : SizeInt;
+Function Pos (const c : UnicodeString; Const s : RawByteString) : SizeInt;
+Function Pos (const c : ShortString; Const s : UnicodeString) : SizeInt;
Function UpCase(const s : UnicodeString) : UnicodeString;
Function UpCase(c:UnicodeChar):UnicodeChar;
diff --git a/rtl/inc/ustrings.inc b/rtl/inc/ustrings.inc
index 631e8f7b27..88b0cb21fb 100644
--- a/rtl/inc/ustrings.inc
+++ b/rtl/inc/ustrings.inc
@@ -1160,7 +1160,7 @@ end;
{$ifndef 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
i,MaxLen : SizeInt;
pc : punicodechar;
@@ -1168,9 +1168,9 @@ begin
Pos:=0;
if Length(SubStr)>0 then
begin
- MaxLen:=Length(source)-Length(SubStr)-(OffSet-1);
+ MaxLen:=Length(source)-Length(SubStr);
i:=0;
- pc:=@source[OffSet];
+ pc:=@source[1];
while (i<=MaxLen) do
begin
inc(i);
@@ -1190,13 +1190,13 @@ end;
{$ifndef FPC_HAS_POS_UNICODECHAR_UNICODESTR}
{$define FPC_HAS_POS_UNICODECHAR_UNICODESTR}
{ 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
i: SizeInt;
pc : punicodechar;
begin
- pc:=@s[OffSet];
- for i:=OffSet to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=c then
begin
@@ -1212,21 +1212,21 @@ end;
{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
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
- result:=Pos(UnicodeString(c),s,offset);
+ result:=Pos(UnicodeString(c),s);
end;
-Function Pos (const c : ShortString; Const s : UnicodeString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (const c : ShortString; Const s : UnicodeString) : SizeInt;
begin
- result:=Pos(UnicodeString(c),s,OffSet);
+ result:=Pos(UnicodeString(c),s);
end;
-Function Pos (const c : UnicodeString; Const s : RawByteString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (const c : UnicodeString; Const s : RawByteString) : SizeInt;
begin
- result:=Pos(c,UnicodeString(s),OffSet);
+ result:=Pos(c,UnicodeString(s));
end;
{$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 }
{ 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 : UnicodeString; Offset: Sizeint = 1) : SizeInt;
+Function Pos (c : Char; Const s : UnicodeString) : SizeInt;
var
i: SizeInt;
wc : unicodechar;
pc : punicodechar;
begin
wc:=c;
- pc:=@s[OffSet];
- for i:=OffSet to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=wc then
begin
diff --git a/rtl/inc/wstrings.inc b/rtl/inc/wstrings.inc
index 364ae8f5ad..60f0cab1e0 100644
--- a/rtl/inc/wstrings.inc
+++ b/rtl/inc/wstrings.inc
@@ -578,17 +578,17 @@ begin
end;
-Function Pos (Const Substr : WideString; Const Source : WideString; Offset : SizeInt = 1) : SizeInt;
+Function Pos (Const Substr : WideString; Const Source : WideString) : SizeInt;
var
i,MaxLen : SizeInt;
pc : pwidechar;
begin
Pos:=0;
- if (Length(SubStr)>0) and (Offset>0) and (Offset<Length(Source)) then
+ if Length(SubStr)>0 then
begin
MaxLen:=Length(source)-Length(SubStr)-(OffSet-1);
- i:=Offset-1;
- pc:=@source[Offset];
+ i:=0;
+ pc:=@source[1];
while (i<=MaxLen) do
begin
inc(i);
@@ -605,15 +605,13 @@ end;
{ Faster version for a widechar alone }
-Function Pos (c : WideChar; Const s : WideString; Offset : Sizeint = 1) : SizeInt;
+Function Pos (c : WideChar; Const s : WideString) : SizeInt;
var
i: SizeInt;
pc : pwidechar;
begin
- pos:=0;
- if (Offset<1) or (Offset>Length(s)) then exit;
- pc:=@s[Offset];
- for i:=Offset to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=c then
begin
@@ -622,50 +620,47 @@ begin
end;
inc(pc);
end;
+ pos:=0;
end;
{ DO NOT inline these! Inlining a managed typecast creates an implicit try..finally
block, which is significant bloat without any sensible speed improvement. }
-Function Pos (c : WideChar; Const s : RawByteString; Offset : SizeInt = 1) : SizeInt;
+Function Pos (c : WideChar; Const s : RawByteString) : SizeInt;
begin
- result:=Pos(c,WideString(s),Offset);
+ result:=Pos(c,WideString(s));
end;
-Function Pos (const c : RawByteString; Const s : WideString;Offset : SizeInt = 1) : SizeInt;
+Function Pos (const c : RawByteString; Const s : WideString) : SizeInt;
begin
- result:=Pos(WideString(c),s,Offset);
+ result:=Pos(WideString(c),s);
end;
-Function Pos (const c : ShortString; Const s : WideString;Offset : SizeInt = 1) : SizeInt;
+Function Pos (const c : ShortString; Const s : WideString) : SizeInt;
begin
- result:=Pos(WideString(c),s,Offset);
+ result:=Pos(WideString(c),s);
end;
-Function Pos (const c : WideString; Const s : RawByteString;Offset : SizeInt = 1) : SizeInt;
+Function Pos (const c : WideString; Const s : RawByteString) : SizeInt;
begin
- result:=Pos(c,WideString(s),Offset);
+ result:=Pos(c,WideString(s));
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 : WideString;Offset : SizeInt = 1) : SizeInt;
+Function Pos (c : Char; Const s : WideString) : SizeInt;
var
i: SizeInt;
wc : widechar;
pc : pwidechar;
begin
- Pos:=0;
- if (Offset<1) or (OffSet>Length(S)) then
- exit;
wc:=c;
-
- pc:=@s[offset];
- for i:=Offset to length(s) do
+ pc:=@s[1];
+ for i:=1 to length(s) do
begin
if pc^=wc then
begin
diff --git a/rtl/java/jsystemh.inc b/rtl/java/jsystemh.inc
index 37c4e91456..76047d74e1 100644
--- a/rtl/java/jsystemh.inc
+++ b/rtl/java/jsystemh.inc
@@ -500,7 +500,7 @@ Function hexStr(Val:Pointer):shortstring;
Function chr(b : byte) : Char; [INTERNPROC: fpc_in_chr_byte];
Function upCase(c:Char):Char;
Function lowerCase(c:Char):Char; overload;
-function pos(const substr : shortstring;c:char; Offset : Sizeint=1): SizeInt;
+function pos(const substr : shortstring;c:char): SizeInt;
{****************************************************************************