Remove the last uses of the system's str[n]casecmp

master
Chris Robinson 2019-09-16 15:10:36 -07:00
parent 6d93b2ba81
commit 899a414591
7 changed files with 36 additions and 48 deletions

View File

@ -473,26 +473,6 @@ CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(NOT HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
IF(NOT HAVE__STRICMP)
MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
ENDIF()
SET(CPP_DEFS ${CPP_DEFS} strcasecmp=_stricmp)
ENDIF()
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
IF(NOT HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
IF(NOT HAVE__STRNICMP)
MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
ENDIF()
SET(CPP_DEFS ${CPP_DEFS} strncasecmp=_strnicmp)
ENDIF()
IF(NOT WIN32)
# We need pthreads outside of Windows, for semaphores. It's also used to

View File

@ -43,6 +43,7 @@
#include "alexcpt.h"
#include "almalloc.h"
#include "alnumeric.h"
#include "alstring.h"
#include "effects/base.h"
#include "logging.h"
#include "opthelpers.h"
@ -668,7 +669,7 @@ static const struct {
void LoadReverbPreset(const char *name, ALeffect *effect)
{
if(strcasecmp(name, "NONE") == 0)
if(al::strcasecmp(name, "NONE") == 0)
{
InitEffectParams(effect, AL_EFFECT_NULL);
TRACE("Loading reverb '%s'\n", "NONE");
@ -685,7 +686,7 @@ void LoadReverbPreset(const char *name, ALeffect *effect)
{
const EFXEAXREVERBPROPERTIES *props;
if(strcasecmp(name, reverbitem.name) != 0)
if(al::strcasecmp(name, reverbitem.name) != 0)
continue;
TRACE("Loading reverb '%s'\n", reverbitem.name);

View File

@ -46,6 +46,7 @@
#include <algorithm>
#include "alcmain.h"
#include "alstring.h"
#include "logging.h"
#include "strutils.h"
#include "compat.h"
@ -169,7 +170,7 @@ void LoadConfigFromFile(std::istream &f)
*endsection = 0;
curSection.clear();
if(strcasecmp(section, "general") != 0)
if(al::strcasecmp(section, "general") != 0)
{
do {
char *nextp = std::strchr(section, '%');
@ -447,7 +448,7 @@ const char *GetConfigValue(const char *devName, const char *blockName, const cha
return def;
std::string key;
if(blockName && strcasecmp(blockName, "general") != 0)
if(blockName && al::strcasecmp(blockName, "general") != 0)
{
key = blockName;
if(devName)
@ -532,8 +533,8 @@ al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, c
if(!val[0]) return al::nullopt;
return al::make_optional(
strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
strcasecmp(val, "on") == 0 || atoi(val) != 0);
al::strcasecmp(val, "true") == 0 || al::strcasecmp(val, "yes") == 0 ||
al::strcasecmp(val, "on") == 0 || atoi(val) != 0);
}
int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def)
@ -541,6 +542,6 @@ int GetConfigValueBool(const char *devName, const char *blockName, const char *k
const char *val = GetConfigValue(devName, blockName, keyName, "");
if(!val[0]) return def != 0;
return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
strcasecmp(val, "on") == 0 || atoi(val) != 0);
return (al::strcasecmp(val, "true") == 0 || al::strcasecmp(val, "yes") == 0 ||
al::strcasecmp(val, "on") == 0 || atoi(val) != 0);
}

View File

@ -55,6 +55,7 @@
#include "almalloc.h"
#include "alnumeric.h"
#include "alspan.h"
#include "alstring.h"
#include "ambidefs.h"
#include "atomic.h"
#include "bformatdec.h"
@ -90,7 +91,8 @@ ALfloat InitConeScale()
ALfloat ret{1.0f};
if(auto optval = al::getenv("__ALSOFT_HALF_ANGLE_CONES"))
{
if(strcasecmp(optval->c_str(), "true") == 0 || strtol(optval->c_str(), nullptr, 0) == 1)
if(al::strcasecmp(optval->c_str(), "true") == 0
|| strtol(optval->c_str(), nullptr, 0) == 1)
ret *= 0.5f;
}
return ret;
@ -101,7 +103,8 @@ ALfloat InitZScale()
ALfloat ret{1.0f};
if(auto optval = al::getenv("__ALSOFT_REVERSE_Z"))
{
if(strcasecmp(optval->c_str(), "true") == 0 || strtol(optval->c_str(), nullptr, 0) == 1)
if(al::strcasecmp(optval->c_str(), "true") == 0
|| strtol(optval->c_str(), nullptr, 0) == 1)
ret *= -1.0f;
}
return ret;

View File

@ -70,6 +70,7 @@
#include "alcmain.h"
#include "almalloc.h"
#include "alstring.h"
#include "compat.h"
#include "cpu_caps.h"
#include "fpu_modes.h"
@ -662,7 +663,7 @@ static void DirectorySearch(const char *path, const char *ext, al::vector<std::s
size_t len{strlen(dirent->d_name)};
if(len <= extlen) continue;
if(strcasecmp(dirent->d_name+len-extlen, ext) != 0)
if(al::strcasecmp(dirent->d_name+len-extlen, ext) != 0)
continue;
results->emplace_back();

View File

@ -48,6 +48,7 @@
#include "alnumeric.h"
#include "aloptional.h"
#include "alspan.h"
#include "alstring.h"
#include "alu.h"
#include "cpu_caps.h"
#include "devformat.h"
@ -174,22 +175,22 @@ void aluInitMixer()
if(auto resopt = ConfigValueStr(nullptr, nullptr, "resampler"))
{
const char *str{resopt->c_str()};
if(strcasecmp(str, "point") == 0 || strcasecmp(str, "none") == 0)
if(al::strcasecmp(str, "point") == 0 || al::strcasecmp(str, "none") == 0)
ResamplerDefault = PointResampler;
else if(strcasecmp(str, "linear") == 0)
else if(al::strcasecmp(str, "linear") == 0)
ResamplerDefault = LinearResampler;
else if(strcasecmp(str, "cubic") == 0)
else if(al::strcasecmp(str, "cubic") == 0)
ResamplerDefault = FIR4Resampler;
else if(strcasecmp(str, "bsinc12") == 0)
else if(al::strcasecmp(str, "bsinc12") == 0)
ResamplerDefault = BSinc12Resampler;
else if(strcasecmp(str, "bsinc24") == 0)
else if(al::strcasecmp(str, "bsinc24") == 0)
ResamplerDefault = BSinc24Resampler;
else if(strcasecmp(str, "bsinc") == 0)
else if(al::strcasecmp(str, "bsinc") == 0)
{
WARN("Resampler option \"%s\" is deprecated, using bsinc12\n", str);
ResamplerDefault = BSinc12Resampler;
}
else if(strcasecmp(str, "sinc4") == 0 || strcasecmp(str, "sinc8") == 0)
else if(al::strcasecmp(str, "sinc4") == 0 || al::strcasecmp(str, "sinc8") == 0)
{
WARN("Resampler option \"%s\" is deprecated, using cubic\n", str);
ResamplerDefault = FIR4Resampler;

View File

@ -44,6 +44,7 @@
#include "alnumeric.h"
#include "aloptional.h"
#include "alspan.h"
#include "alstring.h"
#include "alu.h"
#include "ambdec.h"
#include "ambidefs.h"
@ -586,25 +587,25 @@ void InitHrtfPanning(ALCdevice *device)
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode"))
{
const char *mode{modeopt->c_str()};
if(strcasecmp(mode, "basic") == 0)
if(al::strcasecmp(mode, "basic") == 0)
{
ERR("HRTF mode \"%s\" deprecated, substituting \"%s\"\n", mode, "ambi2");
mode = "ambi2";
}
if(strcasecmp(mode, "full") == 0)
if(al::strcasecmp(mode, "full") == 0)
device->mRenderMode = HrtfRender;
else if(strcasecmp(mode, "ambi1") == 0)
else if(al::strcasecmp(mode, "ambi1") == 0)
{
device->mRenderMode = NormalRender;
ambi_order = 1;
}
else if(strcasecmp(mode, "ambi2") == 0)
else if(al::strcasecmp(mode, "ambi2") == 0)
{
device->mRenderMode = NormalRender;
ambi_order = 2;
}
else if(strcasecmp(mode, "ambi3") == 0)
else if(al::strcasecmp(mode, "ambi3") == 0)
{
device->mRenderMode = NormalRender;
ambi_order = 3;
@ -732,11 +733,11 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-mode"))
{
const char *mode{modeopt->c_str()};
if(strcasecmp(mode, "headphones") == 0)
if(al::strcasecmp(mode, "headphones") == 0)
headphones = true;
else if(strcasecmp(mode, "speakers") == 0)
else if(al::strcasecmp(mode, "speakers") == 0)
headphones = false;
else if(strcasecmp(mode, "auto") != 0)
else if(al::strcasecmp(mode, "auto") != 0)
ERR("Unexpected stereo-mode: %s\n", mode);
}
}
@ -835,9 +836,9 @@ no_hrtf:
if(auto encopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "stereo-encoding"))
{
const char *mode{encopt->c_str()};
if(strcasecmp(mode, "uhj") == 0)
if(al::strcasecmp(mode, "uhj") == 0)
device->mRenderMode = NormalRender;
else if(strcasecmp(mode, "panpot") != 0)
else if(al::strcasecmp(mode, "panpot") != 0)
ERR("Unexpected stereo-encoding: %s\n", mode);
}
if(device->mRenderMode == NormalRender)