Added internal function __PHYSFS_platformStrnicmp().
authorRyan C. Gordon <icculus@icculus.org>
Sun, 09 Nov 2003 20:59:07 +0000
changeset 596 381b6ca0dd85
parent 595 67aff4091bf1
child 597 e84664806f86
Added internal function __PHYSFS_platformStrnicmp().
physfs_internal.h
platform/macclassic.c
platform/os2.c
platform/pocketpc.c
platform/posix.c
platform/skeleton.c
platform/win32.c
--- a/physfs_internal.h	Sat Sep 13 02:30:55 2003 +0000
+++ b/physfs_internal.h	Sun Nov 09 20:59:07 2003 +0000
@@ -1314,6 +1314,11 @@
 int __PHYSFS_platformStricmp(const char *str1, const char *str2);
 
 /*
+ * This is a pass-through to whatever strnicmp() is called on your platform.
+ */
+int __PHYSFS_platformStrnicmp(const char *s1, const char *s2, PHYSFS_uint32 l);
+
+/*
  * Return non-zero if filename (in platform-dependent notation) exists.
  *  Symlinks should NOT be followed; at this stage, we do not care what the
  *  symlink points to. Please call __PHYSFS_SetError() with the details of
--- a/platform/macclassic.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/macclassic.c	Sun Nov 09 20:59:07 2003 +0000
@@ -350,6 +350,13 @@
 } /* __PHYSFS_platformStricmp */
 
 
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 l)
+{
+    extern int _strnicmp(const char *, const char *, int);
+    return(_strnicmp(x, y, (int) l));  /* (*shrug*) */
+} /* __PHYSFS_platformStricmp */
+
+
 static OSErr fnameToFSSpecNoAlias(const char *fname, FSSpec *spec)
 {
     OSErr err;
--- a/platform/os2.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/os2.c	Sun Nov 09 20:59:07 2003 +0000
@@ -340,6 +340,30 @@
 } /* __PHYSFS_platformStricmp */
 
 
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 len)
+{
+    int ux, uy;
+
+    if (!len)
+        return(0);
+
+    do
+    {
+        ux = toupper((int) *x);
+        uy = toupper((int) *y);
+        if (ux > uy)
+            return(1);
+        else if (ux < uy)
+            return(-1);
+        x++;
+        y++;
+        len--;
+    } while ((ux) && (uy) && (len));
+
+    return(0);
+} /* __PHYSFS_platformStrnicmp */
+
+
 int __PHYSFS_platformExists(const char *fname)
 {
     FILESTATUS3 fs;
--- a/platform/pocketpc.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/pocketpc.c	Sun Nov 09 20:59:07 2003 +0000
@@ -211,8 +211,13 @@
 int __PHYSFS_platformStricmp(const char *x, const char *y)
 {    
     return(_stricmp(x, y));
+} /* __PHYSFS_platformStricmp */
 
-} /* __PHYSFS_platformStricmp */
+
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 len)
+{    
+    return(_strnicmp(x, y, (int) len));
+} /* __PHYSFS_platformStrnicmp */
 
 
 int __PHYSFS_platformExists(const char *fname)
--- a/platform/posix.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/posix.c	Sun Nov 09 20:59:07 2003 +0000
@@ -141,6 +141,28 @@
 } /* __PHYSFS_platformStricmp */
 
 
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 len)
+{
+    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 */
+
+
 #if (defined __PHYSFS_NO_SYMLINKS__)
 #define doStat stat
 #else
--- a/platform/skeleton.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/skeleton.c	Sun Nov 09 20:59:07 2003 +0000
@@ -68,6 +68,12 @@
 } /* __PHYSFS_platformStricmp */
 
 
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 l)
+{
+    BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
+} /* __PHYSFS_platformStrnicmp */
+
+
 int __PHYSFS_platformExists(const char *fname)
 {
     BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
--- a/platform/win32.c	Sat Sep 13 02:30:55 2003 +0000
+++ b/platform/win32.c	Sun Nov 09 20:59:07 2003 +0000
@@ -368,6 +368,34 @@
 } /* __PHYSFS_platformStricmp */
 
 
+int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 len)
+{
+#if (defined _MSC_VER)
+    return(strnicmp(x, y, (int) len));
+#else
+    int ux, uy;
+
+    if (!len)
+        return(0);
+
+    do
+    {
+        ux = toupper((int) *x);
+        uy = toupper((int) *y);
+        if (ux > uy)
+            return(1);
+        else if (ux < uy)
+            return(-1);
+        x++;
+        y++;
+        len--;
+    } while ((ux) && (uy) && (len));
+
+    return(0);
+#endif
+} /* __PHYSFS_platformStricmp */
+
+
 int __PHYSFS_platformExists(const char *fname)
 {
     BAIL_IF_MACRO(GetFileAttributes(fname) == INVALID_FILE_ATTRIBUTES,