mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-07-31 01:15:48 -04:00
newer standards prefer nullptr over NULL - this is most of them but there are others too
This commit is contained in:
+13
-13
@@ -28,7 +28,7 @@ bool CConfig::LoadFile(char * file)
|
||||
|
||||
// open file
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL || fp == (FILE *)-1)
|
||||
if (fp == nullptr || fp == (FILE *)-1)
|
||||
{
|
||||
//fprintf(stderr,"Failed to open config file %s!",file);
|
||||
return false;
|
||||
@@ -71,21 +71,21 @@ void CConfig::UnloadFile(void)
|
||||
//-----------------------------------
|
||||
{
|
||||
delete[] pConfig;
|
||||
pConfig = NULL;
|
||||
pConfig = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
/// finds a key of the config in memory
|
||||
// key argument is case-insensitive, but must be upper case in config file
|
||||
// Returns true for success (passing NULL is a special case returned as success)
|
||||
// Returns true for success (passing nullptr is a special case returned as success)
|
||||
bool CConfig::FindKey(char *key)
|
||||
//-----------------------------------
|
||||
{
|
||||
if (pConfig == NULL)
|
||||
if (pConfig == nullptr)
|
||||
return false;
|
||||
|
||||
// special case...continue with existing key
|
||||
if (key == NULL)
|
||||
if (key == nullptr)
|
||||
return true;
|
||||
|
||||
// form the search key
|
||||
@@ -96,12 +96,12 @@ bool CConfig::FindKey(char *key)
|
||||
|
||||
// find the key heading
|
||||
pCursor = strstr(pConfig,strBuffer);
|
||||
if (pCursor==NULL)
|
||||
if (pCursor==nullptr)
|
||||
return false;
|
||||
|
||||
// find the closing bracket of key heading
|
||||
pCursor = strchr(pCursor,']');
|
||||
if (pCursor==NULL)
|
||||
if (pCursor==nullptr)
|
||||
return false;
|
||||
pCursor++;
|
||||
|
||||
@@ -110,7 +110,7 @@ bool CConfig::FindKey(char *key)
|
||||
|
||||
//-----------------------------------
|
||||
/// extract a number from the config string
|
||||
// pass the key to find the first number in the list, else NULL to find the next number in the list
|
||||
// pass the key to find the first number in the list, else nullptr to find the next number in the list
|
||||
// returns 0 if no number is found, else returns the number
|
||||
long CConfig::GetLong(char *key)
|
||||
//-----------------------------------
|
||||
@@ -133,20 +133,20 @@ long CConfig::GetLong(char *key)
|
||||
|
||||
//-----------------------------------
|
||||
/// extract string (in double-quotes) from the list.
|
||||
// pass the key to find the first string in the list, else NULL to find the next string in the list
|
||||
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
|
||||
// pass the key to find the first string in the list, else nullptr to find the next string in the list
|
||||
// returns nullptr if no string found, else returns a temporary copy of the string (without quotes)
|
||||
char * CConfig::GetString(char *key)
|
||||
//-----------------------------------
|
||||
{
|
||||
if (!FindKey(key))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
|
||||
// look for start of string or end of key
|
||||
while (*pCursor && *pCursor != '"' && *pCursor != '[')
|
||||
pCursor++;
|
||||
if (*(pCursor++) != '"')
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// until closing quote
|
||||
int c = 0;
|
||||
@@ -160,7 +160,7 @@ char * CConfig::GetString(char *key)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user