[linux-port] Add definition of strnicmp for Linux. (#1567)

Usage of strnicmp was recently added to the code base, and causes the
Linux builds to fail. This should fix it.
This commit is contained in:
Ehsan 2018-09-25 17:24:59 -04:00 коммит произвёл GitHub
Родитель d36eb1731c
Коммит d0008e6a41
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -172,6 +172,7 @@
#define _atoi64 atoll
#define sprintf_s snprintf
#define _strdup strdup
#define _strnicmp strnicmp
#define vsprintf_s vsprintf
#define strcat_s strcat

Просмотреть файл

@ -26,6 +26,8 @@ HRESULT UIntAdd(UINT uAugend, UINT uAddend, UINT *puResult);
HRESULT IntToUInt(int in, UINT *out);
HRESULT SizeTToInt(size_t in, INT *out);
HRESULT UInt32Mult(UINT a, UINT b, UINT *out);
int strnicmp(const char *str1, const char *str2, size_t count);
int _stricmp(const char *str1, const char *str2);
int _wcsicmp(const wchar_t *str1, const wchar_t *str2);
int _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n);

Просмотреть файл

@ -98,6 +98,23 @@ HRESULT UInt32Mult(UINT a, UINT b, UINT *out) {
return S_OK;
}
int strnicmp(const char *str1, const char *str2, size_t count) {
size_t i = 0;
for (; i < count && str1[i] && str2[i]; ++i) {
int d = std::tolower(str1[i]) - std::tolower(str2[i]);
if (d != 0)
return d;
}
if (i == count) {
// All 'count' characters matched.
return 0;
}
// str1 or str2 reached NULL before 'count' characters were compared.
return str1[i] - str2[i];
}
int _stricmp(const char *str1, const char *str2) {
size_t i = 0;
for (; str1[i] && str2[i]; ++i) {

Просмотреть файл

@ -11,6 +11,7 @@
#include "dxc/HLSL/DxilModule.h"
#include "dxc/HLSL/HLModule.h"
#include "dxc/Support/Global.h"
#include "dxc/Support/WinFunctions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/LLVMContext.h"