Procházet zdrojové kódy

* fix for Mantis #38390: use Val instead of StrToInt to avoid overload problems
+ added test

git-svn-id: trunk@48399 -

svenbarth před 4 roky
rodič
revize
c3fd06b6b5
3 změnil soubory, kde provedl 29 přidání a 1 odebrání
  1. 1 0
      .gitattributes
  2. 5 1
      rtl/objpas/sysutils/syshelpo.inc
  3. 23 0
      tests/webtbs/tw38390.pp

+ 1 - 0
.gitattributes

@@ -18644,6 +18644,7 @@ tests/webtbs/tw3833.pp svneol=native#text/plain
 tests/webtbs/tw38337.pp svneol=native#text/plain
 tests/webtbs/tw38337.pp svneol=native#text/plain
 tests/webtbs/tw38339.pp svneol=native#text/plain
 tests/webtbs/tw38339.pp svneol=native#text/plain
 tests/webtbs/tw38351.pp -text svneol=native#text/pascal
 tests/webtbs/tw38351.pp -text svneol=native#text/pascal
+tests/webtbs/tw38390.pp svneol=native#text/pascal
 tests/webtbs/tw3840.pp svneol=native#text/plain
 tests/webtbs/tw3840.pp svneol=native#text/plain
 tests/webtbs/tw3841.pp svneol=native#text/plain
 tests/webtbs/tw3841.pp svneol=native#text/plain
 tests/webtbs/tw3863.pp svneol=native#text/plain
 tests/webtbs/tw3863.pp svneol=native#text/plain

+ 5 - 1
rtl/objpas/sysutils/syshelpo.inc

@@ -1,8 +1,12 @@
 
 
 Class Function TORDINALHELPER.Parse(const AString: string): TORDINALTYPE; inline; static;
 Class Function TORDINALHELPER.Parse(const AString: string): TORDINALTYPE; inline; static;
 
 
+var
+  Error: Integer;
 begin
 begin
-  Result:=StrToInt(AString);
+  Val(AString,Result,Error);
+  if Error<>0 then
+    raise EConvertError.CreateFmt(SInvalidInteger,[AString]);
 end;
 end;
 
 
 Class Function TORDINALHELPER.Size: Integer; inline; static;
 Class Function TORDINALHELPER.Size: Integer; inline; static;

+ 23 - 0
tests/webtbs/tw38390.pp

@@ -0,0 +1,23 @@
+program tw38390;
+{$MODE Delphi}
+uses SysUtils;
+
+var
+  s: String;
+  x: UInt64;
+
+begin
+  s := '20000000000';
+  x := UInt64.Parse(s);
+  WriteLn(x);
+  if x <> 20000000000 then
+    Halt(1);
+  UInt64.TryParse(s, x);
+  WriteLn(x);
+  if x <> 20000000000 then
+    Halt(2);
+  x := StrToQWord(s);
+  WriteLn(x);
+  if x <> 20000000000 then
+    Halt(3);
+end.