don't accept NULL to assignment

simplify
This commit is contained in:
Glenn Maynard
2006-09-18 23:42:32 +00:00
parent b8349ca68b
commit 106b0ae7a3
+3 -11
View File
@@ -188,18 +188,11 @@ inline void ssasn(std::string& sDst, const std::string& sSrc)
} }
inline void ssasn(std::string& sDst, PCSTR pA) inline void ssasn(std::string& sDst, PCSTR pA)
{ {
// Watch out for NULLs, as always.
if ( 0 == pA )
{
sDst.erase();
}
#if defined(HAVE_ASSIGN_FIX) #if defined(HAVE_ASSIGN_FIX)
// If pA actually points to part of sDst, we must NOT erase(), but // If pA actually points to part of sDst, we must NOT erase(), but
// rather take a substring // rather take a substring
else if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() ) if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() )
{ {
sDst =sDst.substr(static_cast<SS_SIZETYPE>(pA-sDst.c_str())); sDst =sDst.substr(static_cast<SS_SIZETYPE>(pA-sDst.c_str()));
} }
@@ -212,8 +205,8 @@ inline void ssasn(std::string& sDst, PCSTR pA)
Q172398(sDst); Q172398(sDst);
sDst.assign(pA); sDst.assign(pA);
} }
#else
else else
#else
sDst.assign(pA); sDst.assign(pA);
#endif #endif
} }
@@ -395,9 +388,8 @@ public:
{ {
} }
CStdStr(const std::string& str) CStdStr(const std::string& str): MYBASE(str)
{ {
ssasn(*this, str);
} }
CStdStr(PCMYSTR pT, MYSIZE n) : MYBASE(pT, n) CStdStr(PCMYSTR pT, MYSIZE n) : MYBASE(pT, n)