mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 05:09:13 +02:00
* fix for Mantis #37043: apply patch by Bi0T1N (including test) to add additional overloads for IntToHex including a rerouting of the ordinal helpers' ToHexString to use these overloads
git-svn-id: trunk@45370 -
This commit is contained in:
parent
0548ac5549
commit
f0e8d5dfa6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -16019,6 +16019,7 @@ tests/test/units/sysutils/tfile2.pp svneol=native#text/plain
|
|||||||
tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
|
tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
|
||||||
tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
|
tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
|
||||||
tests/test/units/sysutils/tformat.pp svneol=native#text/plain
|
tests/test/units/sysutils/tformat.pp svneol=native#text/plain
|
||||||
|
tests/test/units/sysutils/tinttohex.pp svneol=native#text/pascal
|
||||||
tests/test/units/sysutils/tlocale.pp svneol=native#text/plain
|
tests/test/units/sysutils/tlocale.pp svneol=native#text/plain
|
||||||
tests/test/units/sysutils/trwsync.pp svneol=native#text/plain
|
tests/test/units/sysutils/trwsync.pp svneol=native#text/plain
|
||||||
tests/test/units/sysutils/tsscanf.pp svneol=native#text/plain
|
tests/test/units/sysutils/tsscanf.pp svneol=native#text/plain
|
||||||
|
@ -61,7 +61,7 @@ end;
|
|||||||
Function TORDINALHELPER.ToHexString: string; overload; inline;
|
Function TORDINALHELPER.ToHexString: string; overload; inline;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=IntToHex(Self,SizeOf(TORDINALTYPE)*2);
|
Result:=IntToHex(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TORDINALHELPER.ToSingle: Single; inline;
|
Function TORDINALHELPER.ToSingle: Single; inline;
|
||||||
|
@ -919,6 +919,46 @@ begin
|
|||||||
result:=IntToHex(Int64(Value),Digits);
|
result:=IntToHex(Int64(Value),Digits);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: Int8): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(Int8));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: UInt8): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(UInt8));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: Int16): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(Int16));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: UInt16): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(UInt16));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: Int32): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(Int32));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: UInt32): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(UInt32));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: Int64): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(Int64));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function IntToHex(Value: UInt64): string;
|
||||||
|
begin
|
||||||
|
Result:=IntToHex(Value, 2*SizeOf(UInt64));
|
||||||
|
end;
|
||||||
|
|
||||||
function TryStrToInt(const s: string; out i : Longint) : boolean;
|
function TryStrToInt(const s: string; out i : Longint) : boolean;
|
||||||
var Error : word;
|
var Error : word;
|
||||||
begin
|
begin
|
||||||
|
@ -120,6 +120,14 @@ function UIntToStr(Value: Cardinal): string; {$ifdef SYSUTILSINLINE}inline;{$END
|
|||||||
function IntToHex(Value: Longint; Digits: integer): string;
|
function IntToHex(Value: Longint; Digits: integer): string;
|
||||||
function IntToHex(Value: Int64; Digits: integer): string;
|
function IntToHex(Value: Int64; Digits: integer): string;
|
||||||
function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: Int8): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: UInt8): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: Int16): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: UInt16): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: Int32): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: UInt32): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: Int64): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
|
function IntToHex(Value: UInt64): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||||
function StrToInt(const s: string): Longint;
|
function StrToInt(const s: string): Longint;
|
||||||
function StrToDWord(const s: string): DWord;
|
function StrToDWord(const s: string): DWord;
|
||||||
function StrToUInt(const s: string): Cardinal;
|
function StrToUInt(const s: string): Cardinal;
|
||||||
|
74
tests/test/units/sysutils/tinttohex.pp
Normal file
74
tests/test/units/sysutils/tinttohex.pp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
program tinttohex;
|
||||||
|
|
||||||
|
{$mode Delphi}
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils;
|
||||||
|
|
||||||
|
var
|
||||||
|
i8: Int8;
|
||||||
|
u8: UInt8;
|
||||||
|
i16: Int16;
|
||||||
|
u32: UInt32;
|
||||||
|
u64: Uint64;
|
||||||
|
i: Integer;
|
||||||
|
s: AnsiString;
|
||||||
|
|
||||||
|
begin
|
||||||
|
i8 := 15;
|
||||||
|
s := IntToHex(i8);
|
||||||
|
writeln(s);
|
||||||
|
if s <> '0F' then halt(1);
|
||||||
|
|
||||||
|
u8 := 224;
|
||||||
|
s := IntToHex(u8);
|
||||||
|
writeln(s);
|
||||||
|
if s <> 'E0' then halt(2);
|
||||||
|
|
||||||
|
i16 := 224;
|
||||||
|
s := IntToHex(i16);
|
||||||
|
writeln(s);
|
||||||
|
if s <> '00E0' then halt(3);
|
||||||
|
|
||||||
|
u32 := 224;
|
||||||
|
s := IntToHex(u32);
|
||||||
|
writeln(s);
|
||||||
|
if s <> '000000E0' then halt(4);
|
||||||
|
|
||||||
|
u64 := 224;
|
||||||
|
s := IntToHex(u64);
|
||||||
|
writeln(s);
|
||||||
|
if s <> '00000000000000E0' then halt(5);
|
||||||
|
|
||||||
|
i := 224;
|
||||||
|
s := IntToHex(i);
|
||||||
|
writeln(s);
|
||||||
|
if s <> '000000E0' then halt(6);
|
||||||
|
|
||||||
|
s := i8.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> '0F' then halt(7);
|
||||||
|
|
||||||
|
s := u8.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> 'E0' then halt(8);
|
||||||
|
|
||||||
|
s := i16.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> '00E0' then halt(9);
|
||||||
|
|
||||||
|
s := u32.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> '000000E0' then halt(10);
|
||||||
|
|
||||||
|
s := u64.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> '00000000000000E0' then halt(11);
|
||||||
|
|
||||||
|
s := i.ToHexString;
|
||||||
|
writeln(s);
|
||||||
|
if s <> '000000E0' then halt(12);
|
||||||
|
|
||||||
|
writeln('ok');
|
||||||
|
//readln;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user