Browse Source

* Empty string cannot be number

michael 4 years ago
parent
commit
5fef7a40d0
1 changed files with 15 additions and 0 deletions
  1. 15 0
      packages/rtl/system.pas

+ 15 - 0
packages/rtl/system.pas

@@ -664,6 +664,11 @@ function valint(const S: String; MinVal, MaxVal: NativeInt; out Code: Integer):
 var
 var
   x: double;
   x: double;
 begin
 begin
+  if S='' then
+    begin
+    code:=1;
+    exit;
+    end;
   x:=Number(S);
   x:=Number(S);
   if isNaN(x) then
   if isNaN(x) then
     case copy(s,1,1) of
     case copy(s,1,1) of
@@ -694,6 +699,11 @@ procedure val(const S: String; out NI: NativeUInt; out Code: Integer);
 var
 var
   x : double;
   x : double;
 begin
 begin
+  if S='' then
+    begin
+    code:=1;
+    exit;
+    end;
   x:=Number(S);
   x:=Number(S);
   if isNaN(x) or (X<>Int(X)) or (X<0) then
   if isNaN(x) or (X<>Int(X)) or (X<0) then
     Code:=1
     Code:=1
@@ -738,6 +748,11 @@ procedure val(const S : String; out d : double; out Code : Integer);
 Var
 Var
   x: double;
   x: double;
 begin
 begin
+  if S='' then
+    begin
+    code:=1;
+    exit;
+    end;
   x:=Number(S);
   x:=Number(S);
   if isNaN(x) then
   if isNaN(x) then
     Code:=1
     Code:=1