Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced strcmp with strncmp in cmd line params parsing.

  • Loading branch information...
commit ddea5b60b18ec0abf84092911502efb69fb9820b 1 parent dd8a555
Petar Petrov authored
Showing with 8 additions and 8 deletions.
  1. +2 −2 src/CSdl.cpp
  2. +6 −6 src/Main.cpp
4 src/CSdl.cpp
View
@@ -1076,7 +1076,7 @@ bool CSdl::InitializeSound()
#ifdef LINUX_BUILD
// ALSA is preferred for FMod on Debian
- if ( getenv("SW_SND_ALSA") && !strcmp( getenv("SW_SND_ALSA"), "1" ) )
+ if ( getenv("SW_SND_ALSA") && !strncmp(getenv("SW_SND_ALSA"), "1", 1) )
{
result = FMOD_System_SetOutput(fmod_system, FMOD_OUTPUTTYPE_ALSA);
IsFModOK(result);
@@ -1144,7 +1144,7 @@ bool CSdl::InitializeSound()
else
{
int mixrate = getenv("SW_SND_22KHZ")
- && !strcmp( getenv("SW_SND_22KHZ"), "1" ) ? 22050 : 44100;
+ && !strncmp(getenv("SW_SND_22KHZ"), "1", 1) ? 22050 : 44100;
/* initialize sdl mixer, open up the audio device */
if (Mix_OpenAudio(mixrate, MIX_DEFAULT_FORMAT, 2, 4096) < 0) {
12 src/Main.cpp
View
@@ -68,28 +68,28 @@ int main( int argc, char *argv[] )
if (argc > 1) {
for (int i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-wnd")) {
+ if (!strncmp(argv[i], "-wnd", 4)) {
fullscreen = false;
continue;
- } else if (!strcmp(argv[i], "-sw")) {
+ } else if (!strncmp(argv[i], "-sw", 3)) {
hardware_support = false;
continue;
}
- if (!strcmp(argv[i], "-force-fullscreen")
- || !strcmp(argv[i], "-fullscreen")) {
+ if (!strncmp(argv[i], "-force-fullscreen", 17)
+ || !strncmp(argv[i], "-fullscreen", 11)) {
fullscreen = true;
continue;
}
#ifdef LINUX_BUILD
- if (!strcmp(argv[i], "-snd_alsa")) {
+ if (!strncmp(argv[i], "-snd_alsa", 9)) {
/*
* On the majority Linux distros this seems to be required !
*/
setenv("SW_SND_ALSA", "1", 0);
continue;
- } else if (!strcmp(argv[i], "-snd_22khz")) {
+ } else if (!strncmp(argv[i], "-snd_22khz", 10)) {
/*
* 44KHz somehow seems to be a problem for FMod on Linux
*/
Please sign in to comment.
Something went wrong with that request. Please try again.