From 6d287a8db8e1d668b1b6a20f2e2bf242d48b9d42 Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 8 Jun 2021 08:58:21 +0000 Subject: [PATCH] * commit second patch (from Hendi) from mantis #38930, make debug define compiling again git-svn-id: trunk@49492 - --- packages/paszlib/src/infblock.pas | 2 +- packages/paszlib/src/infcodes.pas | 4 ++-- packages/paszlib/src/inffast.pas | 2 +- packages/paszlib/src/zbase.pas | 10 ---------- packages/paszlib/src/zconf.inc | 6 ++++++ packages/paszlib/src/zdeflate.pas | 21 +++++++++++++++++++++ 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/paszlib/src/infblock.pas b/packages/paszlib/src/infblock.pas index 2c19909a57..571a085b3f 100644 --- a/packages/paszlib/src/infblock.pas +++ b/packages/paszlib/src/infblock.pas @@ -45,7 +45,7 @@ function inflate_blocks_sync_point(var s : inflate_blocks_state) : integer; implementation uses - infcodes, inftrees, infutil; + infcodes, inftrees, infutil{$IFDEF ZLIB_DEBUG}, SysUtils{$ENDIF}; { Tables for deflate from PKZIP's appnote.txt. } Const diff --git a/packages/paszlib/src/infcodes.pas b/packages/paszlib/src/infcodes.pas index f4159c429a..b5f2baf502 100644 --- a/packages/paszlib/src/infcodes.pas +++ b/packages/paszlib/src/infcodes.pas @@ -31,7 +31,7 @@ procedure inflate_codes_free(var c : pInflate_codes_state; implementation uses - infutil, inffast; + infutil, inffast{$IFDEF ZLIB_DEBUG}, SysUtils{$ENDIF}; function inflate_codes_new (bl : cardinal; @@ -185,7 +185,7 @@ begin if (t^.base >= $20) and (t^.base < $7f) then Tracevv('inflate: literal '+char(t^.base)) else - Tracevv('inflate: literal '+IntToStr(t^.base)); + Tracevv('inflate: literal $'+IntToHex(t^.base, 2)); {$ENDIF} c^.mode := LIT; continue; { break switch statement } diff --git a/packages/paszlib/src/inffast.pas b/packages/paszlib/src/inffast.pas index 4a70c49cc3..74f33966e6 100644 --- a/packages/paszlib/src/inffast.pas +++ b/packages/paszlib/src/inffast.pas @@ -29,7 +29,7 @@ function inflate_fast( bl : cardinal; implementation uses - infutil; + infutil{$IFDEF ZLIB_DEBUG}, SysUtils{$ENDIF}; { Called with number of bytes left to write in window at least 258 diff --git a/packages/paszlib/src/zbase.pas b/packages/paszlib/src/zbase.pas index f9bf887c93..34d1fc5440 100644 --- a/packages/paszlib/src/zbase.pas +++ b/packages/paszlib/src/zbase.pas @@ -380,10 +380,6 @@ const PRESET_DICT = $20; { preset dictionary flag in zlib header } - {$IFDEF ZLIB_DEBUG} - procedure Assert(cond : boolean; msg : string); - {$ENDIF} - procedure Trace(x : string); procedure Tracev(x : string); procedure Tracevv(x : string); @@ -461,12 +457,6 @@ begin Halt(1); end; -procedure Assert(cond : boolean; msg : string); -begin - if not cond then - z_error(msg); -end; - procedure Trace(x : string); begin WriteLn(x); diff --git a/packages/paszlib/src/zconf.inc b/packages/paszlib/src/zconf.inc index 7086daea68..94acbb5e18 100644 --- a/packages/paszlib/src/zconf.inc +++ b/packages/paszlib/src/zconf.inc @@ -36,3 +36,9 @@ {$UNDEF MAXSEG_64K} {$UNDEF Delphi32} {$ENDIF} + +{- $DEFINE ZLIB_DEBUG} + +{$IFDEF ZLIB_DEBUG} + {$ASSERTIONS ON} +{$ENDIF} diff --git a/packages/paszlib/src/zdeflate.pas b/packages/paszlib/src/zdeflate.pas index 66e3f978a2..3e984a9a51 100644 --- a/packages/paszlib/src/zdeflate.pas +++ b/packages/paszlib/src/zdeflate.pas @@ -1502,6 +1502,27 @@ end; {$endif} { FASTEST } {$ifdef ZLIB_DEBUG} +function zmemcmp(s1p, s2p : PByte; len : Cardinal) : Integer; +var + j : Cardinal; + source, + dest : PByte; +begin + source := s1p; + dest := s2p; + for j := 0 to pred(len) do + begin + if (source^ <> dest^) then + begin + zmemcmp := 2*Ord(source^ > dest^)-1; + exit; + end; + Inc(source); + Inc(dest); + end; + zmemcmp := 0; +end; + { =========================================================================== Check that the match at match_start is indeed a match. }