Browse Source

* val for dword and qword didn't handle the max values
correctly
* val for qword works again
+ val with int64/qword and ansistring implemented

florian 25 years ago
parent
commit
bd0d141b08
2 changed files with 37 additions and 8 deletions
  1. 28 4
      rtl/inc/int64.inc
  2. 9 4
      rtl/inc/sstrings.inc

+ 28 - 4
rtl/inc/int64.inc

@@ -464,8 +464,7 @@
        end;
        prev := ValQWord;
        If (u>=base) or
-          (qword(maxqword - prev) < u) or 
-          (prev > maxqword div qword(u)) Then
+         ((QWord(maxqword-u) div QWord(base))<prev) then
          Begin
            ValQWord := 0;
            Exit
@@ -476,10 +475,35 @@
     code := 0;
   end;
 
+Function ValQWord(Const S: AnsiString; var Code: ValSInt): QWord; [public, alias:'FPC_VAL_QWORD_ANSISTR'];
+
+  begin
+     ValQWord:=0;
+     if length(S)>255 then
+       code:=256
+     else
+       ValQWord:=ValQWord(ShortString(S),Code);
+  end;
+
+Function ValInt64(Const S: AnsiString; var Code: ValSInt): Int64; [public, alias:'FPC_VAL_INT64_ANSISTR'];
+
+  begin
+     ValInt64:=0;
+     if length(S)>255 then
+       code:=256
+     else
+       ValInt64:=ValInt64(ShortString(S),Code);
+  end;
 
 {
   $Log$
-  Revision 1.5  2000-12-07 17:19:47  jonas
+  Revision 1.6  2000-12-09 20:52:40  florian
+    * val for dword and qword didn't handle the max values
+      correctly
+    * val for qword works again
+    + val with int64/qword and ansistring implemented
+
+  Revision 1.5  2000/12/07 17:19:47  jonas
     * new constant handling: from now on, hex constants >$7fffffff are
       parsed as unsigned constants (otherwise, $80000000 got sign extended
       and became $ffffffff80000000), all constants in the longint range
@@ -501,5 +525,5 @@
 
   Revision 1.2  2000/07/13 11:33:44  michael
   + removed logs
- 
+
 }

+ 9 - 4
rtl/inc/sstrings.inc

@@ -422,8 +422,7 @@ begin
      end;
      prev := ValUnsignedInt;
      If (u>=base) or
-        (ValUInt(MaxUIntValue-ValUnsignedInt) < u) or
-        (prev > (ValUInt(MaxUIntValue) div ValUInt(Base))) then
+        (ValUInt(MaxUIntValue-u) div ValUInt(Base)<prev) then
       begin
         ValUnsignedInt:=0;
         exit;
@@ -553,7 +552,13 @@ end;
 
 {
   $Log$
-  Revision 1.7  2000-11-23 11:41:56  jonas
+  Revision 1.8  2000-12-09 20:52:41  florian
+    * val for dword and qword didn't handle the max values
+      correctly
+    * val for qword works again
+    + val with int64/qword and ansistring implemented
+
+  Revision 1.7  2000/11/23 11:41:56  jonas
     * fix for web bug 1265 by Peter (merged)
 
   Revision 1.6  2000/11/17 17:01:23  jonas
@@ -576,4 +581,4 @@ end;
   Revision 1.2  2000/07/13 11:33:45  michael
   + removed logs
 
-}
+}