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:
parent
cc86160256
commit
0ae2f8de88
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user