Ver código fonte

* fixed (harmless) range check errors
* fixed indentation

git-svn-id: trunk@12709 -

Jonas Maebe 16 anos atrás
pai
commit
dc2d1c6926
2 arquivos alterados com 25 adições e 24 exclusões
  1. 7 9
      rtl/objpas/sysutils/syspch.inc
  2. 18 15
      rtl/objpas/sysutils/sysstr.inc

+ 7 - 9
rtl/objpas/sysutils/syspch.inc

@@ -22,9 +22,6 @@
 
 
 {  PChar functions  }
 {  PChar functions  }
 
 
-type
-   CharArray = array[0..0] of char;
-
 { Processor dependent part, shared withs strings unit }
 { Processor dependent part, shared withs strings unit }
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
 {$i cgenstr.inc}
 {$i cgenstr.inc}
@@ -88,13 +85,14 @@ function StrPLCopy(Dest: PChar; Source: string; MaxLen: SizeUInt): PChar;
 var Count: SizeUInt;
 var Count: SizeUInt;
 begin
 begin
 result := Dest;
 result := Dest;
-if (Result <> Nil) and (MaxLen <> 0) then begin
-   Count := Length(Source);
-   if Count > MaxLen then
+if (Result <> Nil) and (MaxLen <> 0) then
+  begin
+    Count := Length(Source);
+    if Count > MaxLen then
       Count := MaxLen;
       Count := MaxLen;
-   StrMove(Dest, PChar(Source), Count);
-   CharArray(result^)[Count] := #0;  { terminate ! }
-   end ;
+    StrMove(Dest, PChar(Source), Count);
+    result[Count] := #0;  { terminate ! }
+  end ;
 end ;
 end ;
 
 
 
 

+ 18 - 15
rtl/objpas/sysutils/sysstr.inc

@@ -210,24 +210,27 @@ begin
     Count := Count2
     Count := Count2
   else
   else
     Count := Count1;
     Count := Count1;
-  P1 := @S1[1];
-  P2 := @S2[1];
   i := 0;
   i := 0;
-  while i < Count do
-  begin
-    Chr1 := byte(p1^);
-    Chr2 := byte(p2^);
-    if Chr1 <> Chr2 then
+  if count>0 then
     begin
     begin
-      if Chr1 in [97..122] then
-        dec(Chr1,32);
-      if Chr2 in [97..122] then
-        dec(Chr2,32);
-      if Chr1 <> Chr2 then
-        Break;
+      P1 := @S1[1];
+      P2 := @S2[1];
+      while i < Count do
+        begin
+          Chr1 := byte(p1^);
+          Chr2 := byte(p2^);
+          if Chr1 <> Chr2 then
+            begin
+              if Chr1 in [97..122] then
+                dec(Chr1,32);
+              if Chr2 in [97..122] then
+                dec(Chr2,32);
+              if Chr1 <> Chr2 then
+                Break;
+            end;
+          Inc(P1); Inc(P2); Inc(I);
+        end;
     end;
     end;
-    Inc(P1); Inc(P2); Inc(I);
-  end;
   if i < Count then
   if i < Count then
     result := Chr1-Chr2
     result := Chr1-Chr2
   else
   else