Menu

#14 zip 3.0f beta Win32 unicode doesn't match file names

open
nobody
None
5
2007-10-11
2007-10-11
Willus
No

I compiled zip30f with MinGW/gcc 3.4.0 using the INSTALL instructions (make -f win32/makefile.gcc). All exe's were built without a hitch, but my very first test:

zip myarch.zip *.iso

failed to match the name (name not matched: *.iso) even though I had several .iso files in the folder. I tracked it down to the part of the win32zip.c wild_recurse() function which then was converting the arguments to unicode and calling wild_recursew(), which failed to find any matches. I've temporarily gotten around this by disabling unicode support (-DNO_UNICODE_SUPPORT) when building zip.

Discussion

  • Ed Gordon

    Ed Gordon - 2007-10-14

    Logged In: YES
    user_id=1172496
    Originator: NO

    The solution for now may be to disable Unicode by default for MinGW until a fix is available. I know I'm not familiar with how MinGW supports doing searches for wide-character paths so hopefully someone else can provide some help with that, though in theory MinGW seems to call the native Windows libraries so it should be possible to support wide-character paths.

     
  • Willus

    Willus - 2007-10-30

    Logged In: YES
    user_id=681780
    Originator: YES

    It appears that the problem with name matching is that the "wildtail" pointer passed to wild_recursew() is expected to be indexed off of the "whole" pointer. Making the modification listed below to the code in the wild() function in win32/win32zip.c which assigns pw and qw seems to do the trick, but this has now caused a new problem to be revealed where the readlocal() function is causing the contents of the tempzip pointer to get overwritten. E.g. before the call to readlocal(), tempzip="zia00704", and after, it is changed to the name of the target archive. I'm working on that one...

    wild()

    {
    ...
    /* use wide Unicode directory scan */
    wchar_t *pw = local_to_wchar_string(p);
    wchar_t *qw;
    int qindex;
    qindex=q-p;
    if (qindex>=0 && qindex<=strlen(p))
    qw = &pw[qindex];
    else
    qw = local_to_wchar_string(q);

    e = wild_recursew(pw, qw);
    ...
    }

     
  • Willus

    Willus - 2007-10-30

    Logged In: YES
    user_id=681780
    Originator: YES

    Found the problem. I was calling free(qw) even when I didn't malloc it. Here's a replacement for the fix from my last post, again replacing the end of the wild() function in win32/win32zip.c.

    wild()
    {
    ...
    /* Here we go */
    #ifdef UNICODE_SUPPORT
    if (no_win32_wide) {
    /* use multibyte directory scan */
    e = wild_recurse(p, q);
    } else {
    /* use wide Unicode directory scan */
    wchar_t *pw = local_to_wchar_string(p);
    wchar_t *qw;
    int qindex,fq;
    qindex=q-p;
    if (qindex>=0 && qindex<=strlen(p))
    {
    fq = 0;
    qw = &pw[qindex];
    }
    else
    {
    fq = 1;
    qw = local_to_wchar_string(q);
    }

    e = wild_recursew(pw, qw);

    if (fq && qw) free(qw);
    if (pw) free(pw);
    }
    #else
    e = wild_recurse(p, q);
    #endif
    free((zvoid *)p);
    return e;
    }

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.