Browse Source

--- Merging r39866 into '.':
U rtl/unix/sysutils.pp
--- Recording mergeinfo for merge of r39866 into '.':
U .
--- Merging r39870 into '.':
U utils/bin2obj.pp
--- Recording mergeinfo for merge of r39870 into '.':
G .
--- Merging r39973 into '.':
U packages/fcl-image/src/fpimage.pp
--- Recording mergeinfo for merge of r39973 into '.':
G .
--- Merging r39995 into '.':
U packages/gmp/src/gmp.pas
U rtl/objpas/math.pp
--- Recording mergeinfo for merge of r39995 into '.':
G .
--- Merging r40215 into '.':
U packages/paszlib/src/zipper.pp
--- Recording mergeinfo for merge of r40215 into '.':
G .

# revisions: 39866,39870,39973,39995,40215,

git-svn-id: branches/fixes_3_2@40528 -

marco 6 years ago
parent
commit
1f921d4ac0

+ 4 - 1
packages/fcl-image/src/fpimage.pp

@@ -721,7 +721,10 @@ function TryHtmlToFPColor(const S: String; out FPColor: TFPColor): Boolean;
   begin
   begin
     Val('$'+Hex, W, Code);
     Val('$'+Hex, W, Code);
     Result := (Code = 0);
     Result := (Code = 0);
-    if not Result then W := 0;
+    if Result then
+      W := W or (W shl 8)
+    else
+      W := 0;
   end;
   end;
 
 
 var
 var

+ 1 - 1
packages/gmp/src/gmp.pas

@@ -1751,7 +1751,7 @@ end;
 
 
 procedure propagate_prec(var result, op1, op2: MPFloat);
 procedure propagate_prec(var result, op1, op2: MPFloat);
 begin
 begin
-  f_set_prec(result, max(valsint(f_get_prec(op1)), f_get_prec(op2)));
+  f_set_prec(result, max(  int64(f_get_prec(op1)), Int64(f_get_prec(op2)) ) );
 end;
 end;
 
 
 // --- ext bindings ----
 // --- ext bindings ----

+ 17 - 6
packages/paszlib/src/zipper.pp

@@ -1609,6 +1609,8 @@ Begin
       begin
       begin
         Compressed_Size := FZip.Size;
         Compressed_Size := FZip.Size;
         LocalZip64Fld.Compressed_Size := 0;
         LocalZip64Fld.Compressed_Size := 0;
+        if LocalZip64Fld.Original_Size > 0 then
+          IsZip64 := true;
       end;
       end;
       if AZipVersionReqd > Extract_Version_Reqd then
       if AZipVersionReqd > Extract_Version_Reqd then
         Extract_Version_Reqd := AZipVersionReqd;
         Extract_Version_Reqd := AZipVersionReqd;
@@ -1623,7 +1625,6 @@ Begin
   FOutStream.WriteBuffer(ZFileName[1],Length(ZFileName));
   FOutStream.WriteBuffer(ZFileName[1],Length(ZFileName));
   if IsZip64 then
   if IsZip64 then
   begin
   begin
-    LocalZip64ExtHdr.Header_ID:=ZIP64_HEADER_ID;
     FOutStream.WriteBuffer({$IFDEF ENDIAN_BIG}SwapEDFH{$ENDIF}(LocalZip64ExtHdr),SizeOf(LocalZip64ExtHdr));
     FOutStream.WriteBuffer({$IFDEF ENDIAN_BIG}SwapEDFH{$ENDIF}(LocalZip64ExtHdr),SizeOf(LocalZip64ExtHdr));
     FOutStream.WriteBuffer({$IFDEF ENDIAN_BIG}SwapZ64EIF{$ENDIF}(LocalZip64Fld),SizeOf(LocalZip64Fld));
     FOutStream.WriteBuffer({$IFDEF ENDIAN_BIG}SwapZ64EIF{$ENDIF}(LocalZip64Fld),SizeOf(LocalZip64Fld));
   end;
   end;
@@ -1682,7 +1683,7 @@ Begin
             end;
             end;
           end;
           end;
       // Move past extra fields
       // Move past extra fields
-      FOutStream.Seek(SavePos+LocalHdr.Extra_Field_Length,soFromBeginning);
+      //FOutStream.Seek(SavePos+LocalHdr.Extra_Field_Length,soFromBeginning);
       end;
       end;
     SavePos := FOutStream.Position;
     SavePos := FOutStream.Position;
     FillChar(CentralHdr,SizeOf(CentralHdr),0);
     FillChar(CentralHdr,SizeOf(CentralHdr),0);
@@ -1732,9 +1733,16 @@ Begin
       else
       else
         Local_Header_Offset := HdrPos;
         Local_Header_Offset := HdrPos;
       end;
       end;
+
+      if IsZip64 then
+      begin
+          CentralHdr.Extra_Field_Length:=SizeOf(LocalZip64ExtHdr)+SizeOf(LocalZip64Fld);
+      end else CentralHdr.Extra_Field_Length :=0;
+
     FOutStream.Seek(0,soEnd);
     FOutStream.Seek(0,soEnd);
     FOutStream.WriteBuffer({$IFDEF FPC_BIG_ENDIAN}SwapCFH{$ENDIF}(CentralHdr),SizeOf(CentralHdr));
     FOutStream.WriteBuffer({$IFDEF FPC_BIG_ENDIAN}SwapCFH{$ENDIF}(CentralHdr),SizeOf(CentralHdr));
     FOutStream.WriteBuffer(ZFileName[1],Length(ZFileName));
     FOutStream.WriteBuffer(ZFileName[1],Length(ZFileName));
+
     if IsZip64 then
     if IsZip64 then
       begin
       begin
       FOutStream.Seek(0,soEnd);
       FOutStream.Seek(0,soEnd);
@@ -1744,7 +1752,7 @@ Begin
 
 
     Inc(ACount);
     Inc(ACount);
     // Move past compressed file data to next header:
     // Move past compressed file data to next header:
-    if Iszip64 then
+    if LocalZip64Fld.Compressed_Size > 0 then
       FOutStream.Seek(SavePos + LocalZip64Fld.Compressed_Size,soBeginning)
       FOutStream.Seek(SavePos + LocalZip64Fld.Compressed_Size,soBeginning)
     else
     else
       FOutStream.Seek(SavePos + LocalHdr.Compressed_Size,soBeginning);
       FOutStream.Seek(SavePos + LocalHdr.Compressed_Size,soBeginning);
@@ -2093,7 +2101,7 @@ function TUnZipper.OpenOutput(OutFileName: RawByteString;
 Var
 Var
   Path: RawByteString;
   Path: RawByteString;
   OldDirectorySeparators: set of char;
   OldDirectorySeparators: set of char;
-  
+
 Begin
 Begin
   { the default RTL behavior is broken on Unix platforms
   { the default RTL behavior is broken on Unix platforms
     for Windows compatibility: it allows both '/' and '\'
     for Windows compatibility: it allows both '/' and '\'
@@ -2521,7 +2529,10 @@ Begin
           end;
           end;
         end;
         end;
       // Move past extra fields and file comment to next header
       // Move past extra fields and file comment to next header
-      FZipStream.Seek(SavePos+Extra_Field_Length+File_Comment_Length,soFromBeginning);
+      if File_Comment_Length > 0 then
+          FZipStream.Seek(File_Comment_Length,soFromCurrent);
+      // this doesn't work properly when zip file size is over 4Gb, so commented off
+      //FZipStream.Seek(SavePos+Extra_Field_Length+File_Comment_Length,soFromBeginning);
       end;
       end;
     end;
     end;
 end;
 end;
@@ -2605,7 +2616,7 @@ Var
           OnProgress:=Self.OnProgress;
           OnProgress:=Self.OnProgress;
           OnPercent:=Self.OnPercent;
           OnPercent:=Self.OnPercent;
           DeCompress;
           DeCompress;
-          Self.FTotPos := FTotPos; 
+          Self.FTotPos := FTotPos;
           if Item.CRC32 <> Crc32Val then
           if Item.CRC32 <> Crc32Val then
             raise EZipError.CreateFmt(SErrInvalidCRC,[Item.ArchiveFileName]);
             raise EZipError.CreateFmt(SErrInvalidCRC,[Item.ArchiveFileName]);
         Finally
         Finally

+ 18 - 0
rtl/objpas/math.pp

@@ -165,6 +165,8 @@ function Max(a, b: Cardinal): Cardinal; overload;
 }
 }
 function Min(a, b: Int64): Int64;inline; overload;
 function Min(a, b: Int64): Int64;inline; overload;
 function Max(a, b: Int64): Int64;inline; overload;
 function Max(a, b: Int64): Int64;inline; overload;
+function Min(a, b: QWord): QWord;inline; overload;
+function Max(a, b: QWord): QWord;inline; overload;
 {$ifdef FPC_HAS_TYPE_SINGLE}
 {$ifdef FPC_HAS_TYPE_SINGLE}
 function Min(a, b: Single): Single;inline; overload;
 function Min(a, b: Single): Single;inline; overload;
 function Max(a, b: Single): Single;inline; overload;
 function Max(a, b: Single): Single;inline; overload;
@@ -2056,6 +2058,22 @@ begin
     Result := b;
     Result := b;
 end;
 end;
 
 
+function Min(a, b: QWord): QWord; inline;
+begin
+  if a < b then
+    Result := a
+  else
+    Result := b;
+end;
+
+function Max(a, b: QWord): Qword;inline;
+begin
+  if a > b then
+    Result := a
+  else
+    Result := b;
+end;
+
 {$ifdef FPC_HAS_TYPE_SINGLE}
 {$ifdef FPC_HAS_TYPE_SINGLE}
 function Min(a, b: Single): Single;inline;
 function Min(a, b: Single): Single;inline;
 begin
 begin

+ 2 - 2
rtl/unix/sysutils.pp

@@ -1128,7 +1128,7 @@ var
   fs : tstatfs;
   fs : tstatfs;
 Begin
 Begin
   if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
   if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
-     ((Drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
+     ((Drive in [Low(DriveStr)..High(DriveStr)]) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
    Diskfree:=int64(fs.bavail)*int64(fs.bsize)
    Diskfree:=int64(fs.bavail)*int64(fs.bsize)
   else
   else
    Diskfree:=-1;
    Diskfree:=-1;
@@ -1141,7 +1141,7 @@ var
   fs : tstatfs;
   fs : tstatfs;
 Begin
 Begin
   if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
   if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
-     ((drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
+     ((Drive in [Low(DriveStr)..High(DriveStr)]) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
    DiskSize:=int64(fs.blocks)*int64(fs.bsize)
    DiskSize:=int64(fs.blocks)*int64(fs.bsize)
   else
   else
    DiskSize:=-1;
    DiskSize:=-1;

+ 18 - 4
utils/bin2obj.pp

@@ -26,7 +26,8 @@ var
   WriteAsciiData,
   WriteAsciiData,
   CompressData,
   CompressData,
   EnCodeData,
   EnCodeData,
-  CompileUnit : Boolean;
+  CompileUnit,
+  WriteHex : Boolean;
   Cryptkey : IDEAcryptKey;
   Cryptkey : IDEAcryptKey;
   InStream,
   InStream,
   MemStream,
   MemStream,
@@ -39,6 +40,7 @@ begin
   Writeln ('Usage: bin2obj [options] -c constname [infile] ');
   Writeln ('Usage: bin2obj [options] -c constname [infile] ');
   Writeln ('Where options is a combination of : ');
   Writeln ('Where options is a combination of : ');
   Writeln ('   -a        write asciii data instead of bytes');
   Writeln ('   -a        write asciii data instead of bytes');
+  Writeln ('   -x        write numerical values as hexadecimal numbers');
   Writeln ('   -z        compress data.');
   Writeln ('   -z        compress data.');
   Writeln ('   -e key    encrypt data with key (must have 8 characters)');
   Writeln ('   -e key    encrypt data with key (must have 8 characters)');
   Writeln ('   -o        output filename');
   Writeln ('   -o        output filename');
@@ -62,13 +64,15 @@ begin
   UnitName:='';
   UnitName:='';
   NeedUnitName:=False;
   NeedUnitName:=False;
   WriteAsciiData:=False;
   WriteAsciiData:=False;
+  WriteHex:=False;
   Repeat
   Repeat
-    c:=GetOpt('ac:e:o:zhu::U::');
+    c:=GetOpt('ac:e:o:zhu::U::x');
     Case C of
     Case C of
       'a' : WriteAsciiData:=True;
       'a' : WriteAsciiData:=True;
       'c' : ConstName:=OptArg;
       'c' : ConstName:=OptArg;
       'h','?' : usage;
       'h','?' : usage;
       'z' : CompressData := True;
       'z' : CompressData := True;
+      'x' : WriteHex := True;
       'e' : begin
       'e' : begin
             EncodeData:=True;
             EncodeData:=True;
             If Length(OptArg)<8 then
             If Length(OptArg)<8 then
@@ -209,13 +213,23 @@ begin
     begin
     begin
     MemStream.Read(B,1);
     MemStream.Read(B,1);
     If Not WriteAsciiData then
     If Not WriteAsciiData then
-       ToAdd:=Format('%3d',[b])
+       begin
+         if WriteHex then
+           ToAdd:=Format('$%2.2x',[b])
+         else
+           ToAdd:=Format('%3d',[b]);
+       end
     else
     else
       If (B in [32..127]) and not (B in [10,13,39]) then
       If (B in [32..127]) and not (B in [10,13,39]) then
         ToAdd:=''''+Chr(b)+''''
         ToAdd:=''''+Chr(b)+''''
       else
       else
 //        ToAdd:=Format('''%s''',[Chr(b)]);
 //        ToAdd:=Format('''%s''',[Chr(b)]);
-        ToAdd:=Format('#%d',[B]);
+        begin
+          if WriteHex then
+            ToAdd:=Format('#$%x',[B])
+          else
+            ToAdd:=Format('#%d',[B]);
+        end;
     If I<Count then
     If I<Count then
       ToAdd:=ToAdd+',';
       ToAdd:=ToAdd+',';
     Line:=Line+ToAdd;
     Line:=Line+ToAdd;