瀏覽代碼

* val takes care of empty string, patch from Petr Kristan

git-svn-id: trunk@10609 -
florian 17 年之前
父節點
當前提交
347ae5a3bf
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9 3
      rtl/inc/sstrings.inc

+ 9 - 3
rtl/inc/sstrings.inc

@@ -765,12 +765,18 @@ Function InitVal(const s:shortstring;out negativ:boolean;out base:byte):ValSInt;
 var
   Code : SizeInt;
 begin
-{Skip Spaces and Tab}
   code:=1;
+  negativ:=false;
+  base:=10;
+  if length(s)=0 then 
+    begin
+      InitVal:=code;
+      Exit;
+    end;
+{Skip Spaces and Tab}
   while (code<=length(s)) and (s[code] in [' ',#9]) do
    inc(code);
 {Sign}
-  negativ:=false;
   case s[code] of
    '-' : begin
            negativ:=true;
@@ -779,7 +785,6 @@ begin
    '+' : inc(code);
   end;
 {Base}
-  base:=10;
   if code<=length(s) then
    begin
      case s[code] of
@@ -1388,3 +1393,4 @@ begin
     ShortCompareText := L1 - L2;
 end;
 
+