Browse Source

# revisions: 45877,46843,46844,46845,47275,47364,47505

git-svn-id: branches/fixes_3_2@47574 -
marco 4 years ago
parent
commit
f0445c2374

+ 1 - 1
packages/fcl-net/src/ssockets.pp

@@ -1143,7 +1143,7 @@ begin
   TimeOutResult:=ctrError;
   TimeOutResult:=ctrError;
   {$ifdef unix}
   {$ifdef unix}
   Err:=ESysEINTR;
   Err:=ESysEINTR;
-  While IsError and (Err in [ESysEINTR, ESysEAGAIN]) do
+  While IsError and ((Err=ESysEINTR) or (Err=ESysEAGAIN)) do
   {$endif}
   {$endif}
     begin
     begin
     IsError:=fpConnect(Handle, @addr, sizeof(addr))<>0;
     IsError:=fpConnect(Handle, @addr, sizeof(addr))<>0;

+ 1 - 1
packages/rtl-extra/src/win/serial.pp

@@ -463,7 +463,7 @@ begin
     Timeouts.ReadTotalTimeoutConstant := mSec;
     Timeouts.ReadTotalTimeoutConstant := mSec;
     SetCommTimeouts(Handle, Timeouts)
     SetCommTimeouts(Handle, Timeouts)
   end;
   end;
-  if not ReadFile(Handle, Buffer, count, BytesRead, nil) then
+  if not ReadFile(Handle, Buffer[0], count, BytesRead, nil) then
     result := 0
     result := 0
   else
   else
     result := BytesRead
     result := BytesRead

+ 6 - 1
packages/rtl-generics/src/generics.collections.pas

@@ -1179,6 +1179,7 @@ var
   i: SizeInt;
   i: SizeInt;
   LEnumerator: TEnumerator<T>;
   LEnumerator: TEnumerator<T>;
 begin
 begin
+  Result := nil;
   SetLength(Result, ACount);
   SetLength(Result, ACount);
 
 
   try
   try
@@ -1620,6 +1621,7 @@ begin
   if (ACount < 0) or (AIndex < 0) or (AIndex + ACount > Count) then
   if (ACount < 0) or (AIndex < 0) or (AIndex + ACount > Count) then
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
 
 
+  LDeleted := nil;
   SetLength(LDeleted, ACount);
   SetLength(LDeleted, ACount);
   System.Move(FItems[AIndex], LDeleted[0], ACount * SizeOf(T));
   System.Move(FItems[AIndex], LDeleted[0], ACount * SizeOf(T));
 
 
@@ -2021,6 +2023,9 @@ end;
 
 
 function TQueue<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
 function TQueue<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
 begin
 begin
+  if Count = 0 then
+    raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
+
   Result := FItems[AIndex];
   Result := FItems[AIndex];
   FItems[AIndex] := Default(T);
   FItems[AIndex] := Default(T);
   Inc(FLow);
   Inc(FLow);
@@ -2151,7 +2156,7 @@ end;
 
 
 function TStack<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
 function TStack<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
 begin
 begin
-  if AIndex < 0 then
+  if (AIndex < 0) or (Count = 0) then
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
 
 
   Result := FItems[AIndex];
   Result := FItems[AIndex];

+ 3 - 0
packages/rtl-generics/src/inc/generics.dictionaries.inc

@@ -138,6 +138,7 @@ var
   i: SizeInt;
   i: SizeInt;
   LEnumerator: TEnumerator<TDictionaryPair>;
   LEnumerator: TEnumerator<TDictionaryPair>;
 begin
 begin
+  Result := nil;
   SetLength(Result, ACount);
   SetLength(Result, ACount);
   LEnumerator := DoGetEnumerator;
   LEnumerator := DoGetEnumerator;
 
 
@@ -292,6 +293,7 @@ var
   i: SizeInt;
   i: SizeInt;
   LEnumerator: TPointersEnumerator;
   LEnumerator: TPointersEnumerator;
 begin
 begin
+  Result := nil;
   SetLength(Result, GetCount);
   SetLength(Result, GetCount);
 
 
   try
   try
@@ -480,6 +482,7 @@ begin
   if ASizePow2 < 0 then
   if ASizePow2 < 0 then
     OutOfMemoryError;
     OutOfMemoryError;
 
 
+  LNewItems := nil;
   SetLength(LNewItems, ASizePow2);
   SetLength(LNewItems, ASizePow2);
   UpdateItemsThreshold(ASizePow2);
   UpdateItemsThreshold(ASizePow2);
 
 

+ 32 - 9
packages/rtl-generics/tests/tests.generics.dictionary.pas

@@ -351,6 +351,7 @@ Var
 begin
 begin
   DoAdd(3);
   DoAdd(3);
   A:=Dict.ToArray;
   A:=Dict.ToArray;
+  specialize TArrayHelper<TMyPair>.Sort(A{$ifndef fpc}, specialize TComparer<TMySimpleDict.TMyPair>.Default{$endif});
   AssertEquals('Length Ok',3,Length(A));
   AssertEquals('Length Ok',3,Length(A));
   For I:=1 to 3 do
   For I:=1 to 3 do
     begin
     begin
@@ -370,6 +371,7 @@ Var
 begin
 begin
   DoAdd(3);
   DoAdd(3);
   A:=Dict.Keys.ToArray;
   A:=Dict.Keys.ToArray;
+  specialize TArrayHelper<Integer>.Sort(A{$ifndef fpc}, specialize TComparer<Integer>.Default{$endif});
   AssertEquals('Length Ok',3,Length(A));
   AssertEquals('Length Ok',3,Length(A));
   For I:=1 to 3 do
   For I:=1 to 3 do
     begin
     begin
@@ -387,6 +389,7 @@ Var
 begin
 begin
   DoAdd(3);
   DoAdd(3);
   A:=Dict.Values.ToArray;
   A:=Dict.Values.ToArray;
+  specialize TArrayHelper<String>.Sort(A{$ifndef fpc}, specialize TComparer<String>.Default{$endif});
   AssertEquals('Length Ok',3,Length(A));
   AssertEquals('Length Ok',3,Length(A));
   For I:=1 to 3 do
   For I:=1 to 3 do
     begin
     begin
@@ -396,6 +399,9 @@ begin
 end;
 end;
 
 
 procedure TTestSimpleDictionary.TestEnumerator;
 procedure TTestSimpleDictionary.TestEnumerator;
+type
+  TStringList = specialize TList<String>;
+  TIntegerList = specialize TList<Integer>;
 
 
 Var
 Var
 {$ifdef fpc}
 {$ifdef fpc}
@@ -403,19 +409,36 @@ Var
 {$else}
 {$else}
   A : TMySimpleDict.TMyPair;
   A : TMySimpleDict.TMyPair;
 {$endif}
 {$endif}
-  I : Integer;
+  I,J : Integer;
   SI : String;
   SI : String;
-
+  IL: TIntegerList;
+  SL: TStringList;
 begin
 begin
   DoAdd(3);
   DoAdd(3);
-  I:=1;
-  For A in Dict do
-    begin
-    SI:=IntToStr(I);
-    AssertEquals('key '+SI,I,A.Key);
-    AssertEquals('Value '+SI,SI,A.Value);
-    Inc(I);
+  IL:=Nil;
+  SL:=TStringList.Create;
+  try
+    IL:=TIntegerList.Create;
+    for I:=1 to 3 do begin
+      IL.Add(I);
+      SL.Add(IntToStr(I));
     end;
     end;
+    I:=1;
+    For A in Dict do
+      begin
+      SI:=IntToStr(I);
+      J:=IL.IndexOf(A.Key);
+      AssertTrue('key '+SI,J>=0);
+      IL.Delete(J);
+      J:=SL.IndexOf(A.Value);
+      AssertTrue('value '+SI,J>=0);
+      SL.Delete(J);
+      Inc(I);
+      end;
+  finally
+    IL.Free;
+    SL.Free;
+  end;
 end;
 end;
 
 
 procedure TTestSimpleDictionary.TestNotification;
 procedure TTestSimpleDictionary.TestNotification;

+ 1 - 1
packages/rtl-generics/tests/tests.generics.queue.pas

@@ -377,7 +377,7 @@ procedure TTestSimpleQueue.TestValueNotificationDelete;
 begin
 begin
   DoAdd(3);
   DoAdd(3);
   Queue.OnNotify:=@DoValueNotify;
   Queue.OnNotify:=@DoValueNotify;
-  SetExpectValues('Clear',['1','2','3'],[cnRemoved,cnRemoved,cnRemoved],{$IFDEF FPC}true{$ELSE}False{$endif});
+  SetExpectValues('Clear',['1','2','3'],[cnRemoved,cnRemoved,cnRemoved]);
   Queue.Clear;
   Queue.Clear;
   DoneExpectValues;
   DoneExpectValues;
 end;
 end;

+ 0 - 1
rtl/win/wininc/base.inc

@@ -206,7 +206,6 @@
      LPPTSTR = ^LPTSTR;
      LPPTSTR = ^LPTSTR;
 
 
      PWINBOOL = ^WINBOOL;
      PWINBOOL = ^WINBOOL;
-     PBOOLEAN = ^BYTE {$ifndef VER2_2} deprecated {$endif};
 
 
      PBYTE = System.PByte;
      PBYTE = System.PByte;