From c087f917dda52ea72e200990e41b843767f0091d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 24 Oct 2011 20:29:28 +0200 Subject: GUI: Fix missing audio drivers in Edit Game dialog. This is a regression from 77c65648b1db8f8b7b245510681eafd856798d26. Formerly the code used strtok to check for any audio related GUIO flag to be present in _guioptions. Since strtok tokenizes the string this won't really work. I changed it to use strpbrk, which searches a string for any character from a set of characters (in our case flags). The code should now have the same semantics as of before the above mentioned commit. This also gets rid of copying the gui options into a char array and a strncpy call. --- gui/options.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/gui/options.cpp b/gui/options.cpp index 8b4d9d183e..e93092f954 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -616,11 +616,8 @@ void OptionsDialog::setAudioSettingsState(bool enabled) { _midiPopUpDesc->setEnabled(enabled); _midiPopUp->setEnabled(enabled); - Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1); - char opt[256]; - - strncpy(opt, _guioptions.c_str(), 256); - bool hasMidiDefined = (strtok(opt, allFlags.c_str()) != NULL); + const Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1); + bool hasMidiDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL); if (_domain != Common::ConfigManager::kApplicationDomain && // global dialog hasMidiDefined && // No flags are specified @@ -766,11 +763,8 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const Common::String &pref _midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", _("Specifies output sound device or sound card emulator")); // Populate it - Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1); - char opt[256]; - - strncpy(opt, _guioptions.c_str(), 256); - bool hasMidiDefined = (strtok(opt, allFlags.c_str()) != NULL); + const Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1); + bool hasMidiDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL); const MusicPlugin::List p = MusicMan.getPlugins(); for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { -- cgit v1.2.3