Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added internal function __PHYSFS_platformStrnicmp().
  • Loading branch information
icculus committed Nov 9, 2003
1 parent 13d6a13 commit 09ef260
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
5 changes: 5 additions & 0 deletions physfs_internal.h
Expand Up @@ -1313,6 +1313,11 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void);
*/
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
Expand Down
7 changes: 7 additions & 0 deletions platform/macclassic.c
Expand Up @@ -350,6 +350,13 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
} /* __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;
Expand Down
24 changes: 24 additions & 0 deletions platform/os2.c
Expand Up @@ -340,6 +340,30 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
} /* __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;
Expand Down
7 changes: 6 additions & 1 deletion platform/pocketpc.c
Expand Up @@ -211,10 +211,15 @@ PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
int __PHYSFS_platformStricmp(const char *x, const char *y)
{
return(_stricmp(x, y));

} /* __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)
{
int retval=0;
Expand Down
22 changes: 22 additions & 0 deletions platform/posix.c
Expand Up @@ -141,6 +141,28 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
} /* __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
Expand Down
6 changes: 6 additions & 0 deletions platform/skeleton.c
Expand Up @@ -68,6 +68,12 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
} /* __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);
Expand Down
28 changes: 28 additions & 0 deletions platform/win32.c
Expand Up @@ -368,6 +368,34 @@ int __PHYSFS_platformStricmp(const char *x, const char *y)
} /* __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,
Expand Down

0 comments on commit 09ef260

Please sign in to comment.