gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

provide a workaround for missing strnlen #25 #28

Closed mojca closed 6 years ago

mojca commented 6 years ago

The strnlen function is only defined in POSIX.1-2008. It is missing on Solaris 10 or Mac OS X 10.6 for example.

gdraheim commented 6 years ago

I have read up about and it seems to be supported even on Windows (atleast back to MSVC6). There are hints that malloc(3) might be defined in but commentators do point out that it is a non-standard location with a possibly non-standard declaration.

I'll not roll a release by tomorrow - but the patch looks great with a real autoconf check being added. All further enhancement should be based on it. Thanks a lot!

mojca commented 6 years ago

Thanks for the quick patch.

To criticise my own patch, here's a bunch of warnings (along with a few unrelated ones)

../../zziplib/zzip/__string.h: In function `_zzip_strnlen':
../../zziplib/zzip/__string.h:26: warning: signed and unsigned type in conditional expression
../../zziplib/zzip/__string.h: In function `_zzip_strndup':
../../zziplib/zzip/__string.h:41: warning: return discards qualifiers from pointer target type

../../zziplib/zzip/mmapped.c: In function `zzip_disk_findfirst':
../../zziplib/zzip/mmapped.c:447: warning: ISO C90 forbids mixed declarations and code

../../zziplib/zzip/memdisk.c: In function `zzip_mem_disk_fdopen':
../../zziplib/zzip/memdisk.c:112: warning: format argument is not a pointer (arg 4)
../../zziplib/zzip/memdisk.c: In function `zzip_mem_entry_new':
../../zziplib/zzip/memdisk.c:240: warning: comparison of distinct pointer types lacks a cast
../../zziplib/zzip/memdisk.c:254: warning: comparison of distinct pointer types lacks a cast
../../zziplib/zzip/memdisk.c: In function `zzip_mem_entry_find_extra_block':
../../zziplib/zzip/memdisk.c:330: warning: comparison between signed and unsigned

../../zziplib/bins/unzzipcat-big.c: In function `unzzip_cat':
../../zziplib/bins/unzzipcat-big.c:109: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type
../../zziplib/bins/unzzipcat-big.c:142: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type

../../zziplib/bins/unzzipcat-zip.c:127: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type
../../zziplib/bins/unzzipcat-zip.c:149: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type

../../zziplib/bins/unzzipcat-mix.c: In function `unzzip_cat':
../../zziplib/bins/unzzipcat-mix.c:127: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type
../../zziplib/bins/unzzipcat-mix.c:158: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type

../../zziplib/bins/unzzipcat-mem.c:117: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type
../../zziplib/bins/unzzipcat-mem.c:149: warning: passing arg 2 of `create_fopen' discards qualifiers from pointer target type
../../zziplib/bins/unzzipcat-mem.c:92: warning: 'done' might be used uninitialized in this function

../../zziplib/bins/unzzip.c: In function `main':
../../zziplib/bins/unzzip.c:38: warning: unused variable `argn'
../../zziplib/bins/unzzip.c:39: warning: unused variable `exitcode'
../../zziplib/bins/unzzip.c:40: warning: unused variable `error'

../../zziplib/bins/zzip.c: In function `main':
../../zziplib/bins/zzip.c:32: warning: unused variable `argn'
../../zziplib/bins/zzip.c:33: warning: unused variable `exitcode'
../../zziplib/bins/zzip.c:34: warning: unused variable `dir'

cp ../../zziplib/docs/zziplib-manpages.tar manpages.tar
cp: cannot access ../../zziplib/docs/zziplib-manpages.tar
*** Error code 2