1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Re-define nil as nullptr, cleaning up some potential issues along the way

This commit is contained in:
2013-01-20 20:48:41 -08:00
parent c65ac61fb8
commit f86b549293
36 changed files with 123 additions and 130 deletions

View File

@ -116,7 +116,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif
#ifndef nil
# define nil (0)
# define nil (nullptr)
#endif
typedef int32_t hsError;

View File

@ -734,7 +734,7 @@ template <class T> void hsTArray<T>::SetCountAndZero(int count)
}
int i;
for( i = 0; i < fTotalCount; i++ )
fArray[i] = nil;
fArray[i] = 0;
fUseCount = count;
}
@ -746,7 +746,7 @@ template <class T> void hsTArray<T>::ExpandAndZero(int count)
Expand(count);
int i;
for( i = n; i < count; i++ )
fArray[i] = nil;
fArray[i] = 0;
}
if( fUseCount < count )
fUseCount = count;

View File

@ -88,7 +88,7 @@ size_t wcsnlen(const wchar_t *s, size_t maxlen)
void plString::IConvertFromUtf8(const char *utf8, size_t size)
{
if (utf8 == nil) {
if (!utf8) {
fUtf8Buffer = plStringBuffer<char>();
return;
}
@ -134,7 +134,7 @@ plString &plString::operator=(const plStringBuffer<char> &init)
void plString::IConvertFromUtf16(const uint16_t *utf16, size_t size)
{
fUtf8Buffer = plStringBuffer<char>();
if (utf16 == nil)
if (!utf16)
return;
if ((int32_t)size < 0)
@ -213,7 +213,7 @@ void plString::IConvertFromWchar(const wchar_t *wstr, size_t size)
void plString::IConvertFromUtf32(const UniChar *ustr, size_t size)
{
fUtf8Buffer = plStringBuffer<char>();
if (ustr == nil)
if (!ustr)
return;
if ((int32_t)size < 0)
@ -271,7 +271,7 @@ void plString::IConvertFromUtf32(const UniChar *ustr, size_t size)
void plString::IConvertFromIso8859_1(const char *astr, size_t size)
{
fUtf8Buffer = plStringBuffer<char>();
if (astr == nil)
if (!astr)
return;
if ((int32_t)size < 0)
@ -477,23 +477,23 @@ plUnicodeBuffer plString::GetUnicodeArray() const
int plString::ToInt(int base) const
{
return static_cast<int>(strtol(c_str(), nil, base));
return static_cast<int>(strtol(c_str(), nullptr, base));
}
unsigned int plString::ToUInt(int base) const
{
return static_cast<unsigned int>(strtoul(c_str(), nil, base));
return static_cast<unsigned int>(strtoul(c_str(), nullptr, base));
}
float plString::ToFloat() const
{
// strtof is C99, which MS doesn't support...
return (float)strtod(c_str(), nil);
return (float)strtod(c_str(), nullptr);
}
double plString::ToDouble() const
{
return strtod(c_str(), nil);
return strtod(c_str(), nullptr);
}
// Microsoft doesn't provide this for us

View File

@ -215,6 +215,15 @@ private:
void IConvertFromUtf32(const UniChar *ustr, size_t size);
void IConvertFromIso8859_1(const char *astr, size_t size);
// Constructing and comparing with nil or nullptr won't break plString,
// but it's preferred not to do so with the constants. That is to say,
// you can construct with a const char * which points to null, but
// don't actually write `plString foo = nil;`
plString(std::nullptr_t) { }
void operator=(std::nullptr_t) { }
void operator==(std::nullptr_t) const { }
void operator!=(std::nullptr_t) const { }
public:
/** Construct a valid, empty string. */
plString() { }