mirror of https://github.com/stella-emu/stella.git
More 'const char* const' fixes.
This commit is contained in:
parent
788c836130
commit
d1767d4d93
|
@ -268,7 +268,7 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
|
|||
// it also appends " #x", where x seems to vary. Obviously this wreaks
|
||||
// havoc with the idea that a joystick will always have the same name.
|
||||
// So we truncate the number.
|
||||
const char* sdlname = SDL_JoystickName(myStick);
|
||||
const char* const sdlname = SDL_JoystickName(myStick);
|
||||
const string& desc = BSPF::startsWithIgnoreCase(sdlname, "XInput Controller")
|
||||
? "XInput Controller" : sdlname;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ FSNodeZIP::FSNodeZIP(const string& p)
|
|||
if (_zipFile[0] == '~')
|
||||
{
|
||||
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
||||
const char* home = std::getenv("HOME"); // NOLINT (not thread safe)
|
||||
const char* const home = std::getenv("HOME"); // NOLINT (not thread safe)
|
||||
if (home != nullptr)
|
||||
_zipFile.replace(0, 1, home);
|
||||
#elif defined(BSPF_WINDOWS)
|
||||
|
@ -270,8 +270,8 @@ AbstractFSNodePtr FSNodeZIP::getParent() const
|
|||
if(_virtualPath.empty())
|
||||
return _realNode ? _realNode->getParent() : nullptr;
|
||||
|
||||
const char* start = _path.c_str();
|
||||
const char* end = lastPathComponent(_path);
|
||||
const char* const start = _path.c_str();
|
||||
const char* const end = lastPathComponent(_path);
|
||||
|
||||
return make_unique<FSNodeZIP>(string(start, end - start - 1));
|
||||
}
|
||||
|
|
|
@ -120,7 +120,9 @@ bool SoundSDL2::openDevice()
|
|||
|
||||
myDeviceId = BSPF::clamp(myAudioSettings.device(), 0U,
|
||||
static_cast<uInt32>(myDevices.size() - 1));
|
||||
const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr;
|
||||
const char* const device = myDeviceId
|
||||
? myDevices.at(myDeviceId).first.c_str()
|
||||
: nullptr;
|
||||
|
||||
myDevice = SDL_OpenAudioDevice(device, 0, &desired, &myHardwareSpec,
|
||||
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
|
||||
|
@ -384,7 +386,9 @@ void SoundSDL2::callback(void* object, uInt8* stream, int len)
|
|||
bool SoundSDL2::playWav(const string& fileName, const uInt32 position,
|
||||
const uInt32 length)
|
||||
{
|
||||
const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr;
|
||||
const char* const device = myDeviceId
|
||||
? myDevices.at(myDeviceId).first.c_str()
|
||||
: nullptr;
|
||||
|
||||
return myWavHandler.play(fileName, device, position, length);
|
||||
}
|
||||
|
|
|
@ -845,7 +845,7 @@ string CartDebug::loadListFile()
|
|||
buf >> addr >> addr_s;
|
||||
if(addr_s.length() == 0)
|
||||
continue;
|
||||
const char* p = addr_s[0] == 'U' ? addr_s.c_str() + 1 : addr_s.c_str();
|
||||
const char* const p = addr_s[0] == 'U' ? addr_s.c_str() + 1 : addr_s.c_str();
|
||||
addr = static_cast<int>(strtoul(p, nullptr, 16));
|
||||
|
||||
// For now, completely ignore ROM addresses
|
||||
|
@ -1555,7 +1555,7 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
|
|||
// Now scan user-defined labels
|
||||
for(const auto& iter: myUserAddresses)
|
||||
{
|
||||
const char* l = iter.first.c_str();
|
||||
const char* const l = iter.first.c_str();
|
||||
if(BSPF::matchesCamelCase(l, in))
|
||||
completions.push_back(l);
|
||||
}
|
||||
|
|
|
@ -899,7 +899,7 @@ void Debugger::getCompletions(const char* in, StringList& list) const
|
|||
{
|
||||
for(const auto& iter : myFunctions)
|
||||
{
|
||||
const char* l = iter.first.c_str();
|
||||
const char* const l = iter.first.c_str();
|
||||
if(BSPF::matchesCamelCase(l, in))
|
||||
list.push_back(l);
|
||||
}
|
||||
|
|
|
@ -509,7 +509,7 @@ class AbstractFSNode
|
|||
if(str.empty())
|
||||
return "";
|
||||
|
||||
const char* start = str.c_str();
|
||||
const char* const start = str.c_str();
|
||||
const char* cur = start + str.size() - 2;
|
||||
|
||||
while (cur >= start && !(*cur == '/' || *cur == '\\'))
|
||||
|
|
|
@ -118,7 +118,7 @@ void KidVid::update()
|
|||
if(myTape)
|
||||
{
|
||||
static constexpr uInt32 gameNumber[4] = { 3, 1, 2, 3 };
|
||||
static constexpr const char* gameName[6] = {
|
||||
static constexpr const char* const gameName[6] = {
|
||||
"Harmony Smurf", "Handy Smurf", "Greedy Smurf",
|
||||
"Big Number Hunt", "Great Letter Roundup", "Spooky Spelling Bee"
|
||||
};
|
||||
|
@ -240,7 +240,7 @@ bool KidVid::load(Serializer& in)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const char* KidVid::getFileName() const
|
||||
{
|
||||
static constexpr const char* fileNames[6] = {
|
||||
static constexpr const char* const fileNames[6] = {
|
||||
"KVS3.WAV", "KVS1.WAV", "KVS2.WAV",
|
||||
"KVB3.WAV", "KVB1.WAV", "KVB2.WAV"
|
||||
};
|
||||
|
|
|
@ -527,7 +527,7 @@ string OSystem::createConsole(const FSNode& rom, const string& md5sum,
|
|||
{
|
||||
// Make sure there always is an id
|
||||
constexpr int ID_LEN = 32;
|
||||
const char* HEX_DIGITS = "0123456789ABCDEF";
|
||||
const char* const HEX_DIGITS = "0123456789ABCDEF";
|
||||
char id_chr[ID_LEN] = { 0 };
|
||||
const Random rnd;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void OSystemUNIX::getBaseDirectories(string& basedir, string& homedir,
|
|||
bool useappdir, const string& usedir)
|
||||
{
|
||||
// Use XDG_CONFIG_HOME if defined, otherwise use the default
|
||||
const char* cfg_home = std::getenv("XDG_CONFIG_HOME"); // NOLINT
|
||||
const char* const cfg_home = std::getenv("XDG_CONFIG_HOME"); // NOLINT
|
||||
const string& configDir = cfg_home != nullptr ? cfg_home : "~/.config";
|
||||
basedir = configDir + "/stella";
|
||||
homedir = "~/";
|
||||
|
|
|
@ -77,7 +77,7 @@ string FSNodeWINDOWS::getShortPath() const
|
|||
if (home != "" && BSPF::startsWithIgnoreCase(_path, home))
|
||||
{
|
||||
string path = "~";
|
||||
const char* offset = _path.c_str() + home.length();
|
||||
const char* const offset = _path.c_str() + home.length();
|
||||
if (*offset != FSNode::PATH_SEPARATOR)
|
||||
path += FSNode::PATH_SEPARATOR;
|
||||
path += offset;
|
||||
|
@ -105,13 +105,13 @@ AbstractFSNodePtr FSNodeWINDOWS::getParent() const
|
|||
|
||||
if (_path.size() > 3)
|
||||
{
|
||||
const char* start = _path.c_str();
|
||||
const char* end = lastPathComponent(_path);
|
||||
const char* const start = _path.c_str();
|
||||
const char* const end = lastPathComponent(_path);
|
||||
|
||||
return make_shared<FSNodeWINDOWS>(string(start, static_cast<size_t>(end - start)));
|
||||
return make_unique<FSNodeWINDOWS>(string(start, static_cast<size_t>(end - start)));
|
||||
}
|
||||
else
|
||||
return make_shared<FSNodeWINDOWS>();
|
||||
return make_unique<FSNodeWINDOWS>();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -135,7 +135,7 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const
|
|||
entry._isFile = false;
|
||||
entry._isPseudoRoot = false;
|
||||
entry._path = current_drive;
|
||||
myList.emplace_back(make_shared<FSNodeWINDOWS>(entry));
|
||||
myList.emplace_back(make_unique<FSNodeWINDOWS>(entry));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -164,8 +164,8 @@ void FSNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
|
|||
{
|
||||
const char* const asciiName = find_data.cFileName;
|
||||
|
||||
// Skip local directory (.) and parent (..)
|
||||
if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2))
|
||||
// Skip files starting with '.' (we assume empty filesnames never occur)
|
||||
if (asciiName[0] == '.')
|
||||
return;
|
||||
|
||||
const bool isDirectory = static_cast<bool>(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
|
@ -186,7 +186,7 @@ void FSNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
|
|||
entry._isPseudoRoot = false;
|
||||
entry._size = find_data.nFileSizeHigh * (static_cast<size_t>(MAXDWORD) + 1) + find_data.nFileSizeLow;
|
||||
|
||||
list.emplace_back(make_shared<FSNodeWINDOWS>(entry));
|
||||
list.emplace_back(make_unique<FSNodeWINDOWS>(entry));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue