[Zlib-devel] zlib gzopen_w function added

Cosmin Truta cosmin at cs.toronto.edu
Sun Mar 18 01:48:07 EDT 2012


On Sun, Mar 18, 2012 at 12:45 AM, Mark Adler <madler at madler.net> wrote:
> On Mar 17, 2012, at 9:29 PM, Cosmin Truta wrote:
>> I just tested it, and it failed. You used w_char instead of wchar_t.
>
> Hah, right, I knew that.  Brain fart.  Ok, please try the latest update.  Thanks.

Hi, Mark,

I tested it, and you still forgot to #include <stddef.h> or <wchar.h>

Although I said earlier that the standard C library generally has
wchar_t equivalents for functions handling char*, I just remembered
that they are missing for paths. The closest thing that you can get to
is _wfopen_s, and even if you wanted to emulate that, if you look at
the leading underscore, is non-standard, just as _wopen is. And BTW,
that requires both the filename and the mode to be const wchar_t*.
http://msdn.microsoft.com/en-us/library/z5hh6ee9(v=vs.80).aspx

I agree with Bill Rowe: I suggest to remove this completely, or at
least defer it for a future zlib version dedicated for this kind of
work, because you might open a large can of worms otherwise. Moreover,
losing the safety of the gz_open argument type (i.e. replacing const
char* with const void*) in gz_open is yet another change that I see as
a downside; e.g. I see that you're calling strlen on something that
could be wchar_t* instead of char*, and if that's true, it's a bug. I
didn't look carefully into it if this one to make sure it is as I
describe it, I'm just saying that this kind of change opens the door
to hard-to-find errors.

Sincerely,
Cosmin




More information about the Zlib-devel mailing list