Aggiunta l'accettazione dei NULL pointer come parametri nella rewrite

git-svn-id: svn://10.65.10.50/trunk@4214 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
augusto 1997-03-18 09:28:36 +00:00
parent cc86160256
commit 0ae2f8de88

View File

@ -762,16 +762,18 @@ TString& TString::overwrite(
//
// @xref <mf TString::insert>
{
const int l = len();
if (pos < 0) pos = l;
const int max = pos+strlen(s);
if (max > size()) resize(max, TRUE); // resize needed?
const bool over = max > l; // beyond end of string?
for (int i = l; i < pos; i++) _str[i] = ' '; // space padding
for (; *s; s++) _str[pos++] = *s; // write
if (over) _str[pos] = '\0'; // end of string
if (s)
{
const int l = len();
if (pos < 0) pos = l;
const int max = pos+strlen(s);
if (max > size()) resize(max, TRUE); // resize needed?
const bool over = max > l; // beyond end of string?
for (int i = l; i < pos; i++) _str[i] = ' '; // space padding
for (; *s; s++) _str[pos++] = *s; // write
if (over) _str[pos] = '\0'; // end of string
}
return *this;
}