Skip to content

Commit e091168

Browse files
committed
fix casecmp defines and uniformly use casecmp in code:
str[n]casecmp used to be brokenly defined as str[n]cmp. even strnicmp ended up being defined as strcmp. should be fixed now.
1 parent 58ac0eb commit e091168

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/libmodplug/stdafx.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@
4646

4747
inline void ProcessPlugins(int n) {}
4848

49-
#define strncasecmp(a,b,c) strncmp(a,b,c)
50-
#define strcasecmp(a,b) strcmp(a,b)
51-
#define strnicmp(a,b,c) strncasecmp(a,b,c)
49+
#undef strcasecmp
50+
#undef strncasecmp
51+
#undef stricmp
52+
#undef strnicmp
53+
#define strcasecmp(a,b) _stricmp(a,b)
54+
#define strncasecmp(a,b,c) _strnicmp(a,b,c)
55+
#define stricmp(a,b) _stricmp(a,b)
56+
#define strnicmp(a,b,c) _strnicmp(a,b,c)
5257
#define HAVE_SINF 1
5358

5459
#ifndef isblank
@@ -96,10 +101,12 @@ inline LONG MulDiv (long a, long b, long c)
96101
#define lstrcpyn strncpy
97102
#define lstrcpy strcpy
98103
#define lstrcmp strcmp
104+
#define wsprintf sprintf
105+
99106
#define WAVE_FORMAT_PCM 1
100107

101108
#define GHND 0
102-
109+
#define GlobalFreePtr(p) free((void *)(p))
103110
inline int8_t * GlobalAllocPtr(unsigned int, size_t size)
104111
{
105112
int8_t * p = (int8_t *) malloc(size);
@@ -110,11 +117,6 @@ inline int8_t * GlobalAllocPtr(unsigned int, size_t size)
110117

111118
inline void ProcessPlugins(int n) {}
112119

113-
#define GlobalFreePtr(p) free((void *)(p))
114-
115-
#define strnicmp(a,b,c) strncasecmp(a,b,c)
116-
#define wsprintfsprintf
117-
118120
#ifndef FALSE
119121
#define FALSEfalse
120122
#endif

src/load_mod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ BOOL CSoundFile::ReadMod(const BYTE *lpStream, DWORD dwMemLength)
341341
LPSTR p = (LPSTR)(lpStream+dwMemPos);
342342
UINT flags = 0;
343343
if (dwMemPos + 5 >= dwMemLength) break;
344-
if (!strnicmp(p, "ADPCM", 5))
344+
if (!strncasecmp(p, "ADPCM", 5))
345345
{
346346
flags = 3;
347347
p += 5;

src/load_stm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ BOOL CSoundFile::ReadSTM(const BYTE *lpStream, DWORD dwMemLength)
6464

6565
if ((!lpStream) || (dwMemLength < sizeof(STMHEADER))) return FALSE;
6666
if ((phdr->filetype != 2) || (phdr->unused != 0x1A)
67-
|| ((strnicmp(phdr->trackername, "!SCREAM!", 8))
68-
&& (strnicmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
67+
|| ((strncasecmp(phdr->trackername, "!SCREAM!", 8))
68+
&& (strncasecmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
6969
memcpy(m_szNames[0], phdr->songname, 20);
7070
// Read STM header
7171
m_nType = MOD_TYPE_STM;

src/load_xm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ BOOL CSoundFile::ReadXM(const BYTE *lpStream, DWORD dwMemLength)
8989

9090
m_nChannels = 0;
9191
if ((!lpStream) || (dwMemLength < 0x200)) return FALSE;
92-
if (strnicmp((LPCSTR)lpStream, "Extended Module", 15)) return FALSE;
92+
if (strncasecmp((LPCSTR)lpStream, "Extended Module", 15)) return FALSE;
9393

9494
memcpy(m_szNames[0], lpStream+17, 20);
9595
xmhead = *(tagXMFILEHEADER *)(lpStream+60);

0 commit comments

Comments
 (0)