Quellcode durchsuchen

Merged revisions 10929 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r10929 | jonas | 2008-05-10 12:45:25 +0200 (Sat, 10 May 2008) | 2 lines

* fixed cutils local copy of swapendian

........

git-svn-id: branches/fixes_2_2@10930 -

Jonas Maebe vor 17 Jahren
Ursprung
Commit
784999f675
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      compiler/cutils.pas

+ 5 - 1
compiler/cutils.pas

@@ -1341,7 +1341,11 @@ implementation
 {$ifdef ver2_0}
 function SwapEndian(const AValue: SmallInt): SmallInt;
   begin
-    Result := (AValue shr 8) or (AValue shl 8);
+    { the extra Word type cast is necessary because the "AValue shr 8" }
+    { is turned into "longint(AValue) shr 8", so if AValue < 0 then    }
+    { the sign bits from the upper 16 bits are shifted in rather than  }
+    { zeroes.                                                          }
+    Result := SmallInt((Word(AValue) shr 8) or (Word(AValue) shl 8));
   end;