Browse Source

+ Merged from fixbranch

michael 25 years ago
parent
commit
619dac6c93
2 changed files with 34 additions and 15 deletions
  1. 31 14
      rtl/inc/generic.inc
  2. 3 1
      rtl/inc/makefile.inc

+ 31 - 14
rtl/inc/generic.inc

@@ -285,23 +285,32 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 function CompareChar0(var buf1,buf2;len:longint):longint;
 function CompareChar0(var buf1,buf2;len:longint):longint;
-var
-  I,J,K,bytesTodo : longint;
+
+Var i : longint;
+
 begin
 begin
-  K:=0;
-  if Len<>0 then
+  I:=0;
+  if (Len<>0) and (@Buf1<>@Buf2) then
    begin
    begin
-     I:=IndexByte(Buf1,Len,0);
-     J:=IndexByte(Buf2,Len,0);
-     if (I<>0) and (J<>0) then
+     while (I<Len) And
+           ((Pbyte(@Buf1)[i]<>0) and (PByte(@buf2)[i]<>0)) and 
+           (pbyte(@Buf1)[I]=pbyte(@Buf2)[I])  do
+      inc(I);
+     if (I=Len) or 
+        (PByte(@Buf1)[i]=0) or 
+        (PByte(@buf2)[I]=0) then  {No difference or 0 reached }
+      I:=0
+     else
       begin
       begin
-        bytesTodo:=I;
-        if J<bytesTodo then
-         bytesTodo:=J;
-        K:=CompareByte(Buf1,Buf2,bytesTodo); // Safe for bytesTodo=0
+        I:=pbyte(@Buf1)[I]-pbyte(@Buf2)[I];
+        if I>0 then
+         I:=1
+        else
+         if I<0 then
+          I:=-1;
       end;
       end;
-  end;
-  CompareChar0:=K;
+   end;
+  CompareChar0:=I;
 end;
 end;
 {$endif ndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$endif ndef FPC_SYSTEM_HAS_COMPARECHAR0}
 
 
@@ -766,7 +775,15 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2000-08-09 11:29:01  jonas
+  Revision 1.5  2000-10-01 13:17:35  michael
+  + Merged from fixbranch
+
+  Revision 1.4  2000/08/09 11:29:01  jonas
+
+  Revision 1.1.2.2  2000/10/01 13:14:50  michael
+  + Corrected and (hopefully) improved compare0
+
+  Revision 1.1.2.1  2000/08/09 11:21:32  jonas
     + FPC_STR_TO_CHARARRAY routine necessary for string -> chararray
     + FPC_STR_TO_CHARARRAY routine necessary for string -> chararray
       conversions fix (merged fropm fixes branch)
       conversions fix (merged fropm fixes branch)
 
 

+ 3 - 1
rtl/inc/makefile.inc

@@ -5,7 +5,9 @@
 # implementation files.
 # implementation files.
 
 
 SYSNAMES=systemh heaph mathh filerec textrec system real2str sstrings innr \
 SYSNAMES=systemh heaph mathh filerec textrec system real2str sstrings innr \
-         file typefile text rtti heap astrings objpas objpash except int64
+         file typefile text rtti heap astrings objpas objpash except int64 \
+         generic
+         
 SYSINCNAMES=$(addsuffix .inc,$(SYSNAMES))
 SYSINCNAMES=$(addsuffix .inc,$(SYSNAMES))
 
 
 # Other unit names which can be used for all systems
 # Other unit names which can be used for all systems