Browse Source

Patches to get this building on Mac Classic again.

Ryan C. Gordon 22 years ago
parent
commit
24c8651f7f
3 changed files with 40 additions and 13 deletions
  1. 6 6
      archivers/hog.c
  2. 1 1
      archivers/wad.c
  3. 33 6
      platform/macclassic.c

+ 6 - 6
archivers/hog.c

@@ -249,10 +249,10 @@ static int hog_open(const char *filename, int forWriting,
         goto openHog_failed;
     } /* if */
 
-    while( 1 )
+    while (1)
     {
         if (__PHYSFS_platformRead(*fh, buf, 13, 1) != 1)
-            break;             //eof here is ok
+            break; /* eof here is ok */
 
         if (__PHYSFS_platformRead(*fh, &size, 4, 1) != 1)
             goto openHog_failed;
@@ -261,15 +261,15 @@ static int hog_open(const char *filename, int forWriting,
 
         (*count)++;
 
-        // Skip over entry
+        /* Skip over entry... */
         pos = __PHYSFS_platformTell(*fh);
         if (pos == -1)
             goto openHog_failed;
         if (!__PHYSFS_platformSeek(*fh, pos + size))
             goto openHog_failed;
-    }
+    } /* while */
 
-    // Rewind to start of entries
+    /* Rewind to start of entries... */
     if (!__PHYSFS_platformSeek(*fh, 3))
         goto openHog_failed;
 
@@ -353,7 +353,7 @@ static int hog_load_entries(const char *name, int forWriting, HOGinfo *info)
             return(0);
         }
 
-        // Skip over entry
+        /* Skip over entry */
         if (!__PHYSFS_platformSeek(fh, entry->startPos + entry->size))
         {
             __PHYSFS_platformClose(fh);

+ 1 - 1
archivers/wad.c

@@ -309,7 +309,7 @@ static int wad_load_entries(const char *name, int forWriting, WADinfo *info)
     PHYSFS_uint32 fileCount;
     PHYSFS_uint32 directoryOffset;
     WADentry *entry;
-    char lastDirectory[9],buffer[9];
+    char lastDirectory[9];
 
     lastDirectory[8] = 0; /* Make sure lastDirectory stays null-terminated. */
 

+ 33 - 6
platform/macclassic.c

@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <alloca.h>
 
 /*
@@ -345,16 +346,42 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
 
 int __PHYSFS_platformStricmp(const char *x, const char *y)
 {
-    extern int _stricmp(const char *, const char *);
-    return(_stricmp(x, y));  /* (*shrug*) */
+    int ux, uy;
+
+    do
+    {
+        ux = toupper((int) *x);
+        uy = toupper((int) *y);
+        if (ux != uy)
+            return((ux > uy) ? 1 : -1);
+        x++;
+        y++;
+    } while ((ux) && (uy));
+
+    return(0);
 } /* __PHYSFS_platformStricmp */
 
 
-int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 l)
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 len)
 {
-    extern int _strnicmp(const char *, const char *, int);
-    return(_strnicmp(x, y, (int) l));  /* (*shrug*) */
-} /* __PHYSFS_platformStricmp */
+    int ux, uy;
+
+    if (!len)
+        return(0);
+
+    do
+    {
+        ux = toupper((int) *x);
+        uy = toupper((int) *y);
+        if (ux != uy)
+            return((ux > uy) ? 1 : -1);
+        x++;
+        y++;
+        len--;
+    } while ((ux) && (uy) && (len));
+
+    return(0);
+} /* __PHYSFS_platformStrnicmp */
 
 
 static OSErr fnameToFSSpecNoAlias(const char *fname, FSSpec *spec)