Pārlūkot izejas kodu

* fix regression introduced with r42240: packed sets for the Integer based variants of SetToString/StringToSet need to be shifted on Big Endian systems

git-svn-id: trunk@43048 -
svenbarth 5 gadi atpakaļ
vecāks
revīzija
a00be912aa
1 mainītis faili ar 16 papildinājumiem un 2 dzēšanām
  1. 16 2
      rtl/objpas/typinfo.pp

+ 16 - 2
rtl/objpas/typinfo.pp

@@ -1196,11 +1196,18 @@ end;
 Function SetToString(PropInfo: PPropInfo; Value: LongInt; Brackets: Boolean) : String;
 Function SetToString(PropInfo: PPropInfo; Value: LongInt; Brackets: Boolean) : String;
 
 
 begin
 begin
-  Result:=SetToString(PropInfo^.PropType, @Value, Brackets);
+  Result:=SetToString(PropInfo^.PropType, Value, Brackets);
 end;
 end;
 
 
 Function SetToString(TypeInfo: PTypeInfo; Value: LongInt; Brackets: Boolean) : String;
 Function SetToString(TypeInfo: PTypeInfo; Value: LongInt; Brackets: Boolean) : String;
 begin
 begin
+{$if defined(FPC_BIG_ENDIAN)}
+  { correctly adjust packed sets that are smaller than 32-bit }
+  case GetTypeData(TypeInfo)^.OrdType of
+    otSByte,otUByte: Value := Value shl (SizeOf(Integer)*8-8);
+    otSWord,otUWord: Value := Value shl (SizeOf(Integer)*8-16);
+  end;
+{$endif}
   Result := SetToString(TypeInfo, @Value, Brackets);
   Result := SetToString(TypeInfo, @Value, Brackets);
 end;
 end;
 
 
@@ -1295,12 +1302,19 @@ end;
 Function StringToSet(PropInfo: PPropInfo; const Value: string): LongInt;
 Function StringToSet(PropInfo: PPropInfo; const Value: string): LongInt;
 
 
 begin
 begin
-  StringToSet(PropInfo^.PropType,Value,@Result);
+  Result:=StringToSet(PropInfo^.PropType,Value);
 end;
 end;
 
 
 Function StringToSet(TypeInfo: PTypeInfo; const Value: string): LongInt;
 Function StringToSet(TypeInfo: PTypeInfo; const Value: string): LongInt;
 begin
 begin
   StringToSet(TypeInfo, Value, @Result);
   StringToSet(TypeInfo, Value, @Result);
+{$if defined(FPC_BIG_ENDIAN)}
+  { correctly adjust packed sets that are smaller than 32-bit }
+  case GetTypeData(TypeInfo)^.OrdType of
+    otSByte,otUByte: Result := Result shr (SizeOf(Integer)*8-8);
+    otSWord,otUWord: Result := Result shr (SizeOf(Integer)*8-16);
+  end;
+{$endif}
 end;
 end;
 
 
 procedure StringToSet(TypeInfo: PTypeInfo; const Value: String; Result: Pointer);
 procedure StringToSet(TypeInfo: PTypeInfo; const Value: String; Result: Pointer);