From: eH
To: physfs@icculus.org
Subject: [physfs] lzma.c msvc, etc. patch
I came across a few bugs compiling PhysFS with msvc9 - I've created a patch which seems to fix them:
SzFileReadImp / SzFileSeekImp:
Problem: Can't preform arithmatic on 'void *'
Fix: Cast 'object' to unsigned long
LZMA_enumerateFiles:
Problem: There is no error handling if the directory 'dname' doesn't exist
Fix: Check the return value of 'lzma_find_file()' before using it
LZMA_isDirectory:
Problem: return (file->item->IsDirectory) is illegal if 'file' doesn't exist
Fix: Make sure 'file' isn't null before returning
only enumerated their files when looking in a directory other than the root,
instead of enumerating only for the root. Thanks to Chris Taylor for the
catch.
versions of the OS, and fallback to "ANSI" versions for 95/98/ME,
tapdancing around the system codepage if it has to. Other minor Windows
cleanups and corrections.
which will stack allocate small (128 or less bytes) blocks and Malloc the
rest...naturally these now have to be paired with __PHYSFS_smallFree() calls,
so you can't be as lazy as a basic alloca() would let you be. The benefit is
both less malloc pressure for those temporary allocations and better stack
overflow safety (so if some jerk tries to push a 78 megabyte string through
the library as a filename, we won't try to strcpy it to the stack).
platform-specific stricmp implementations, changed appropriate calls to an
ASCII-only stricmp that ignores locale. Fixed case on UTF-8 API entry points.
#ifdefs...this will make it easier to "embed" this library in other projects
or use a different build system: just push everything through the compiler
with preprocessor defines for the parts you want/need...platform modules are
determined automatically without the build system needing to intervene, so
you just have to #define the archivers, etc that you want.