rtl: replace PChar -> PAnsiChar, Char -> AnsiChar in astrings.inc routines

git-svn-id: trunk@19291 -
This commit is contained in:
paul 2011-09-30 08:15:17 +00:00
parent bcb0317209
commit 451e48a033
3 changed files with 31 additions and 31 deletions

View File

@ -44,7 +44,7 @@ Type
{$endif CPU64}
Ref : SizeInt;
Len : SizeInt;
First : Char;
First : AnsiChar;
end;
Const
@ -143,7 +143,7 @@ Procedure fpc_AnsiStr_Assign (Var S1 : Pointer;S2 : Pointer);[external name 'FPC
function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): ansistring; compilerproc;
Var
Size,Location : SizeInt;
pc : pchar;
pc : PAnsiChar;
begin
{ only assign if s1 or s2 is empty }
if (S1='') then
@ -159,7 +159,7 @@ begin
Location:=Length(S1);
Size:=length(S2);
SetLength(result,Size+Location);
pc:=pchar(result);
pc:=PAnsiChar(result);
Move(S1[1],pc^,Location);
inc(pc,location);
Move(S2[1],pc^,Size+1);
@ -170,7 +170,7 @@ function fpc_AnsiStr_Concat_multi (const sarr:array of Ansistring): ansistring;
Var
i : Longint;
p : pointer;
pc : pchar;
pc : PAnsiChar;
Size,NewLen : SizeInt;
begin
{ First calculate size of the result so we can do
@ -179,14 +179,14 @@ begin
for i:=low(sarr) to high(sarr) do
inc(NewLen,length(sarr[i]));
SetLength(result,NewLen);
pc:=pchar(result);
pc:=PAnsiChar(result);
for i:=low(sarr) to high(sarr) do
begin
p:=pointer(sarr[i]);
if assigned(p) then
begin
Size:=length(ansistring(p));
Move(pchar(p)^,pc^,Size+1);
Move(PAnsiChar(p)^,pc^,Size+1);
inc(pc,size);
end;
end;
@ -501,7 +501,7 @@ begin
end
end;
Function fpc_Char_To_AnsiStr(const c : Char{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_Char_To_AnsiStr(const c : AnsiChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
{
Converts a Char to a AnsiString;
}
@ -524,7 +524,7 @@ begin
end;
Function fpc_PChar_To_AnsiStr(const p : pchar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_PChar_To_AnsiStr(const p : PAnsiChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Var
L : SizeInt;
{$ifndef FPC_HAS_CPSTRING}
@ -606,7 +606,7 @@ end;
{$else ndef FPC_STRTOCHARARRAYPROC}
procedure fpc_ansistr_to_chararray(out res: array of char; const src: RawByteString); compilerproc;
procedure fpc_ansistr_to_chararray(out res: array of AnsiChar; const src: RawByteString); compilerproc;
var
len: SizeInt;
begin
@ -890,11 +890,11 @@ end;
{$endif FPC_SYSTEM_HAS_ANSISTR_UNIQUE}
Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); [Public,Alias : 'FPC_ANSISTR_APPEND_CHAR']; compilerproc;
Procedure fpc_ansistr_append_char(Var S : AnsiString;c : AnsiChar); [Public,Alias : 'FPC_ANSISTR_APPEND_CHAR']; compilerproc;
begin
SetLength(S,length(S)+1);
// avoid unique call
PChar(Pointer(S)+length(S)-1)^:=c;
PAnsiChar(Pointer(S)+length(S)-1)^:=c;
PByte(Pointer(S)+length(S))^:=0; { Terminating Zero }
end;
@ -961,11 +961,11 @@ begin
Pointer(fpc_ansistr_Copy):=ResultAddress;
end;
Function Pos (Const Substr : ShortString; Const Source : RawByteString) : SizeInt;
Function Pos(Const Substr : ShortString; Const Source : RawByteString) : SizeInt;
var
i,MaxLen : SizeInt;
pc : pchar;
pc : PAnsiChar;
begin
Pos:=0;
if Length(SubStr)>0 then
@ -988,10 +988,10 @@ begin
end;
Function Pos (Const Substr : RawByteString; Const Source : RawByteString) : SizeInt;
Function Pos(Const Substr : RawByteString; Const Source : RawByteString) : SizeInt;
var
i,MaxLen : SizeInt;
pc : pchar;
pc : PAnsiChar;
begin
Pos:=0;
if Length(SubStr)>0 then
@ -1018,10 +1018,10 @@ 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 : Char; Const s : RawByteString) : SizeInt;
Function Pos(c : AnsiChar; Const s : RawByteString) : SizeInt;
var
i: SizeInt;
pc : pchar;
pc : PAnsiChar;
begin
pc:=@s[1];
for i:=1 to length(s) do
@ -1291,20 +1291,20 @@ begin
end;
Function StringOfChar(c : char;l : SizeInt) : AnsiString;
Function StringOfChar(c : Ansichar;l : SizeInt) : AnsiString;
begin
SetLength(StringOfChar,l);
FillChar(Pointer(StringOfChar)^,Length(StringOfChar),c);
end;
Procedure SetString (Out S : AnsiString; Buf : PChar; Len : SizeInt); {$IFNDEF VER2_0} Inline; {$ENDIF}
Procedure SetString(Out S : AnsiString; Buf : PAnsiChar; Len : SizeInt); {$IFNDEF VER2_0} Inline; {$ENDIF}
begin
SetLength(S,Len);
If (Buf<>Nil) then
Move (Buf^,Pointer(S)^,Len);
Move(Buf^,Pointer(S)^,Len);
end;
Procedure SetString (Out S : AnsiString; Buf : PWideChar; Len : SizeInt);
Procedure SetString(Out S : AnsiString; Buf : PWideChar; Len : SizeInt);
begin
if (Buf<>nil) and (Len>0) then
widestringmanager.Wide2AnsiMoveProc(Buf,S,DefaultSystemCodePage,Len)

View File

@ -255,7 +255,7 @@ Procedure fpc_AnsiStr_Concat_multi (Var DestS : RawByteString;const sarr:array o
function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): AnsiString; compilerproc;
function fpc_AnsiStr_Concat_multi (const sarr:array of Ansistring): ansistring; compilerproc;
{$endif STR_CONCAT_PROCS}
Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); compilerproc;
Procedure fpc_ansistr_append_char(Var S : AnsiString;c : AnsiChar); compilerproc;
Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;const Str : ShortString); compilerproc;
Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;const Str : AnsiString); compilerproc;
{$ifdef EXTRAANSISHORT}
@ -270,14 +270,14 @@ procedure fpc_AnsiStr_To_ShortStr (out res : shortstring;const S2 : RawByteStrin
Function fpc_AnsiStr_To_AnsiStr (const S : RawByteString;cp : TSystemCodePage): RawByteString; compilerproc;
{$endif FPC_HAS_CPSTRING}
Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_Char_To_AnsiStr(const c : Char{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_Char_To_AnsiStr(const c : AnsiChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_PChar_To_AnsiStr(const p : pchar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_CharArray_To_AnsiStr(const arr: array of char; {$ifdef FPC_HAS_CPSTRING}cp : TSystemCodePage;{$endif FPC_HAS_CPSTRING}zerobased: boolean = true): RawByteString; compilerproc;
Function fpc_PChar_To_AnsiStr(const p : PAnsiChar{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}): RawByteString; compilerproc;
Function fpc_CharArray_To_AnsiStr(const arr: array of AnsiChar; {$ifdef FPC_HAS_CPSTRING}cp : TSystemCodePage;{$endif FPC_HAS_CPSTRING}zerobased: boolean = true): RawByteString; compilerproc;
{$ifndef FPC_STRTOCHARARRAYPROC}
function fpc_ansistr_to_chararray(arraysize: SizeInt; const src: ansistring): fpc_big_chararray; compilerproc;
{$else ndef FPC_STRTOCHARARRAYPROC}
procedure fpc_ansistr_to_chararray(out res: array of char; const src: RawByteString)compilerproc;
procedure fpc_ansistr_to_chararray(out res: array of AnsiChar; const src: RawByteString)compilerproc;
{$endif ndef FPC_STRTOCHARARRAYPROC}
Function fpc_AnsiStr_Compare(const S1,S2 : RawByteString): SizeInt; compilerproc;
Function fpc_AnsiStr_Compare_equal(const S1,S2 : RawByteString): SizeInt; compilerproc;

View File

@ -848,9 +848,9 @@ Procedure Insert(source:Char;var s:shortstring;index: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) : SizeInt;
Procedure SetString (out S : AnsiString; Buf : PChar; Len : SizeInt);
Procedure SetString (out S : AnsiString; Buf : PWideChar; Len : SizeInt);
Function Pos(const Substr : ShortString; const Source : RawByteString) : SizeInt;
Procedure SetString(out S : AnsiString; Buf : PAnsiChar; Len : SizeInt);
Procedure SetString(out S : AnsiString; Buf : PWideChar; Len : SizeInt);
{$endif FPC_HAS_FEATURE_ANSISTRINGS}
Procedure SetString (out S : Shortstring; Buf : PChar; Len : SizeInt);
function ShortCompareText(const S1, S2: shortstring): SizeInt;
@ -882,10 +882,10 @@ function pos(const substr : shortstring;c:char): 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) : SizeInt;
Function Pos (c : Char; const s : 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 : char;l : SizeInt) : AnsiString;
Function StringOfChar(c : Ansichar;l : SizeInt) : AnsiString;
function upcase(const s : ansistring) : ansistring;
function lowercase(const s : ansistring) : ansistring;