mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-19 22:49:37 +01:00
* str() helpers now also use valint/valuint
* int64/qword helpers disabled for cpu64
This commit is contained in:
parent
94c6cdb21a
commit
cafed35e77
@ -24,9 +24,9 @@
|
||||
AnsiString is defined as a 'silent' pchar :
|
||||
a pchar that points to :
|
||||
|
||||
@-12 : Longint for maximum size;
|
||||
@-8 : Longint for size;
|
||||
@-4 : Longint for reference count;
|
||||
@-12 : StrLenInt for maximum size;
|
||||
@-8 : StrLenInt for size;
|
||||
@-4 : StrLenInt for reference count;
|
||||
@ : String + Terminating #0;
|
||||
Pchar(Ansistring) is a valid typecast.
|
||||
So AS[i] is converted to the address @AS+i-1.
|
||||
@ -40,7 +40,7 @@ Type
|
||||
TAnsiRec = Packed Record
|
||||
Maxlen,
|
||||
len,
|
||||
ref : Longint;
|
||||
ref : StrLenint;
|
||||
First : Char;
|
||||
end;
|
||||
|
||||
@ -55,7 +55,7 @@ Const
|
||||
|
||||
|
||||
|
||||
Function NewAnsiString(Len : Longint) : Pointer;
|
||||
Function NewAnsiString(Len : StrLenInt) : Pointer;
|
||||
{
|
||||
Allocate a new AnsiString on the heap.
|
||||
initialize it to zero length and reference count 1.
|
||||
@ -101,9 +101,9 @@ Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer);saveregisters;[Public,Alias:'FP
|
||||
If the reference count is zero, deallocate the string;
|
||||
}
|
||||
Type
|
||||
plongint = ^longint;
|
||||
pStrLenInt = ^StrLenInt;
|
||||
Var
|
||||
l : plongint;
|
||||
l : pStrLenInt;
|
||||
Begin
|
||||
{ Zero string }
|
||||
If S=Nil then exit;
|
||||
@ -174,7 +174,7 @@ Procedure fpc_AnsiStr_Concat (const S1,S2 : ansistring;var S3 : ansistring);[Pub
|
||||
Result Goes to S3;
|
||||
}
|
||||
Var
|
||||
Size,Location : Longint;
|
||||
Size,Location : StrLenInt;
|
||||
begin
|
||||
{ only assign if s1 or s2 is empty }
|
||||
if (S1='') then
|
||||
@ -201,7 +201,7 @@ Procedure AnsiStr_ShortStr_Concat (Var S1: AnsiString; Var S2 : ShortString);
|
||||
Concatenates a Ansi with a short string; : S2 + S2
|
||||
}
|
||||
Var
|
||||
Size,Location : Longint;
|
||||
Size,Location : StrLenInt;
|
||||
begin
|
||||
Size:=Length(S2);
|
||||
Location:=Length(S1);
|
||||
@ -221,12 +221,12 @@ end;
|
||||
{ procedure fpc_AnsiStr_To_ShortStr (Var S1 : ShortString;S2 : Pointer); }
|
||||
{ which is what the old helper was, so we don't need an extra implementation }
|
||||
{ of the old helper (JM) }
|
||||
function fpc_AnsiStr_To_ShortStr (high_of_res: longint;const S2 : Ansistring): shortstring;[Public, alias: 'FPC_ANSISTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
function fpc_AnsiStr_To_ShortStr (high_of_res: StrLenInt;const S2 : Ansistring): shortstring;[Public, alias: 'FPC_ANSISTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{
|
||||
Converts a AnsiString to a ShortString;
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if S2='' then
|
||||
fpc_AnsiStr_To_ShortStr:=''
|
||||
@ -246,7 +246,7 @@ Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; {$ifdef h
|
||||
Converts a ShortString to a AnsiString;
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
Size:=Length(S2);
|
||||
Setlength (fpc_ShortStr_To_AnsiStr,Size);
|
||||
@ -284,7 +284,7 @@ end;
|
||||
|
||||
Function fpc_PChar_To_AnsiStr(const p : pchar): ansistring; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
L : Longint;
|
||||
L : StrLenInt;
|
||||
begin
|
||||
if (not assigned(p)) or (p[0]=#0) Then
|
||||
{ result is automatically set to '' }
|
||||
@ -305,7 +305,7 @@ end;
|
||||
|
||||
Function fpc_CharArray_To_AnsiStr(const arr: array of char): ansistring; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
if arr[0]=#0 Then
|
||||
{ result is automatically set to '' }
|
||||
@ -322,10 +322,10 @@ end;
|
||||
{ the declaration below is the same as }
|
||||
{ which is what the old helper was (we need the parameter as "array of char" type }
|
||||
{ so we can pass it to the new style helper (JM) }
|
||||
Procedure fpc_CharArray_To_AnsiStr(var a : ansistring; p: pointer; len: longint);[Public,Alias : 'FPC_CHARARRAY_TO_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_CharArray_To_AnsiStr(var a : ansistring; p: pointer; len: StrLenInt);[Public,Alias : 'FPC_CHARARRAY_TO_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
src: pchar;
|
||||
i: longint;
|
||||
i: StrLenInt;
|
||||
begin
|
||||
src := pchar(p);
|
||||
if src[0]=#0 Then
|
||||
@ -347,9 +347,9 @@ end;
|
||||
|
||||
{ note: inside the compiler, the resulttype is modified to be the length }
|
||||
{ of the actual chararray to which we convert (JM) }
|
||||
function fpc_ansistr_to_chararray(arraysize: longint; const src: ansistring): fpc_big_chararray; [public, alias: 'FPC_ANSISTR_TO_CHARARRAY']; compilerproc;
|
||||
function fpc_ansistr_to_chararray(arraysize: StrLenInt; const src: ansistring): fpc_big_chararray; [public, alias: 'FPC_ANSISTR_TO_CHARARRAY']; compilerproc;
|
||||
var
|
||||
len: longint;
|
||||
len: StrLenInt;
|
||||
begin
|
||||
len := length(src);
|
||||
if len > arraysize then
|
||||
@ -363,7 +363,7 @@ end;
|
||||
{$endif hascompilerproc}
|
||||
|
||||
|
||||
Function fpc_AnsiStr_Compare(const S1,S2 : AnsiString): Longint;[Public,Alias : 'FPC_ANSISTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Function fpc_AnsiStr_Compare(const S1,S2 : AnsiString): StrLenInt;[Public,Alias : 'FPC_ANSISTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{
|
||||
Compares 2 AnsiStrings;
|
||||
The result is
|
||||
@ -372,7 +372,7 @@ Function fpc_AnsiStr_Compare(const S1,S2 : AnsiString): Longint;[Public,Alias :
|
||||
>0 if S1>S2
|
||||
}
|
||||
Var
|
||||
MaxI,Temp : Longint;
|
||||
MaxI,Temp : StrLenInt;
|
||||
begin
|
||||
if pointer(S1)=pointer(S2) then
|
||||
begin
|
||||
@ -397,16 +397,16 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_AnsiStr_CheckRange(len,index : longint);[Public,Alias : 'FPC_ANSISTR_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_AnsiStr_CheckRange(len,index : StrLenInt);[Public,Alias : 'FPC_ANSISTR_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
begin
|
||||
if (index>len) or (Index<1) then
|
||||
HandleErrorFrame(201,get_frame);
|
||||
end;
|
||||
|
||||
{$ifndef INTERNSETLENGTH}
|
||||
Procedure SetLength (Var S : AnsiString; l : Longint);
|
||||
Procedure SetLength (Var S : AnsiString; l : StrLenInt);
|
||||
{$else INTERNSETLENGTH}
|
||||
Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : Longint);[Public,Alias : 'FPC_ANSISTR_SETLENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : StrLenInt);[Public,Alias : 'FPC_ANSISTR_SETLENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif INTERNSETLENGTH}
|
||||
{
|
||||
Sets The length of string S to L.
|
||||
@ -414,7 +414,7 @@ Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : Longint);[Public,Alias
|
||||
}
|
||||
Var
|
||||
Temp : Pointer;
|
||||
movelen, NewLen: longint;
|
||||
movelen, NewLen: StrLenInt;
|
||||
begin
|
||||
if (l>0) then
|
||||
begin
|
||||
@ -465,7 +465,7 @@ begin
|
||||
end;
|
||||
|
||||
{$ifdef EXTRAANSISHORT}
|
||||
Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): Longint; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): StrLenInt; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{
|
||||
Compares a AnsiString with a ShortString;
|
||||
The result is
|
||||
@ -474,7 +474,7 @@ Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString):
|
||||
>0 if S1>S2
|
||||
}
|
||||
Var
|
||||
i,MaxI,Temp : Longint;
|
||||
i,MaxI,Temp : StrLenInt;
|
||||
begin
|
||||
Temp:=0;
|
||||
i:=0;
|
||||
@ -496,7 +496,7 @@ end;
|
||||
*****************************************************************************}
|
||||
|
||||
{$ifndef INTERNLENGTH}
|
||||
Function Length (Const S : AnsiString) : Longint;
|
||||
Function Length (Const S : AnsiString) : StrLenInt;
|
||||
{
|
||||
Returns the length of an AnsiString.
|
||||
Takes in acount that zero strings are NIL;
|
||||
@ -520,7 +520,7 @@ Function fpc_ansistr_Unique(Var S : Pointer): Pointer; [Public,Alias : 'FPC_ANSI
|
||||
}
|
||||
Var
|
||||
SNew : Pointer;
|
||||
L : Longint;
|
||||
L : StrLenInt;
|
||||
begin
|
||||
pointer(result) := pointer(s);
|
||||
If Pointer(S)=Nil then
|
||||
@ -567,9 +567,9 @@ begin
|
||||
end;
|
||||
|
||||
{$ifdef interncopy}
|
||||
Function Fpc_Ansistr_Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;compilerproc;
|
||||
Function Fpc_Ansistr_Copy (Const S : AnsiString; Index,Size : StrLenInt) : AnsiString;compilerproc;
|
||||
{$else}
|
||||
Function Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;
|
||||
Function Copy (Const S : AnsiString; Index,Size : StrLenInt) : AnsiString;
|
||||
{$endif}
|
||||
var
|
||||
ResultAddress : Pointer;
|
||||
@ -603,7 +603,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : Longint;
|
||||
Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : StrLenInt;
|
||||
var
|
||||
i,MaxLen : StrLenInt;
|
||||
pc : pchar;
|
||||
@ -633,9 +633,9 @@ 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 : AnsiString) : Longint;
|
||||
Function Pos (c : Char; Const s : AnsiString) : StrLenInt;
|
||||
var
|
||||
i: longint;
|
||||
i: StrLenInt;
|
||||
pc : pchar;
|
||||
begin
|
||||
pc:=@s[1];
|
||||
@ -682,7 +682,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Function fpc_Val_SInt_AnsiStr (DestSize: StrLenInt; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
@ -696,6 +696,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_ANSISTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
@ -725,7 +728,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_FLOAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif CPU64}
|
||||
|
||||
|
||||
procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : StrLenInt;var s : ansistring);[public,alias:'FPC_ANSISTR_FLOAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
ss: ShortString;
|
||||
begin
|
||||
@ -734,30 +740,59 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_AnsiStr_Longword(C : Longword;Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
Procedure fpc_AnsiStr_UInt(v : ValUInt;Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_VALUINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
Procedure fpc_AnsiStr_Longword(v : Longword;Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
str(C:Len,SS);
|
||||
str(v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure fpc_AnsiStr_Longint(L : Longint; Len : Longint; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
Procedure fpc_AnsiStr_SInt(v : ValSInt;Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_VALSINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
Procedure fpc_AnsiStr_Longint(v : Longint; Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
str (L:Len,SS);
|
||||
str (v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
Procedure Delete (Var S : AnsiString; Index,Size: Longint);
|
||||
{$ifndef CPU64}
|
||||
|
||||
Procedure fpc_AnsiStr_QWord(v : QWord;Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
LS : Longint;
|
||||
SS : ShortString;
|
||||
begin
|
||||
str(v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure fpc_AnsiStr_Int64(v : Int64; Len : StrLenInt; Var S : AnsiString);[Public,Alias : 'FPC_ANSISTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
str (v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
|
||||
Procedure Delete (Var S : AnsiString; Index,Size: StrLenInt);
|
||||
Var
|
||||
LS : StrLenInt;
|
||||
begin
|
||||
ls:=Length(S);
|
||||
If (Index>LS) or (Index<=0) or (Size<=0) then
|
||||
@ -774,10 +809,10 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : Longint);
|
||||
Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : StrLenInt);
|
||||
var
|
||||
Temp : AnsiString;
|
||||
LS : Longint;
|
||||
LS : StrLenInt;
|
||||
begin
|
||||
If Length(Source)=0 then
|
||||
exit;
|
||||
@ -798,13 +833,13 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function StringOfChar(c : char;l : longint) : AnsiString;
|
||||
Function StringOfChar(c : char;l : StrLenInt) : AnsiString;
|
||||
begin
|
||||
SetLength(StringOfChar,l);
|
||||
FillChar(Pointer(StringOfChar)^,Length(StringOfChar),c);
|
||||
end;
|
||||
|
||||
Procedure SetString (Var S : AnsiString; Buf : PChar; Len : Longint);
|
||||
Procedure SetString (Var S : AnsiString; Buf : PChar; Len : StrLenInt);
|
||||
begin
|
||||
SetLength(S,Len);
|
||||
If (Buf<>Nil) then
|
||||
@ -816,7 +851,7 @@ end;
|
||||
|
||||
function upcase(const s : ansistring) : ansistring;
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
Setlength(result,length(s));
|
||||
for i := 1 to length (s) do
|
||||
@ -826,7 +861,7 @@ end;
|
||||
|
||||
function lowercase(const s : ansistring) : ansistring;
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
Setlength(result,length(s));
|
||||
for i := 1 to length (s) do
|
||||
@ -836,7 +871,11 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.41 2004-01-21 22:14:05 peter
|
||||
Revision 1.42 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.41 2004/01/21 22:14:05 peter
|
||||
* 1.0.x fix
|
||||
|
||||
Revision 1.40 2004/01/21 22:02:18 peter
|
||||
@ -847,7 +886,7 @@ end;
|
||||
* fixed conversion of fpc_*str_unique to compilerproc
|
||||
|
||||
Revision 1.38 2003/06/17 16:38:53 jonas
|
||||
* fpc_{ansistr|widestr}_unique is now a function so it can be used as
|
||||
* fpc_ansistr|widestr_unique is now a function so it can be used as
|
||||
compilerproc
|
||||
|
||||
Revision 1.37 2003/05/01 08:05:23 florian
|
||||
|
||||
@ -54,8 +54,8 @@ function fpc_chararray_to_shortstr(const arr: array of char):shortstring; compil
|
||||
function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray; compilerproc;
|
||||
|
||||
Function fpc_shortstr_Copy(const s:shortstring;index:StrLenInt;count:StrLenInt):shortstring;compilerproc;
|
||||
Function fpc_ansistr_Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;compilerproc;
|
||||
Function fpc_widestr_Copy (Const S : WideString; Index,Size : Longint) : WideString;compilerproc;
|
||||
Function fpc_ansistr_Copy (Const S : AnsiString; Index,Size : StrLenInt) : AnsiString;compilerproc;
|
||||
Function fpc_widestr_Copy (Const S : WideString; Index,Size : StrLenInt) : WideString;compilerproc;
|
||||
function fpc_char_copy(c:char;index : StrLenInt;count : StrLenInt): shortstring;compilerproc;
|
||||
procedure fpc_dynarray_copy(var pdest : pointer;psrc : pointer;ti : pointer;lowidx,count:tdynarrayindex);compilerproc;
|
||||
|
||||
@ -66,15 +66,57 @@ procedure fpc_dynarray_decr_ref(var p : pointer;ti : pointer); compilerproc;
|
||||
procedure fpc_dynarray_incr_ref(p : pointer); compilerproc;
|
||||
procedure fpc_dynarray_setlength(var p : pointer;pti : pointer; dimcount : dword;dims : pdynarrayindex); compilerproc;
|
||||
|
||||
procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : longint;var s : shortstring); compilerproc;
|
||||
{ Str() support }
|
||||
{$ifdef STR_USES_VALINT}
|
||||
procedure fpc_ShortStr_sint(v : valsint;len : strlenint;var s : shortstring); compilerproc;
|
||||
procedure fpc_shortstr_uint(v : valuint;len : strlenint;var s : shortstring); compilerproc;
|
||||
procedure fpc_chararray_sint(v : valsint;len : strlenint;var a : array of char); compilerproc;
|
||||
procedure fpc_chararray_uint(v : valuint;len : strlenint;var a : array of char); compilerproc;
|
||||
procedure fpc_AnsiStr_sint(v : valsint; Len : strlenint; Var S : AnsiString); compilerproc;
|
||||
procedure fpc_AnsiStr_uint(v : valuint;Len : strlenint; Var S : AnsiString); compilerproc;
|
||||
procedure fpc_WideStr_sint(v : valsint; Len : strlenint; Var S : WideString); compilerproc;
|
||||
procedure fpc_WideStr_uint(v : valuint;Len : strlenint; Var S : WideString); compilerproc;
|
||||
{$else}
|
||||
procedure fpc_ShortStr_Longint(v : longint;len : longint;var s : shortstring); compilerproc;
|
||||
procedure fpc_shortstr_longword(v : longword;len : longint;var s : shortstring); compilerproc;
|
||||
procedure fpc_chararray_Float(d : ValReal;len,fr,rt : longint;var a : array of char); compilerproc;
|
||||
procedure fpc_chararray_Longint(v : longint;len : longint;var a : array of char); compilerproc;
|
||||
procedure fpc_chararray_longword(v : longword;len : longint;var a : array of char); compilerproc;
|
||||
procedure fpc_AnsiStr_Longint(v : Longint; Len : Longint; Var S : AnsiString); compilerproc;
|
||||
procedure fpc_AnsiStr_Longword(v : Longword;Len : Longint; Var S : AnsiString); compilerproc;
|
||||
procedure fpc_WideStr_Longint(v : Longint; Len : Longint; Var S : WideString); compilerproc;
|
||||
procedure fpc_WideStr_Longword(v : Longword;Len : Longint; Var S : WideString); compilerproc;
|
||||
{$endif}
|
||||
procedure fpc_shortstr_qword(v : qword;len : strlenint;var s : shortstring); compilerproc;
|
||||
procedure fpc_shortstr_int64(v : int64;len : strlenint;var s : shortstring); compilerproc;
|
||||
procedure fpc_chararray_qword(v : qword;len : strlenint;var a : array of char); compilerproc;
|
||||
procedure fpc_chararray_int64(v : int64;len : strlenint;var a : array of char); compilerproc;
|
||||
procedure fpc_ansistr_qword(v : qword;len : strlenint;var s : ansistring); compilerproc;
|
||||
procedure fpc_ansistr_int64(v : int64;len : strlenint;var s : ansistring); compilerproc;
|
||||
procedure fpc_widestr_qword(v : qword;len : strlenint;var s : widestring); compilerproc;
|
||||
procedure fpc_widestr_int64(v : int64;len : strlenint;var s : widestring); compilerproc;
|
||||
procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : strlenint;var s : shortstring); compilerproc;
|
||||
procedure fpc_chararray_Float(d : ValReal;len,fr,rt : strlenint;var a : array of char); compilerproc;
|
||||
procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : strlenint;var s : ansistring); compilerproc;
|
||||
procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : strlenint;var s : WideString); compilerproc;
|
||||
|
||||
{ Val() support }
|
||||
Function fpc_Val_Real_ShortStr(const s : shortstring; var code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_Real_WideStr(Const S : WideString; Var Code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_SInt_ShortStr(DestSize: longint; Const S: ShortString; var Code: ValSInt): ValSInt; compilerproc;
|
||||
Function fpc_Val_UInt_Shortstr(Const S: ShortString; var Code: ValSInt): ValUInt; compilerproc;
|
||||
Function fpc_Val_Real_ShortStr(const s : shortstring; var code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc;
|
||||
Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc;
|
||||
Function fpc_Val_UInt_WideStr (Const S : WideString; Var Code : ValSInt): ValUInt; compilerproc;
|
||||
Function fpc_Val_SInt_WideStr (DestSize: longint; Const S : WideString; Var Code : ValSInt): ValSInt; compilerproc;
|
||||
{$ifndef CPU64}
|
||||
Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; compilerproc;
|
||||
Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; compilerproc;
|
||||
Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword;compilerproc;
|
||||
Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; compilerproc;
|
||||
Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; compilerproc;
|
||||
Function fpc_Val_int64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; compilerproc;
|
||||
{$endif CPU64}
|
||||
|
||||
Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer); compilerproc;
|
||||
Procedure fpc_AnsiStr_Incr_Ref (S : Pointer); compilerproc;
|
||||
@ -83,7 +125,6 @@ function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): AnsiString; compilerproc
|
||||
Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); compilerproc;
|
||||
Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;Str : ShortString); compilerproc;
|
||||
Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;Str : AnsiString); compilerproc;
|
||||
|
||||
{$ifdef EXTRAANSISHORT}
|
||||
Procedure fpc_AnsiStr_ShortStr_Concat (Var S1: AnsiString; Var S2 : ShortString); compilerproc;
|
||||
{$endif EXTRAANSISHORT}
|
||||
@ -129,24 +170,6 @@ Function fpc_PWideChar_To_WideStr(const p : pwidechar): widestring; compilerproc
|
||||
Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerproc;
|
||||
{$endif HASWIDECHAR}
|
||||
|
||||
Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc;
|
||||
Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc;
|
||||
Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword;compilerproc;
|
||||
Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; compilerproc;
|
||||
procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : longint;var s : ansistring); compilerproc;
|
||||
Procedure fpc_AnsiStr_Longword(C : Longword;Len : Longint; Var S : AnsiString); compilerproc;
|
||||
Procedure fpc_AnsiStr_Longint(L : Longint; Len : Longint; Var S : AnsiString); compilerproc;
|
||||
|
||||
Function fpc_Val_Real_WideStr(Const S : WideString; Var Code : ValSInt): ValReal; compilerproc;
|
||||
Function fpc_Val_UInt_WideStr (Const S : WideString; Var Code : ValSInt): ValUInt; compilerproc;
|
||||
Function fpc_Val_SInt_WideStr (DestSize: longint; Const S : WideString; Var Code : ValSInt): ValSInt; compilerproc;
|
||||
Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; compilerproc;
|
||||
Function fpc_Val_int64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; compilerproc;
|
||||
procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : longint;var s : WideString); compilerproc;
|
||||
Procedure fpc_WideStr_Longword(C : Longword;Len : Longint; Var S : WideString); compilerproc;
|
||||
Procedure fpc_WideStr_Longint(L : Longint; Len : Longint; Var S : WideString); compilerproc;
|
||||
|
||||
{ from text.inc }
|
||||
Procedure fpc_Write_End(var f:Text); compilerproc;
|
||||
Procedure fpc_Writeln_End(var f:Text); compilerproc;
|
||||
@ -159,8 +182,10 @@ Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; S : WideString);
|
||||
{$endif HASWIDESTRING}
|
||||
Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); compilerproc;
|
||||
Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); compilerproc;
|
||||
{$ifndef CPU64}
|
||||
procedure fpc_write_text_qword(len : longint;var t : text;q : qword); compilerproc;
|
||||
procedure fpc_write_text_int64(len : longint;var t : text;i : int64); compilerproc;
|
||||
{$endif CPU64}
|
||||
Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); compilerproc;
|
||||
Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); compilerproc;
|
||||
Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); compilerproc;
|
||||
@ -194,15 +219,6 @@ function fpc_mod_longint(n,z : longint) : longint; compilerproc;
|
||||
{$endif FPC_INCLUDE_SOFTWARE_MOD_DIV}
|
||||
|
||||
{ from int64.inc }
|
||||
procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring); compilerproc;
|
||||
procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring); compilerproc;
|
||||
procedure fpc_ansistr_qword(v : qword;len : longint;var s : ansistring); compilerproc;
|
||||
procedure fpc_ansistr_int64(v : int64;len : longint;var s : ansistring); compilerproc;
|
||||
Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; compilerproc;
|
||||
Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; compilerproc;
|
||||
procedure fpc_widestr_qword(v : qword;len : longint;var s : widestring); compilerproc;
|
||||
procedure fpc_widestr_int64(v : int64;len : longint;var s : widestring); compilerproc;
|
||||
|
||||
function fpc_div_qword(n,z : qword) : qword; compilerproc;
|
||||
function fpc_mod_qword(n,z : qword) : qword; compilerproc;
|
||||
function fpc_div_int64(n,z : int64) : int64; compilerproc;
|
||||
@ -310,7 +326,11 @@ function fpc_qword_to_double(q: qword): double; compilerproc;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.52 2004-04-12 18:51:02 florian
|
||||
Revision 1.53 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.52 2004/04/12 18:51:02 florian
|
||||
* fixed getmem prototype for 64 bit systems
|
||||
|
||||
Revision 1.51 2004/01/01 17:58:16 jonas
|
||||
|
||||
@ -364,202 +364,13 @@
|
||||
end;
|
||||
{$endif FPC_SYSTEM_HAS_MUL_INT64}
|
||||
|
||||
|
||||
procedure qword_str(value : qword;var s : string);
|
||||
|
||||
var
|
||||
hs : string;
|
||||
|
||||
begin
|
||||
hs:='';
|
||||
repeat
|
||||
hs:=chr(longint(value mod qword(10))+48)+hs;
|
||||
value:=value div qword(10);
|
||||
until value=0;
|
||||
s:=hs;
|
||||
end;
|
||||
|
||||
|
||||
procedure int64_str(value : int64;var s : string);
|
||||
|
||||
var
|
||||
hs : string;
|
||||
q : qword;
|
||||
|
||||
begin
|
||||
if value<0 then
|
||||
begin
|
||||
q:=qword(-value);
|
||||
qword_str(q,hs);
|
||||
s:='-'+hs;
|
||||
end
|
||||
else
|
||||
qword_str(qword(value),s);
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
begin
|
||||
qword_str(v,s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
begin
|
||||
int64_str(v,s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
procedure fpc_ansistr_qword(v : qword;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
var
|
||||
ss : shortstring;
|
||||
|
||||
begin
|
||||
str(v:len,ss);
|
||||
s:=ss;
|
||||
end;
|
||||
|
||||
procedure fpc_ansistr_int64(v : int64;len : longint;var s : ansistring);[public,alias:'FPC_ANSISTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
var
|
||||
ss : shortstring;
|
||||
|
||||
begin
|
||||
str(v:len,ss);
|
||||
s:=ss;
|
||||
end;
|
||||
|
||||
{$ifdef HASWIDESTRING}
|
||||
procedure fpc_widestr_qword(v : qword;len : longint;var s : widestring);[public,alias:'FPC_WIDESTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
var
|
||||
ss : shortstring;
|
||||
|
||||
begin
|
||||
str(v:len,ss);
|
||||
s:=ss;
|
||||
end;
|
||||
|
||||
procedure fpc_widestr_int64(v : int64;len : longint;var s : widestring);[public,alias:'FPC_WIDESTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
var
|
||||
ss : shortstring;
|
||||
|
||||
begin
|
||||
str(v:len,ss);
|
||||
s:=ss;
|
||||
end;
|
||||
{$endif HASWIDESTRING}
|
||||
|
||||
|
||||
Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; [public, alias:'FPC_VAL_INT64_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
type
|
||||
QWordRec = packed record
|
||||
l1,l2: longint;
|
||||
end;
|
||||
|
||||
var
|
||||
u, temp, prev, maxint64, maxqword : qword;
|
||||
base : byte;
|
||||
negative : boolean;
|
||||
|
||||
begin
|
||||
fpc_val_int64_shortstr := 0;
|
||||
Temp:=0;
|
||||
Code:=InitVal(s,negative,base);
|
||||
if Code>length(s) then
|
||||
exit;
|
||||
{ high(int64) produces 0 in version 1.0 (JM) }
|
||||
with qwordrec(maxint64) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := $7fffffff;
|
||||
end;
|
||||
with qwordrec(maxqword) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := longint($ffffffff);
|
||||
end;
|
||||
|
||||
while Code<=Length(s) do
|
||||
begin
|
||||
case s[Code] of
|
||||
'0'..'9' : u:=Ord(S[Code])-Ord('0');
|
||||
'A'..'F' : u:=Ord(S[Code])-(Ord('A')-10);
|
||||
'a'..'f' : u:=Ord(S[Code])-(Ord('a')-10);
|
||||
else
|
||||
u:=16;
|
||||
end;
|
||||
Prev:=Temp;
|
||||
Temp:=Temp*Int64(base);
|
||||
If (u >= base) or
|
||||
((base = 10) and
|
||||
(maxint64-temp+ord(negative) < u)) or
|
||||
((base <> 10) and
|
||||
(qword(maxqword-temp) < u)) or
|
||||
(prev > maxqword div qword(base)) Then
|
||||
Begin
|
||||
fpc_val_int64_shortstr := 0;
|
||||
Exit
|
||||
End;
|
||||
Temp:=Temp+u;
|
||||
inc(code);
|
||||
end;
|
||||
code:=0;
|
||||
fpc_val_int64_shortstr:=int64(Temp);
|
||||
If Negative Then
|
||||
fpc_val_int64_shortstr:=-fpc_val_int64_shortstr;
|
||||
end;
|
||||
|
||||
|
||||
Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; [public, alias:'FPC_VAL_QWORD_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
type qwordrec = packed record
|
||||
l1,l2: longint;
|
||||
end;
|
||||
var
|
||||
u, prev, maxqword: QWord;
|
||||
base : byte;
|
||||
negative : boolean;
|
||||
begin
|
||||
fpc_val_qword_shortstr:=0;
|
||||
Code:=InitVal(s,negative,base);
|
||||
If Negative or (Code>length(s)) Then
|
||||
Exit;
|
||||
with qwordrec(maxqword) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := longint($ffffffff);
|
||||
end;
|
||||
while Code<=Length(s) do
|
||||
begin
|
||||
case s[Code] of
|
||||
'0'..'9' : u:=Ord(S[Code])-Ord('0');
|
||||
'A'..'F' : u:=Ord(S[Code])-(Ord('A')-10);
|
||||
'a'..'f' : u:=Ord(S[Code])-(Ord('a')-10);
|
||||
else
|
||||
u:=16;
|
||||
end;
|
||||
prev := fpc_val_qword_shortstr;
|
||||
If (u>=base) or
|
||||
((QWord(maxqword-u) div QWord(base))<prev) then
|
||||
Begin
|
||||
fpc_val_qword_shortstr := 0;
|
||||
Exit
|
||||
End;
|
||||
fpc_val_qword_shortstr:=fpc_val_qword_shortstr*QWord(base) + u;
|
||||
inc(code);
|
||||
end;
|
||||
code := 0;
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.24 2004-04-24 17:14:09 florian
|
||||
Revision 1.25 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.24 2004/04/24 17:14:09 florian
|
||||
* prt0.as exit code handling fixed
|
||||
* int64 mod int64 for negative numbers fixed
|
||||
|
||||
|
||||
@ -350,17 +350,10 @@ end;
|
||||
Str() Helpers
|
||||
*****************************************************************************}
|
||||
|
||||
procedure fpc_shortstr_longint(v : longint;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
begin
|
||||
int_str(v,s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
{$ifdef ver1_0}
|
||||
procedure fpc_shortstr_cardinal(v : longword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_CARDINAL']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
procedure fpc_shortstr_SInt(v : valSInt;len : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_SINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
procedure fpc_shortstr_longword(v : longword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_LONGWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
procedure fpc_shortstr_longint(v : longint;len : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
begin
|
||||
int_str(v,s);
|
||||
@ -368,13 +361,71 @@ begin
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
{ fpc_shortstr_longint must appear before this file is included, because }
|
||||
{$ifdef STR_USES_VALINT}
|
||||
procedure fpc_shortstr_UInt(v : valUInt;len : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_UINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
{$ifdef ver1_0}
|
||||
procedure fpc_shortstr_cardinal(v : longword;len : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_CARDINAL']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
procedure fpc_shortstr_longword(v : longword;len : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_LONGWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
{$endif}
|
||||
begin
|
||||
int_str(v,s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
procedure int_qword_str(value : qword;var s : string);
|
||||
var
|
||||
hs : string;
|
||||
begin
|
||||
hs:='';
|
||||
repeat
|
||||
hs:=chr(longint(value mod qword(10))+48)+hs;
|
||||
value:=value div qword(10);
|
||||
until value=0;
|
||||
s:=hs;
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
begin
|
||||
int_qword_str(v,s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
hs : shortstring;
|
||||
q : qword;
|
||||
begin
|
||||
if v<0 then
|
||||
begin
|
||||
q:=qword(-v);
|
||||
int_qword_str(q,hs);
|
||||
s:='-'+hs;
|
||||
end
|
||||
else
|
||||
int_qword_str(qword(v),s);
|
||||
if length(s)<len then
|
||||
s:=space(len-length(s))+s;
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
|
||||
{ fpc_shortstr_sInt must appear before this file is included, because }
|
||||
{ it's used inside real2str.inc and otherwise the searching via the }
|
||||
{ compilerproc name will fail (JM) }
|
||||
|
||||
{$I real2str.inc}
|
||||
|
||||
procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_FLOAT']; {$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
|
||||
procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : StrLenInt;var s : shortstring);[public,alias:'FPC_SHORTSTR_FLOAT']; {$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
|
||||
begin
|
||||
str_real(len,fr,d,treal_type(rt),s);
|
||||
end;
|
||||
@ -384,25 +435,14 @@ end;
|
||||
Array Of Char Str() helpers
|
||||
}
|
||||
|
||||
procedure fpc_chararray_longint(v : longint;len : longint;var a:array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
procedure fpc_chararray_sint(v : valsint;len : StrLenInt;var a:array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
procedure fpc_chararray_longint(v : longint;len : StrLenInt;var a:array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : longint;
|
||||
begin
|
||||
int_str(v,ss);
|
||||
if length(ss)<len then
|
||||
ss:=space(len-length(ss))+ss;
|
||||
if length(ss)<high(a)+1 then
|
||||
maxlen:=length(ss)
|
||||
else
|
||||
maxlen:=high(a)+1;
|
||||
move(ss[1],pchar(@a)^,maxlen);
|
||||
end;
|
||||
|
||||
procedure fpc_chararray_longword(v : longword;len : longint;var a : array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : longint;
|
||||
maxlen : StrLenInt;
|
||||
begin
|
||||
int_str(v,ss);
|
||||
if length(ss)<len then
|
||||
@ -415,10 +455,74 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_chararray_Float(d : ValReal;len,fr,rt : longint;var a : array of char);{$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
procedure fpc_chararray_uint(v : valuint;len : StrLenInt;var a : array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
procedure fpc_chararray_longword(v : longword;len : StrLenInt;var a : array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : longint;
|
||||
maxlen : StrLenInt;
|
||||
begin
|
||||
int_str(v,ss);
|
||||
if length(ss)<len then
|
||||
ss:=space(len-length(ss))+ss;
|
||||
if length(ss)<high(a)+1 then
|
||||
maxlen:=length(ss)
|
||||
else
|
||||
maxlen:=high(a)+1;
|
||||
move(ss[1],pchar(@a)^,maxlen);
|
||||
end;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
procedure fpc_chararray_qword(v : qword;len : StrLenInt;var a : array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : StrLenInt;
|
||||
begin
|
||||
int_qword_str(v,ss);
|
||||
if length(ss)<len then
|
||||
ss:=space(len-length(ss))+ss;
|
||||
if length(ss)<high(a)+1 then
|
||||
maxlen:=length(ss)
|
||||
else
|
||||
maxlen:=high(a)+1;
|
||||
move(ss[1],pchar(@a)^,maxlen);
|
||||
end;
|
||||
|
||||
|
||||
procedure fpc_chararray_int64(v : int64;len : StrLenInt;var a : array of char);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : StrLenInt;
|
||||
q : qword;
|
||||
begin
|
||||
if v<0 then
|
||||
begin
|
||||
q:=qword(-v);
|
||||
int_qword_str(q,ss);
|
||||
ss:='-'+ss;
|
||||
end
|
||||
else
|
||||
int_qword_str(qword(v),ss);
|
||||
if length(ss)<len then
|
||||
ss:=space(len-length(ss))+ss;
|
||||
if length(ss)<high(a)+1 then
|
||||
maxlen:=length(ss)
|
||||
else
|
||||
maxlen:=high(a)+1;
|
||||
move(ss[1],pchar(@a)^,maxlen);
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
|
||||
procedure fpc_chararray_Float(d : ValReal;len,fr,rt : StrLenInt;var a : array of char);{$ifdef hascompilerproc}compilerproc;{$endif hascompilerproc}
|
||||
var
|
||||
ss : shortstring;
|
||||
maxlen : StrLenInt;
|
||||
begin
|
||||
str_real(len,fr,d,treal_type(rt),ss);
|
||||
if length(ss)<high(a)+1 then
|
||||
@ -435,7 +539,7 @@ end;
|
||||
|
||||
Function InitVal(const s:shortstring;var negativ:boolean;var base:byte):ValSInt;
|
||||
var
|
||||
Code : Longint;
|
||||
Code : StrLenInt;
|
||||
begin
|
||||
{Skip Spaces and Tab}
|
||||
code:=1;
|
||||
@ -476,7 +580,8 @@ begin
|
||||
InitVal:=code;
|
||||
end;
|
||||
|
||||
Function fpc_Val_SInt_ShortStr(DestSize: longint; Const S: ShortString; var Code: ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
Function fpc_Val_SInt_ShortStr(DestSize: StrLenInt; Const S: ShortString; var Code: ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
u, temp, prev, maxPrevValue, maxNewValue: ValUInt;
|
||||
base : byte;
|
||||
@ -523,14 +628,14 @@ begin
|
||||
1: fpc_Val_SInt_ShortStr := shortint(fpc_Val_SInt_ShortStr);
|
||||
2: fpc_Val_SInt_ShortStr := smallint(fpc_Val_SInt_ShortStr);
|
||||
{ Uncomment the folling once full 64bit support is in place
|
||||
4: fpc_Val_SInt_ShortStr := longint(fpc_Val_SInt_ShortStr);}
|
||||
4: fpc_Val_SInt_ShortStr := StrLenInt(fpc_Val_SInt_ShortStr);}
|
||||
End;
|
||||
end;
|
||||
|
||||
{$ifdef hascompilerproc}
|
||||
{ we need this for fpc_Val_SInt_Ansistr and fpc_Val_SInt_WideStr because }
|
||||
{ we have to pass the DestSize parameter on (JM) }
|
||||
Function fpc_Val_SInt_ShortStr(DestSize: longint; Const S: ShortString; var Code: ValSInt): ValSInt; [external name 'FPC_VAL_SINT_SHORTSTR'];
|
||||
Function fpc_Val_SInt_ShortStr(DestSize: StrLenInt; Const S: ShortString; var Code: ValSInt): ValSInt; [external name 'FPC_VAL_SINT_SHORTSTR'];
|
||||
{$endif hascompilerproc}
|
||||
|
||||
|
||||
@ -567,11 +672,116 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; [public, alias:'FPC_VAL_INT64_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
type
|
||||
QWordRec = packed record
|
||||
l1,l2: longint;
|
||||
end;
|
||||
|
||||
var
|
||||
u, temp, prev, maxint64, maxqword : qword;
|
||||
base : byte;
|
||||
negative : boolean;
|
||||
|
||||
begin
|
||||
fpc_val_int64_shortstr := 0;
|
||||
Temp:=0;
|
||||
Code:=InitVal(s,negative,base);
|
||||
if Code>length(s) then
|
||||
exit;
|
||||
{ high(int64) produces 0 in version 1.0 (JM) }
|
||||
with qwordrec(maxint64) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := $7fffffff;
|
||||
end;
|
||||
with qwordrec(maxqword) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := longint($ffffffff);
|
||||
end;
|
||||
|
||||
while Code<=Length(s) do
|
||||
begin
|
||||
case s[Code] of
|
||||
'0'..'9' : u:=Ord(S[Code])-Ord('0');
|
||||
'A'..'F' : u:=Ord(S[Code])-(Ord('A')-10);
|
||||
'a'..'f' : u:=Ord(S[Code])-(Ord('a')-10);
|
||||
else
|
||||
u:=16;
|
||||
end;
|
||||
Prev:=Temp;
|
||||
Temp:=Temp*Int64(base);
|
||||
If (u >= base) or
|
||||
((base = 10) and
|
||||
(maxint64-temp+ord(negative) < u)) or
|
||||
((base <> 10) and
|
||||
(qword(maxqword-temp) < u)) or
|
||||
(prev > maxqword div qword(base)) Then
|
||||
Begin
|
||||
fpc_val_int64_shortstr := 0;
|
||||
Exit
|
||||
End;
|
||||
Temp:=Temp+u;
|
||||
inc(code);
|
||||
end;
|
||||
code:=0;
|
||||
fpc_val_int64_shortstr:=int64(Temp);
|
||||
If Negative Then
|
||||
fpc_val_int64_shortstr:=-fpc_val_int64_shortstr;
|
||||
end;
|
||||
|
||||
|
||||
Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; [public, alias:'FPC_VAL_QWORD_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
type qwordrec = packed record
|
||||
l1,l2: longint;
|
||||
end;
|
||||
var
|
||||
u, prev, maxqword: QWord;
|
||||
base : byte;
|
||||
negative : boolean;
|
||||
begin
|
||||
fpc_val_qword_shortstr:=0;
|
||||
Code:=InitVal(s,negative,base);
|
||||
If Negative or (Code>length(s)) Then
|
||||
Exit;
|
||||
with qwordrec(maxqword) do
|
||||
begin
|
||||
l1 := longint($ffffffff);
|
||||
l2 := longint($ffffffff);
|
||||
end;
|
||||
while Code<=Length(s) do
|
||||
begin
|
||||
case s[Code] of
|
||||
'0'..'9' : u:=Ord(S[Code])-Ord('0');
|
||||
'A'..'F' : u:=Ord(S[Code])-(Ord('A')-10);
|
||||
'a'..'f' : u:=Ord(S[Code])-(Ord('a')-10);
|
||||
else
|
||||
u:=16;
|
||||
end;
|
||||
prev := fpc_val_qword_shortstr;
|
||||
If (u>=base) or
|
||||
((QWord(maxqword-u) div QWord(base))<prev) then
|
||||
Begin
|
||||
fpc_val_qword_shortstr := 0;
|
||||
Exit
|
||||
End;
|
||||
fpc_val_qword_shortstr:=fpc_val_qword_shortstr*QWord(base) + u;
|
||||
inc(code);
|
||||
end;
|
||||
code := 0;
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
|
||||
Function fpc_Val_Real_ShortStr(const s : shortstring; var code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
hd,
|
||||
esign,sign : valreal;
|
||||
exponent,i : longint;
|
||||
exponent,i : StrLenInt;
|
||||
flags : byte;
|
||||
begin
|
||||
fpc_Val_Real_ShortStr:=0.0;
|
||||
@ -670,7 +880,7 @@ fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr*10+(ord(s[code])-ord('0'));
|
||||
end;
|
||||
|
||||
|
||||
Procedure SetString (Var S : Shortstring; Buf : PChar; Len : Longint);
|
||||
Procedure SetString (Var S : Shortstring; Buf : PChar; Len : StrLenInt);
|
||||
begin
|
||||
If Len > High(S) then
|
||||
Len := High(S);
|
||||
@ -683,7 +893,11 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.27 2003-02-26 20:04:47 jonas
|
||||
Revision 1.28 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.27 2003/02/26 20:04:47 jonas
|
||||
* fixed shortstring version of setstring
|
||||
|
||||
Revision 1.26 2002/10/21 19:52:47 jonas
|
||||
|
||||
@ -472,8 +472,8 @@ Procedure Insert(const source:shortstring;Var s:shortstring;index:StrLenInt);
|
||||
Procedure Insert(source:Char;Var s:shortstring;index:StrLenInt);
|
||||
Function Pos(const substr:shortstring;const s:shortstring):StrLenInt;
|
||||
Function Pos(C:Char;const s:shortstring):StrLenInt;
|
||||
Procedure SetString (Var S : Shortstring; Buf : PChar; Len : Longint);
|
||||
Procedure SetString (Var S : AnsiString; Buf : PChar; Len : Longint);
|
||||
Procedure SetString (Var S : Shortstring; Buf : PChar; Len : StrLenInt);
|
||||
Procedure SetString (Var S : AnsiString; Buf : PChar; Len : StrLenInt);
|
||||
{$ifndef INTERNLENGTH}
|
||||
Function Length(s:string):byte;
|
||||
{$endif INTERNLENGTH}
|
||||
@ -505,20 +505,20 @@ function length(c:char):byte;
|
||||
****************************************************************************}
|
||||
|
||||
{$ifndef INTERNSETLENGTH}
|
||||
Procedure SetLength (Var S : AnsiString; l : Longint);
|
||||
Procedure SetLength (Var S : AnsiString; l : StrLenInt);
|
||||
{$endif INTERNSETLENGTH}
|
||||
Procedure UniqueString (Var S : AnsiString);
|
||||
{$ifndef INTERNLENGTH}
|
||||
Function Length (Const S : AnsiString) : Longint;
|
||||
Function Length (Const S : AnsiString) : StrLenInt;
|
||||
{$endif INTERNLENGTH}
|
||||
{$ifndef InternCopy}
|
||||
Function Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;
|
||||
Function Copy (Const S : AnsiString; Index,Size : StrLenInt) : AnsiString;
|
||||
{$endif interncopy}
|
||||
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;
|
||||
Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : StrLenInt;
|
||||
Function Pos (c : Char; Const s : AnsiString) : StrLenInt;
|
||||
Procedure Insert (Const Source : AnsiString; Var S : AnsiString; Index : StrLenInt);
|
||||
Procedure Delete (Var S : AnsiString; Index,Size: StrLenInt);
|
||||
Function StringOfChar(c : char;l : StrLenInt) : AnsiString;
|
||||
function upcase(const s : ansistring) : ansistring;
|
||||
function lowercase(const s : ansistring) : ansistring;
|
||||
|
||||
@ -529,32 +529,32 @@ function lowercase(const s : ansistring) : ansistring;
|
||||
|
||||
{$ifdef HASWIDESTRING}
|
||||
{$ifndef INTERNSETLENGTH}
|
||||
Procedure SetLength (Var S : WideString; l : Longint);
|
||||
Procedure SetLength (Var S : WideString; l : StrLenInt);
|
||||
{$endif INTERNSETLENGTH}
|
||||
Procedure UniqueString (Var S : WideString);
|
||||
{$ifndef INTERNLENGTH}
|
||||
Function Length (Const S : WideString) : Longint;
|
||||
Function Length (Const S : WideString) : StrLenInt;
|
||||
{$endif INTERNLENGTH}
|
||||
{$ifndef InternCopy}
|
||||
Function Copy (Const S : WideString; Index,Size : Longint) : WideString;
|
||||
Function Copy (Const S : WideString; Index,Size : StrLenInt) : WideString;
|
||||
{$endif interncopy}
|
||||
Function Pos (Const Substr : WideString; Const Source : WideString) : Longint;
|
||||
Function Pos (c : Char; Const s : WideString) : Longint;
|
||||
Function Pos (c : WideChar; Const s : WideString) : Longint;
|
||||
Procedure Insert (Const Source : WideString; Var S : WideString; Index : Longint);
|
||||
Procedure Delete (Var S : WideString; Index,Size: Longint);
|
||||
Procedure SetString (Var S : WideString; Buf : PWideChar; Len : Longint);
|
||||
Procedure SetString (Var S : WideString; Buf : PChar; Len : Longint);
|
||||
Function Pos (Const Substr : WideString; Const Source : WideString) : StrLenInt;
|
||||
Function Pos (c : Char; Const s : WideString) : StrLenInt;
|
||||
Function Pos (c : WideChar; Const s : WideString) : StrLenInt;
|
||||
Procedure Insert (Const Source : WideString; Var S : WideString; Index : StrLenInt);
|
||||
Procedure Delete (Var S : WideString; Index,Size: StrLenInt);
|
||||
Procedure SetString (Var S : WideString; Buf : PWideChar; Len : StrLenInt);
|
||||
Procedure SetString (Var S : WideString; Buf : PChar; Len : StrLenInt);
|
||||
|
||||
function WideCharToString(S : PWideChar) : AnsiString;
|
||||
function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : LongInt) : PWideChar;
|
||||
function WideCharLenToString(S : PWideChar;Len : LongInt) : AnsiString;
|
||||
procedure WideCharLenToStrVar(Src : PWideChar;Len : LongInt;var Dest : AnsiString);
|
||||
function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : StrLenInt) : PWideChar;
|
||||
function WideCharLenToString(S : PWideChar;Len : StrLenInt) : AnsiString;
|
||||
procedure WideCharLenToStrVar(Src : PWideChar;Len : StrLenInt;var Dest : AnsiString);
|
||||
procedure WideCharToStrVar(S : PWideChar;var Dest : AnsiString);
|
||||
|
||||
Type
|
||||
TWide2AnsiMove=procedure(source:pwidechar;dest:pchar;len:longint);
|
||||
TAnsi2WideMove=procedure(source:pchar;dest:pwidechar;len:longint);
|
||||
TWide2AnsiMove=procedure(source:pwidechar;dest:pchar;len:StrLenInt);
|
||||
TAnsi2WideMove=procedure(source:pchar;dest:pwidechar;len:StrLenInt);
|
||||
|
||||
TWideStringManager = record
|
||||
Wide2AnsiMove : TWide2AnsiMove;
|
||||
@ -737,7 +737,11 @@ const
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.88 2004-04-22 17:10:38 peter
|
||||
Revision 1.89 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.88 2004/04/22 17:10:38 peter
|
||||
* random(int64) added
|
||||
|
||||
Revision 1.87 2004/03/23 22:35:45 peter
|
||||
|
||||
@ -651,13 +651,15 @@ Begin
|
||||
End;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
procedure fpc_write_text_qword(len : longint;var t : text;q : qword); iocheck; [public,alias:'FPC_WRITE_TEXT_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
s : string;
|
||||
begin
|
||||
if (InOutRes<>0) then
|
||||
exit;
|
||||
qword_str(q,s);
|
||||
str(q,s);
|
||||
write_str(len,t,s);
|
||||
end;
|
||||
|
||||
@ -667,10 +669,11 @@ var
|
||||
begin
|
||||
if (InOutRes<>0) then
|
||||
exit;
|
||||
int64_str(i,s);
|
||||
str(i,s);
|
||||
write_str(len,t,s);
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); iocheck; [Public,Alias:'FPC_WRITE_TEXT_FLOAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
@ -1266,7 +1269,11 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.21 2004-04-22 21:10:56 peter
|
||||
Revision 1.22 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.21 2004/04/22 21:10:56 peter
|
||||
* do_read/do_write addr argument changed to pointer
|
||||
|
||||
Revision 1.20 2002/11/29 16:26:52 peter
|
||||
|
||||
@ -21,9 +21,9 @@
|
||||
WideString is defined as a 'silent' pwidechar :
|
||||
a pwidechar that points to :
|
||||
|
||||
@-12 : Longint for maximum size;
|
||||
@-8 : Longint for size;
|
||||
@-4 : Longint for reference count;
|
||||
@-12 : StrLenInt for maximum size;
|
||||
@-8 : StrLenInt for size;
|
||||
@-4 : StrLenInt for reference count;
|
||||
@ : String + Terminating #0;
|
||||
Pwidechar(Widestring) is a valid typecast.
|
||||
So WS[i] is converted to the address @WS+i-1.
|
||||
@ -37,7 +37,7 @@ Type
|
||||
TWideRec = Packed Record
|
||||
Maxlen,
|
||||
len,
|
||||
ref : Longint;
|
||||
ref : StrLenInt;
|
||||
First : WideChar;
|
||||
end;
|
||||
|
||||
@ -53,9 +53,9 @@ Const
|
||||
These routines can be overwritten for the Current Locale
|
||||
}
|
||||
|
||||
procedure Wide2AnsiMove(source:pwidechar;dest:pchar;len:longint);
|
||||
procedure Wide2AnsiMove(source:pwidechar;dest:pchar;len:StrLenInt);
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
for i:=1 to len do
|
||||
begin
|
||||
@ -69,9 +69,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure Ansi2WideMove(source:pchar;dest:pwidechar;len:longint);
|
||||
procedure Ansi2WideMove(source:pchar;dest:pwidechar;len:StrLenInt);
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
for i:=1 to len do
|
||||
begin
|
||||
@ -144,14 +144,14 @@ end;
|
||||
{$endif}
|
||||
|
||||
|
||||
Function NewWideString(Len : Longint) : Pointer;
|
||||
Function NewWideString(Len : StrLenInt) : Pointer;
|
||||
{
|
||||
Allocate a new WideString on the heap.
|
||||
initialize it to zero length and reference count 1.
|
||||
}
|
||||
Var
|
||||
P : Pointer;
|
||||
l : Longint;
|
||||
l : StrLenInt;
|
||||
begin
|
||||
{ request a multiple of 16 because the heap manager alloctes anyways chunks of 16 bytes }
|
||||
L := (Len*sizeof(WideChar)+WideRecLen+15) and (not 15);
|
||||
@ -187,9 +187,9 @@ Procedure fpc_WideStr_Decr_Ref (Var S : Pointer);saveregisters;[Public,Alias:'FP
|
||||
If the reference count is zero, deallocate the string;
|
||||
}
|
||||
Type
|
||||
plongint = ^longint;
|
||||
pStrLenInt = ^StrLenInt;
|
||||
Var
|
||||
l : plongint;
|
||||
l : pStrLenInt;
|
||||
Begin
|
||||
{ Zero string }
|
||||
If S=Nil then exit;
|
||||
@ -226,12 +226,12 @@ end;
|
||||
Procedure fpc_WideStr_Incr_Ref (S : Pointer);saveregisters;[external name 'FPC_WIDESTR_INCR_REF'];
|
||||
{$endif compilerproc}
|
||||
|
||||
function fpc_WideStr_To_ShortStr (high_of_res: longint;const S2 : WideString): shortstring;[Public, alias: 'FPC_WIDESTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
function fpc_WideStr_To_ShortStr (high_of_res: StrLenInt;const S2 : WideString): shortstring;[Public, alias: 'FPC_WIDESTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{
|
||||
Converts a WideString to a ShortString;
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if S2='' then
|
||||
fpc_WideStr_To_ShortStr:=''
|
||||
@ -251,7 +251,7 @@ Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString; {$ifdef h
|
||||
Converts a ShortString to a WideString;
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
Size:=Length(S2);
|
||||
Setlength (fpc_ShortStr_To_WideStr,Size);
|
||||
@ -277,7 +277,7 @@ Function fpc_WideStr_To_AnsiStr (const S2 : WideString): AnsiString; {$ifdef has
|
||||
Converts a WideString to an AnsiString
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if s2='' then
|
||||
exit;
|
||||
@ -305,7 +305,7 @@ Function fpc_AnsiStr_To_WideStr (Const S2 : AnsiString): WideString; {$ifdef has
|
||||
Converts an AnsiString to a WideString;
|
||||
}
|
||||
Var
|
||||
Size : Longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if s2='' then
|
||||
exit;
|
||||
@ -322,7 +322,7 @@ end;
|
||||
{ compilers with widestrings should have compiler procs }
|
||||
Function fpc_PWideChar_To_AnsiStr(const p : pwidechar): ansistring; compilerproc;
|
||||
var
|
||||
Size : longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if p=nil then
|
||||
exit;
|
||||
@ -339,7 +339,7 @@ end;
|
||||
|
||||
Function fpc_PWideChar_To_WideStr(const p : pwidechar): widestring; compilerproc;
|
||||
var
|
||||
Size : longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if p=nil then
|
||||
exit;
|
||||
@ -356,7 +356,7 @@ end;
|
||||
|
||||
Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerproc;
|
||||
var
|
||||
Size : longint;
|
||||
Size : StrLenInt;
|
||||
begin
|
||||
if p=nil then
|
||||
begin
|
||||
@ -417,7 +417,7 @@ Procedure fpc_WideStr_Concat (S1,S2 : WideString;var S3 : WideString);[Public, a
|
||||
Result Goes to S3;
|
||||
}
|
||||
Var
|
||||
Size,Location : Longint;
|
||||
Size,Location : StrLenInt;
|
||||
begin
|
||||
{ only assign if s1 or s2 is empty }
|
||||
if (S1='') then
|
||||
@ -462,7 +462,7 @@ end;
|
||||
|
||||
Function fpc_PChar_To_WideStr(const p : pchar): WideString; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
L : Longint;
|
||||
L : StrLenInt;
|
||||
begin
|
||||
if (not assigned(p)) or (p[0]=#0) Then
|
||||
{ result is automatically set to '' }
|
||||
@ -483,7 +483,7 @@ end;
|
||||
|
||||
Function fpc_CharArray_To_WideStr(const arr: array of char): WideString; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
i : longint;
|
||||
i : StrLenInt;
|
||||
begin
|
||||
if arr[0]=#0 Then
|
||||
{ result is automatically set to '' }
|
||||
@ -497,10 +497,10 @@ end;
|
||||
|
||||
{ old style helper }
|
||||
{$ifndef hascompilerproc}
|
||||
Procedure fpc_CharArray_To_WideStr(var a : WideString; p: pointer; len: longint); [Public,Alias : 'FPC_CHARARRAY_TO_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_CharArray_To_WideStr(var a : WideString; p: pointer; len: StrLenInt); [Public,Alias : 'FPC_CHARARRAY_TO_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
src: pchar;
|
||||
i: longint;
|
||||
i: StrLenInt;
|
||||
begin
|
||||
src := pchar(p);
|
||||
if src[0]=#0 Then
|
||||
@ -519,9 +519,9 @@ end;
|
||||
{$ifdef hascompilerproc}
|
||||
{ inside the compiler, the resulttype is modified to that of the actual }
|
||||
{ chararray we're converting to (JM) }
|
||||
function fpc_widestr_to_chararray(arraysize: longint; const src: WideString): fpc_big_chararray;[public,alias: 'FPC_WIDESTR_TO_CHARARRAY']; compilerproc;
|
||||
function fpc_widestr_to_chararray(arraysize: StrLenInt; const src: WideString): fpc_big_chararray;[public,alias: 'FPC_WIDESTR_TO_CHARARRAY']; compilerproc;
|
||||
var
|
||||
len: longint;
|
||||
len: StrLenInt;
|
||||
begin
|
||||
len := length(src);
|
||||
if len > arraysize then
|
||||
@ -533,7 +533,7 @@ begin
|
||||
end;
|
||||
{$endif hascompilerproc}
|
||||
|
||||
Function fpc_WideStr_Compare(const S1,S2 : WideString): Longint;[Public,Alias : 'FPC_WIDESTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Function fpc_WideStr_Compare(const S1,S2 : WideString): StrLenInt;[Public,Alias : 'FPC_WIDESTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{
|
||||
Compares 2 WideStrings;
|
||||
The result is
|
||||
@ -542,7 +542,7 @@ Function fpc_WideStr_Compare(const S1,S2 : WideString): Longint;[Public,Alias :
|
||||
>0 if S1>S2
|
||||
}
|
||||
Var
|
||||
MaxI,Temp : Longint;
|
||||
MaxI,Temp : StrLenInt;
|
||||
begin
|
||||
if pointer(S1)=pointer(S2) then
|
||||
begin
|
||||
@ -567,16 +567,16 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_WideStr_CheckRange(len,index : longint);[Public,Alias : 'FPC_WIDESTR_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_WideStr_CheckRange(len,index : StrLenInt);[Public,Alias : 'FPC_WIDESTR_RANGECHECK']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
begin
|
||||
if (index>len) or (Index<1) then
|
||||
HandleErrorFrame(201,get_frame);
|
||||
end;
|
||||
|
||||
{$ifndef INTERNSETLENGTH}
|
||||
Procedure SetLength (Var S : WideString; l : Longint);
|
||||
Procedure SetLength (Var S : WideString; l : StrLenInt);
|
||||
{$else INTERNSETLENGTH}
|
||||
Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint);[Public,Alias : 'FPC_WIDESTR_SETLENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Procedure fpc_WideStr_SetLength (Var S : WideString; l : StrLenInt);[Public,Alias : 'FPC_WIDESTR_SETLENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif INTERNSETLENGTH}
|
||||
{
|
||||
Sets The length of string S to L.
|
||||
@ -584,7 +584,7 @@ Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint);[Public,Alias
|
||||
}
|
||||
Var
|
||||
Temp : Pointer;
|
||||
movelen, NewLen: longint;
|
||||
movelen, NewLen: StrLenInt;
|
||||
begin
|
||||
if (l>0) then
|
||||
begin
|
||||
@ -646,7 +646,7 @@ function WideCharToString(S : PWideChar) : AnsiString;
|
||||
result:=WideCharLenToString(s,Length(WideString(s)));
|
||||
end;
|
||||
|
||||
function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : LongInt) : PWideChar;
|
||||
function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : StrLenInt) : PWideChar;
|
||||
begin
|
||||
if Length(Src)<DestSize then
|
||||
Ansi2WideMoveProc(PChar(Src),Dest,Length(Src))
|
||||
@ -655,13 +655,13 @@ function StringToWideChar(const Src : AnsiString;Dest : PWideChar;DestSize : Lon
|
||||
result:=Dest;
|
||||
end;
|
||||
|
||||
function WideCharLenToString(S : PWideChar;Len : LongInt) : AnsiString;
|
||||
function WideCharLenToString(S : PWideChar;Len : StrLenInt) : AnsiString;
|
||||
begin
|
||||
SetLength(result,Len);
|
||||
Wide2AnsiMove(S,PChar(result),Len);
|
||||
end;
|
||||
|
||||
procedure WideCharLenToStrVar(Src : PWideChar;Len : LongInt;var Dest : AnsiString);
|
||||
procedure WideCharLenToStrVar(Src : PWideChar;Len : StrLenInt;var Dest : AnsiString);
|
||||
begin
|
||||
Dest:=WideCharLenToString(Src,Len);
|
||||
end;
|
||||
@ -673,7 +673,7 @@ procedure WideCharToStrVar(S : PWideChar;var Dest : AnsiString);
|
||||
|
||||
|
||||
{$ifndef INTERNLENGTH}
|
||||
Function Length (Const S : WideString) : Longint;
|
||||
Function Length (Const S : WideString) : StrLenInt;
|
||||
{
|
||||
Returns the length of an WideString.
|
||||
Takes in acount that zero strings are NIL;
|
||||
@ -697,7 +697,7 @@ Function fpc_widestr_Unique(Var S : Pointer): Pointer; [Public,Alias : 'FPC_WIDE
|
||||
}
|
||||
Var
|
||||
SNew : Pointer;
|
||||
L : Longint;
|
||||
L : StrLenInt;
|
||||
begin
|
||||
pointer(result) := pointer(s);
|
||||
If Pointer(S)=Nil then
|
||||
@ -716,9 +716,9 @@ end;
|
||||
|
||||
|
||||
{$ifdef interncopy}
|
||||
Function Fpc_WideStr_Copy (Const S : WideString; Index,Size : Longint) : WideString;compilerproc;
|
||||
Function Fpc_WideStr_Copy (Const S : WideString; Index,Size : StrLenInt) : WideString;compilerproc;
|
||||
{$else}
|
||||
Function Copy (Const S : WideString; Index,Size : Longint) : WideString;
|
||||
Function Copy (Const S : WideString; Index,Size : StrLenInt) : WideString;
|
||||
{$endif}
|
||||
var
|
||||
ResultAddress : Pointer;
|
||||
@ -752,7 +752,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function Pos (Const Substr : WideString; Const Source : WideString) : Longint;
|
||||
Function Pos (Const Substr : WideString; Const Source : WideString) : StrLenInt;
|
||||
var
|
||||
i,MaxLen : StrLenInt;
|
||||
pc : pwidechar;
|
||||
@ -779,9 +779,9 @@ end;
|
||||
|
||||
|
||||
{ Faster version for a widechar alone }
|
||||
Function Pos (c : WideChar; Const s : WideString) : Longint;
|
||||
Function Pos (c : WideChar; Const s : WideString) : StrLenInt;
|
||||
var
|
||||
i: longint;
|
||||
i: StrLenInt;
|
||||
pc : pwidechar;
|
||||
begin
|
||||
pc:=@s[1];
|
||||
@ -802,9 +802,9 @@ 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 : WideString) : Longint;
|
||||
Function Pos (c : Char; Const s : WideString) : StrLenInt;
|
||||
var
|
||||
i: longint;
|
||||
i: StrLenInt;
|
||||
wc : widechar;
|
||||
pc : pwidechar;
|
||||
begin
|
||||
@ -824,9 +824,9 @@ end;
|
||||
|
||||
|
||||
|
||||
Procedure Delete (Var S : WideString; Index,Size: Longint);
|
||||
Procedure Delete (Var S : WideString; Index,Size: StrLenInt);
|
||||
Var
|
||||
LS : Longint;
|
||||
LS : StrLenInt;
|
||||
begin
|
||||
If Length(S)=0 then
|
||||
exit;
|
||||
@ -848,10 +848,10 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure Insert (Const Source : WideString; Var S : WideString; Index : Longint);
|
||||
Procedure Insert (Const Source : WideString; Var S : WideString; Index : StrLenInt);
|
||||
var
|
||||
Temp : WideString;
|
||||
LS : Longint;
|
||||
LS : StrLenInt;
|
||||
begin
|
||||
If Length(Source)=0 then
|
||||
exit;
|
||||
@ -872,9 +872,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure SetString (Var S : WideString; Buf : PWideChar; Len : Longint);
|
||||
Procedure SetString (Var S : WideString; Buf : PWideChar; Len : StrLenInt);
|
||||
var
|
||||
BufLen: longint;
|
||||
BufLen: StrLenInt;
|
||||
begin
|
||||
SetLength(S,Len);
|
||||
If (Buf<>Nil) and (Len>0) then
|
||||
@ -888,9 +888,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure SetString (Var S : WideString; Buf : PChar; Len : Longint);
|
||||
Procedure SetString (Var S : WideString; Buf : PChar; Len : StrLenInt);
|
||||
var
|
||||
BufLen: longint;
|
||||
BufLen: StrLenInt;
|
||||
begin
|
||||
SetLength(S,Len);
|
||||
If (Buf<>Nil) and (Len>0) then
|
||||
@ -934,7 +934,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Function fpc_Val_SInt_WideStr (DestSize: longint; Const S : WideString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Function fpc_Val_SInt_WideStr (DestSize: StrLenInt; Const S : WideString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
@ -948,6 +948,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_WIDESTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
@ -977,8 +980,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : longint;var s : WideString);[public,alias:'FPC_WIDESTR_FLOAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
|
||||
procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : StrLenInt;var s : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
var
|
||||
ss : shortstring;
|
||||
begin
|
||||
@ -987,29 +992,60 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_WideStr_Longword(C : Longword;Len : Longint; Var S : WideString);[Public,Alias : 'FPC_WIDESTR_CARDINAL']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
Procedure fpc_WideStr_SInt(v : ValSint; Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
Procedure fpc_WideStr_Longint(v : Longint; Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
str(C:Len,SS);
|
||||
Str (v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure fpc_WideStr_Longint(L : Longint; Len : Longint; Var S : WideString);[Public,Alias : 'FPC_WIDESTR_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$ifdef STR_USES_VALINT}
|
||||
Procedure fpc_WideStr_UInt(v : ValUInt;Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$else}
|
||||
Procedure fpc_WideStr_Longword(v : Longword;Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
{$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
Str (L:Len,SS);
|
||||
str(v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
{$ifndef CPU64}
|
||||
|
||||
Procedure fpc_WideStr_Int64(v : Int64; Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
Str (v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
|
||||
Procedure fpc_WideStr_Qword(v : Qword;Len : StrLenInt; Var S : WideString);{$ifdef hascompilerproc} compilerproc; {$endif}
|
||||
Var
|
||||
SS : ShortString;
|
||||
begin
|
||||
str(v:Len,SS);
|
||||
S:=SS;
|
||||
end;
|
||||
|
||||
{$endif CPU64}
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.35 2004-01-22 22:09:05 peter
|
||||
Revision 1.36 2004-04-29 18:59:43 peter
|
||||
* str() helpers now also use valint/valuint
|
||||
* int64/qword helpers disabled for cpu64
|
||||
|
||||
Revision 1.35 2004/01/22 22:09:05 peter
|
||||
* finalize needs to reset to nil after decr_ref
|
||||
|
||||
Revision 1.34 2003/11/29 17:27:05 michael
|
||||
|
||||
Loading…
Reference in New Issue
Block a user