Patches for correctness and cleaner win32 support.
--- a/Makefile Mon Apr 08 13:35:29 2002 +0000
+++ b/Makefile Fri Apr 12 05:53:12 2002 +0000
@@ -175,9 +175,9 @@
CFLAGS += -DPHYSFS_SUPPORTS_ZIP
LDFLAGS += -lz
ifeq ($(strip $(cygwin)),true)
- EXTRABUILD += zlibwin32/zlib.a
- CFLAGS += -Izlibwin32
- LDFLAGS += -Lzlibwin32
+ EXTRABUILD += zlib114/zlib114.a
+ CFLAGS += -Izlib114
+ LDFLAGS += -Lzlib114
endif
endif
@@ -264,8 +264,8 @@
ifeq ($(strip $(cygwin)),true)
-zlibwin32/zlib.a:
- cd zlibwin32 ; $(MAKE) CC=$(CC)
+zlib114/zlib114.a:
+ cd zlib114 ; $(MAKE) CC=$(CC)
endif
@@ -275,7 +275,7 @@
rm -f $(CLEANUP)
rm -rf $(BINDIR)
ifeq ($(strip $(cygwin)),true)
- cd zlibwin32 ; $(MAKE) clean
+ cd zlib114 ; $(MAKE) clean
endif
listobjs:
--- a/archivers/grp.c Mon Apr 08 13:35:29 2002 +0000
+++ b/archivers/grp.c Fri Apr 12 05:53:12 2002 +0000
@@ -133,7 +133,7 @@
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
if (objsLeft < objCount)
- objCount = objsLeft;
+ objCount = (PHYSFS_uint32) objsLeft;
return(__PHYSFS_platformRead(fh, buffer, objSize, objCount));
} /* GRP_read */
@@ -143,7 +143,9 @@
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
void *fh = finfo->handle;
- return(__PHYSFS_platformTell(fh) >= finfo->startPos + finfo->size);
+ PHYSFS_sint64 pos = __PHYSFS_platformTell(fh);
+ BAIL_IF_MACRO(pos < 0, NULL, 1); /* (*shrug*) */
+ return(pos >= (PHYSFS_sint64) (finfo->startPos + finfo->size));
} /* GRP_eof */
--- a/archivers/zip.c Mon Apr 08 13:35:29 2002 +0000
+++ b/archivers/zip.c Fri Apr 12 05:53:12 2002 +0000
@@ -153,7 +153,7 @@
PHYSFS_uint32 bufsize = 4096 * 2;
BAIL_IF_MACRO(unztell(fh) == offset, NULL, 1);
- BAIL_IF_MACRO(ZIP_fileLength(handle) <= offset, ERR_PAST_EOF, 0);
+ BAIL_IF_MACRO(ZIP_fileLength(handle) <= (PHYSFS_sint64) offset, ERR_PAST_EOF, 0);
/* reset to the start of the zipfile. */
unzCloseCurrentFile(fh);
--- a/physfs.h Mon Apr 08 13:35:29 2002 +0000
+++ b/physfs.h Fri Apr 12 05:53:12 2002 +0000
@@ -129,10 +129,6 @@
#ifndef _INCLUDE_PHYSFS_H_
#define _INCLUDE_PHYSFS_H_
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -143,8 +139,6 @@
#define __EXPORT__
#endif
-
-/* !!! FIXME: This is not universal. */
typedef unsigned char PHYSFS_uint8;
typedef signed char PHYSFS_sint8;
typedef unsigned short PHYSFS_uint16;
@@ -152,13 +146,12 @@
typedef unsigned int PHYSFS_uint32;
typedef signed int PHYSFS_sint32;
-#ifdef PHYSFS_NO_64BIT_SUPPORT /* oh well. */
+#if (defined PHYSFS_NO_64BIT_SUPPORT) /* oh well. */
typedef PHYSFS_uint32 PHYSFS_uint64;
typedef PHYSFS_sint32 PHYSFS_sint64;
-#elif _WIN32
-/*!!! No 64-bit unsigned in Win32???? */
-typedef LONGLONG PHYSFS_sint64;
-typedef LONGLONG PHYSFS_uint64;
+#elif (defined _MSC_VER)
+typedef signed __int64 PHYSFS_sint64;
+typedef unsigned __int64 PHYSFS_uint64;
#else
typedef unsigned long long PHYSFS_uint64;
typedef signed long long PHYSFS_sint64;
--- a/physfs_byteorder.c Mon Apr 08 13:35:29 2002 +0000
+++ b/physfs_byteorder.c Fri Apr 12 05:53:12 2002 +0000
@@ -40,22 +40,26 @@
#define PHYSFS_Swap32 __arch__swab32
#endif
#endif /* linux */
-
+
+#if (defined _MSC_VER)
+#define inline __inline
+#endif
+
#ifndef PHYSFS_Swap16
-static __inline__ PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
+static inline PHYSFS_uint16 PHYSFS_Swap16(PHYSFS_uint16 D)
{
return((D<<8)|(D>>8));
}
#endif
#ifndef PHYSFS_Swap32
-static __inline__ PHYSFS_uint32 PHYSFS_Swap32(PHYSFS_uint32 D)
+static inline PHYSFS_uint32 PHYSFS_Swap32(PHYSFS_uint32 D)
{
return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
}
#endif
#ifndef PHYSFS_NO_64BIT_SUPPORT
#ifndef PHYSFS_Swap64
-static __inline__ PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
+static inline PHYSFS_uint64 PHYSFS_Swap64(PHYSFS_uint64 val) {
PHYSFS_uint32 hi, lo;
/* Separate into high and low 32-bit values and swap them */
--- a/platform/win32.c Mon Apr 08 13:35:29 2002 +0000
+++ b/platform/win32.c Fri Apr 12 05:53:12 2002 +0000
@@ -184,6 +184,9 @@
/* ...make this Cygwin AND Visual C friendly... */
int __PHYSFS_platformStricmp(const char *x, const char *y)
{
+#if (defined _MSC_VER)
+ return(stricmp(x, y));
+#else
int ux, uy;
do
@@ -199,6 +202,7 @@
} while ((ux) && (uy));
return(0);
+#endif
} /* __PHYSFS_platformStricmp */
@@ -469,9 +473,6 @@
/*!!! Second parameter can't be NULL or the function fails??? */
if(!GetUserProfileDirectory(AccessTokenHandle, TempProfileDirectory, &pathsize))
{
- const char *temp;
- temp = win32strerror();
-
/* Allocate memory for the profile directory */
ProfileDirectory = (char *)malloc(pathsize);
BAIL_IF_MACRO(ProfileDirectory == NULL, ERR_OUT_OF_MEMORY, 0);