#1 2016-01-11 14:40:58

adem
Member
Registered: 2012-08-13
Posts: 8

PasZip upgraded from v1.5 to v1.18 doesn't work

A little background:

I am working on 'NHunspell for Delphi' [ http://sourceforge.net/projects/nhunspelldelphi/ ] which uses PasZip v1.5.

As it is, it is a 32-bit code. In order to make it 64bit, other than using a 64bit Hunspell DLL, it needs PasZip that's 64bit compatible.

Now the problem:

When I replace PasZip v1.5 with v1.18 (the one available from GitHub MorMot), 'NHunspell for Delphi' compiles but it simply and silently fdoes not unzip anything --even for 32bit.

I couln't figure out what has changed between the versions (other than that the new one is 64bit compatible).

Could someone shed some light here --is there a compiler define I need to enable with the newer one, for example.

Offline

#2 2016-01-11 14:42:10

adem
Member
Registered: 2012-08-13
Posts: 8

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

I forgot: I am using XE2.

Offline

#3 2016-01-11 20:42:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

I can't see why http://synopse.info/fossil/info/032fb0c … f9ef7e42d0 would have changed the unit behavior...

As far as I can tell, there was no code change in the last 5 years...
See the whole history at http://synopse.info/fossil/finfo?name=PasZip.pas

Offline

#4 2016-01-12 12:14:07

adem
Member
Registered: 2012-08-13
Posts: 8

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

I have solved the mistery smile

In PasZip.pas:

NameToIndex() is declared as this:

    function NameToIndex(const aName: AnsiString): integer;

but, is implemented as

function TZipRead.NameToIndex(const aName: string): integer;

Notice that 'AnsiString' has been replaced with 'string'.

It should, instead, be implemented as this:

function TZipRead.NameToIndex(const aName: AnsiString): integer;

---------------------

Another one is this:

    function UnZip(aIndex: integer): string; overload;

It should return 'AnsiString' instead of 'string'

IOW, it should be corrected to be:

    function UnZip(aIndex: integer): AnsiString; overload;

And, its implementation should be like this

function TZipRead.UnZip(aIndex: integer): AnsiString;
{snip}
begin
{snip}
      MessageBoxA(0,'CRC',Name,0);
{snip}
end;

---------------------

And, a little nitpick:

in 'function InflateFast()', there's this code. In there 'inc(R, Extra)' is redundant because 3 lines down, 'R' is assigned a value. See below.

              if C > Extra then begin
                // copy to end of window
                dec(C, Extra);
                MoveWithOverlap(R, Q, Extra);
                inc(R, Extra); { <--- REDUNDAT}
                inc(Q, Extra);
                // copy rest from start of window
                R := S.window;
              end;

---------------------

As you see, my focus has been on the unzipping side of things; I haven't looked ad zipping side of things at all.

But, having found the above AnsiString/string issues, I have become suspicious of routines such as 'function Zip()' as they seem to use 'string' a little too liberally.

But, I haven't checked them.

Offline

#5 2016-01-12 12:26:03

adem
Member
Registered: 2012-08-13
Posts: 8

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

And, now, in order to compile PasZip under x64, the following changes need to be made in the code:

in UpdateCrc32()

    inc(cardinal(inBuf));
should be:
    inc(IntPtr(inBuf));

in CompressString()

    i1 := {snip} PAnsiChar(integer(Result) + 12) {snip};
should be:
    i1 := {snip} PAnsiChar(IntPtr(Result) + 12) {snip};


UncompressString()

    SetLength( {snip} PAnsiChar(integer(data) {snip} );
should be:
    SetLength( {snip} PAnsiChar(IntPtr(data) {snip} );


constructor TZipRead.Create();

      inc(integer(H),  {snip} );
should be:
      inc(IntPtr(H),  {snip} );

Offline

#6 2016-01-12 21:33:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

In fact, PasZip NEVER worked with Unicode versions of Delphi.

So I made a deep refactoring of the unit.
So that it now compiles and run under Win32 and Win64, with all supported Delphi and FPC compiler versions!
smile

See http://synopse.info/fossil/info/a6aa94cb37

Offline

#7 2016-01-13 05:35:28

adem
Member
Registered: 2012-08-13
Posts: 8

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

Thank you.

Just a reminder: It would be a good idea to change the version number --it still says 1.18

Another thing:

We don't need to pull in Synopse.inc just to define 'MSWINDOWS'.

The following is all we need instead of Synopse.inc

{$IFDEF WIN32}
  {$DEFINE MSWINDOWS}
{$ELSE}
  {$IFDEF WIN64}
    {$DEFINE MSWINDOWS}
  {$ELSE}
    {$UNDEF MSWINDOWS}
  {$ENDIF}
{$ENDIF}

Offline

#8 2016-01-13 08:07:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: PasZip upgraded from v1.5 to v1.18 doesn't work

It is currently 1.18.2249.

Synopse.inc is a very small dependency, which does not change anything about exe size or compilation time, and keep all source code consistent.

Offline

Board footer

Powered by FluxBB