Changeset 973 for cpp/frams/util/sstring.cpp
- Timestamp:
- 07/03/20 00:37:13 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstring.cpp
r970 r973 163 163 } 164 164 165 void SString::memoryHint(int howbig)166 {167 detachCopy(howbig);168 }169 170 165 void SString::detachEmpty(int ensuresize) 171 166 { … … 201 196 char *SString::directWrite(int ensuresize) 202 197 { 203 if (ensuresize < 0) ensuresize = len ();198 if (ensuresize < 0) ensuresize = length(); 204 199 REF_LOCK; 205 200 detachCopy(ensuresize); … … 259 254 void SString::operator+=(const SString&s) 260 255 { 261 append(s.c_str(), s.len ());256 append(s.c_str(), s.length()); 262 257 } 263 258 … … 298 293 /////////////////////////////////////// 299 294 300 SString SString::substr(int begin, int length) const301 { 302 if (begin < 0) { length+= begin; begin = 0; }303 if ( length >= (len() - begin)) length = len() - begin;304 if ( length<= 0) return SString();305 if ( length == len()) return *this;306 return SString((*this)(begin), length);295 SString SString::substr(int begin, int numchars) const 296 { 297 if (begin < 0) { numchars += begin; begin = 0; } 298 if (numchars >= (length() - begin)) numchars = length() - begin; 299 if (numchars <= 0) return SString(); 300 if (numchars == length()) return *this; 301 return SString((*this)(begin), numchars); 307 302 } 308 303 … … 337 332 bool SString::getNextToken(int& pos, SString &token, char separator) const 338 333 { 339 if (pos >= len ()) { token = 0; return false; }334 if (pos >= length()) { token = 0; return false; } 340 335 int p1 = pos, p2; 341 336 const char *t1 = buf->txt + pos; 342 337 const char *t2 = strchr(t1, separator); 343 if (t2) pos = (p2 = (t2 - buf->txt)) + 1; else p2 = pos = len ();338 if (t2) pos = (p2 = (t2 - buf->txt)) + 1; else p2 = pos = length(); 344 339 strncpy(token.directWrite(p2 - p1), t1, p2 - p1); 345 340 token.endWrite(p2 - p1); … … 401 396 char* p = ret.directWrite(size); 402 397 assert(p != NULL); 403 size = ret. directMaxLen() + 1;398 size = ret.capacity() + 1; 404 399 /* Try to print in the allocated space. */ 405 400 va_start(ap, format);
Note: See TracChangeset
for help on using the changeset viewer.