View Issue Details

IDProjectCategoryView StatusLast Update
0037049FPCRTLpublic2020-05-13 17:12
ReporterBi0T1N Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.2.0 
Summary0037049: [Patch] Add TryStrToUInt, StrToUInt and StrToUIntDef
DescriptionJust for convenience and compatibility as FPC already has its own DWord functions.

http://docwiki.embarcadero.com/Libraries/Rio/en/System.SysUtils.TryStrToUInt
http://docwiki.embarcadero.com/Libraries/Rio/en/System.SysUtils.StrToUInt
http://docwiki.embarcadero.com/Libraries/Rio/en/System.SysUtils.StrToUIntDef
TagsNo tags attached.
Fixed in Revision45336
FPCOldBugId
FPCTarget4.0.0
Attached Files

Activities

Bi0T1N

2020-05-11 15:09

reporter  

01-Missing_UInt_functions.patch (2,353 bytes)   
diff --git rtl/objpas/sysutils/sysstr.inc rtl/objpas/sysutils/sysstr.inc
index 529ac2a77c..3819eb2a4e 100644
--- rtl/objpas/sysutils/sysstr.inc
+++ rtl/objpas/sysutils/sysstr.inc
@@ -979,6 +979,16 @@ begin
   TryStrToDWord:=Error=0
 end;
 
+function StrToUInt(const s: string): Cardinal;
+begin
+  StrToUInt:=StrToDWord(s);
+end;
+
+function TryStrToUInt(const s: string; out C: Cardinal): Boolean;
+begin
+  TryStrToUInt:=TryStrToDWord(s, C);
+end;
+
 function TryStrToQWord(const s: string; Out Q: QWord): boolean;
 var Error : word;
 begin
@@ -1011,6 +1021,11 @@ begin
   if Error <> 0 then result := Default;
 end;
 
+function StrToUIntDef(const S: string; Default: Cardinal): Cardinal;
+begin
+  Result:=StrToDWordDef(S, Default);
+end;
+
 {   StrToInt64Def converts the string S to an int64 value,
     Default is returned in case S does not represent a valid int64 value  }
 
diff --git rtl/objpas/sysutils/sysstrh.inc rtl/objpas/sysutils/sysstrh.inc
index 30d8716623..1cf84e07fe 100644
--- rtl/objpas/sysutils/sysstrh.inc
+++ rtl/objpas/sysutils/sysstrh.inc
@@ -122,16 +122,19 @@ function IntToHex(Value: Int64; Digits: integer): string;
 function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
 function StrToInt(const s: string): Longint;
 function StrToDWord(const s: string): DWord;
+function StrToUInt(const s: string): Cardinal;
 function StrToInt64(const s: string): int64;
 function StrToQWord(const s: string): QWord; 
 function StrToUInt64(const s: string): UInt64; inline;
 function TryStrToInt(const s: string; Out i : Longint) : boolean;
 function TryStrToDWord(const s: string; Out D : DWord) : boolean;
+function TryStrToUInt(const s: string; out C: Cardinal): Boolean;
 function TryStrToInt64(const s: string; Out i : int64) : boolean;
 function TryStrToQWord(const s: string; Out Q : QWord) : boolean;
 function TryStrToUInt64(const s: string; Out u : UInt64) : boolean; inline;
 function StrToIntDef(const S: string; Default: Longint): Longint;
 function StrToDWordDef(const S: string; Default: DWord): DWord;
+function StrToUIntDef(const S: string; Default: Cardinal): Cardinal;
 function StrToInt64Def(const S: string; Default: int64): int64;
 function StrToQWordDef(const S: string; Default: QWord): QWord;
 function StrToUInt64Def(const S: string; Default: UInt64): UInt64; inline;

Michael Van Canneyt

2020-05-11 15:15

administrator   ~0122714

Applied, thank you very much.

Issue History

Date Modified Username Field Change
2020-05-11 15:09 Bi0T1N New Issue
2020-05-11 15:09 Bi0T1N File Added: 01-Missing_UInt_functions.patch
2020-05-11 15:15 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-05-11 15:15 Michael Van Canneyt Status new => resolved
2020-05-11 15:15 Michael Van Canneyt Resolution open => fixed
2020-05-11 15:15 Michael Van Canneyt Fixed in Version => 3.2.0
2020-05-11 15:15 Michael Van Canneyt Fixed in Revision => 45336
2020-05-11 15:15 Michael Van Canneyt FPCTarget => 4.0.0
2020-05-11 15:15 Michael Van Canneyt Note Added: 0122714
2020-05-13 17:12 Bi0T1N Status resolved => closed