Browse Source

* merged fixes branch fixes

peter 24 years ago
parent
commit
12a3b11cdb
2 changed files with 60 additions and 29 deletions
  1. 43 25
      rtl/inc/generic.inc
  2. 17 4
      rtl/inc/genset.inc

+ 43 - 25
rtl/inc/generic.inc

@@ -745,30 +745,40 @@ end;
 
 procedure int_str(l : longint;var s : string);
 var
-   sign : boolean;
-begin
-  { Workaround: }
-  if l=$80000000 then
-   begin
-     s:='-2147483648';
-     exit;
-   end;
-  if l<0 then
-    begin
-       sign:=true;
-       l:=-l;
-    end
-  else
-    sign:=false;
-  s:='';
-  while l>0 do
-    begin
-       s:=char(ord('0')+(l mod 10))+s;
-       l:=l div 10;
-    end;
-  if sign then
-    s:='-'+s;
-end;
+  value: longint;
+  negative: boolean;
+
+  begin
+     negative := false;
+     s:='';
+     { Workaround: }
+     if l=$80000000 then
+       begin
+         s:='-2147483648';
+         exit;
+       end;
+     { handle case where l = 0 }
+     if l = 0 then
+       begin
+         s:='0';
+         exit;
+       end;
+     If l < 0 then
+       begin
+         negative := true;
+         value:=abs(l);
+       end
+     else
+         value:=l;
+     { handle non-zero case }
+     while value>0 do
+       begin
+         s:=char((value mod 10)+ord('0'))+s;
+         value := value div 10;
+       end;
+     if negative then
+       s := '-' + s;
+  end;
 
 {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
 
@@ -777,6 +787,11 @@ end;
 procedure int_str(l : cardinal;var s : string);
 begin
   s:='';
+  if l = 0 then
+  begin
+    s := '0';
+    exit;
+  end;
   while l>0 do
     begin
        s:=char(ord('0')+(l mod 10))+s;
@@ -811,7 +826,10 @@ end;
 
 {
   $Log$
-  Revision 1.11  2001-05-16 17:44:25  jonas
+  Revision 1.12  2001-05-18 22:59:59  peter
+    * merged fixes branch fixes
+
+  Revision 1.11  2001/05/16 17:44:25  jonas
     + odd() for cardinal, int64 and qword (merged)
 
   Revision 1.10  2001/05/09 19:57:07  peter

+ 17 - 4
rtl/inc/genset.inc

@@ -95,7 +95,11 @@
 
 
 {$ifndef FPC_SYSTEM_HAS_FPC_SET_IN_BYTE}
- function do_in_byte(p : pointer;b : byte):boolean;[public,alias:'FPC_SET_IN_BYTE'];
+
+{ saveregisters is a bit of overkill, but this routine should save all registers }
+{ and it should be overriden for each platform and be written in assembler       }
+{ by saving all required registers.                                              }
+ function do_in_byte(p : pointer;b : byte):boolean;[public,alias:'FPC_SET_IN_BYTE'];saveregisters;
  {
    tests if the element b is in the set p the carryflag is set if it present
  }
@@ -167,7 +171,10 @@
 {$endif}
 
 {$ifndef FPC_SYSTEM_HAS_FPC_SET_COMP_SETS}
- function do_comp_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_COMP_SETS'];
+{ saveregisters is a bit of overkill, but this routine should save all registers }
+{ and it should be overriden for each platform and be written in assembler       }
+{ by saving all required registers.                                              }
+ function do_comp_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_COMP_SETS'];saveregisters;
  {
   compares set1 and set2 zeroflag is set if they are equal
  }
@@ -185,7 +192,10 @@
 
 
 {$ifndef FPC_SYSTEM_HAS_FPC_SET_CONTAINS_SET}
- function do_contains_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_CONTAINS_SETS'];
+{ saveregisters is a bit of overkill, but this routine should save all registers }
+{ and it should be overriden for each platform and be written in assembler       }
+{ by saving all required registers.                                              }
+ function do_contains_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_CONTAINS_SETS'];saveregisters;
  {
   on exit, zero flag is set if set1 <= set2 (set2 contains set1)
  }
@@ -202,7 +212,10 @@
 
 {
   $Log$
-  Revision 1.2  2001-05-09 19:57:07  peter
+  Revision 1.3  2001-05-18 22:59:59  peter
+    * merged fixes branch fixes
+
+  Revision 1.2  2001/05/09 19:57:07  peter
   *** empty log message ***
 
 }