(file) Return to String.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/String.cpp between version 1.123 and 1.129.2.1

version 1.123, 2006/11/10 18:14:58 version 1.129.2.1, 2007/11/08 09:15:06
Line 579 
Line 579 
     if (rep->size == size_t(-1))     if (rep->size == size_t(-1))
     {     {
         StringRep::free(rep);         StringRep::free(rep);
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index);
     }     }
  
     rep->data[rep->size] = '\0';     rep->data[rep->size] = '\0';
Line 596 
Line 596 
     while (*end++)     while (*end++)
         ;         ;
  
     return end - str - 1;      return (Uint32)(end - str - 1);
 } }
  
 //============================================================================== //==============================================================================
Line 669 
Line 669 
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index);
     }     }
  
     _rep->size = n1 + tmp;     _rep->size = n1 + tmp;
Line 689 
Line 689 
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index);
     }     }
  
     _rep->size = n2 + tmp;     _rep->size = n2 + tmp;
Line 742 
Line 742 
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index);
     }     }
  
     _rep->data[_rep->size] = 0;     _rep->data[_rep->size] = 0;
Line 788 
Line 788 
     str[_rep->size] = '\0';     str[_rep->size] = '\0';
     return CString(str);     return CString(str);
 #else #else
     Uint32 n = 3 * _rep->size;      Uint32 n = (Uint32)(3 * _rep->size);
     char* str = (char*)operator new(n + 1);     char* str = (char*)operator new(n + 1);
     size_t size = _copyToUTF8(str, _rep->data, _rep->size);     size_t size = _copyToUTF8(str, _rep->data, _rep->size);
     str[size] = '\0';     str[size] = '\0';
Line 802 
Line 802 
  
     size_t oldSize = _rep->size;     size_t oldSize = _rep->size;
     size_t newSize = oldSize + n;     size_t newSize = oldSize + n;
     _reserve(_rep, newSize);      _reserve(_rep, (Uint32)newSize);
     _copy(_rep->data + oldSize, (Uint16*)str, n);     _copy(_rep->data + oldSize, (Uint16*)str, n);
     _rep->size = newSize;     _rep->size = newSize;
     _rep->data[newSize] = '\0';     _rep->data[newSize] = '\0';
Line 812 
Line 812 
  
 String& String::append(const String& str) String& String::append(const String& str)
 { {
     return append((Char16*)(&(str._rep->data[0])), str._rep->size);      return append((Char16*)(&(str._rep->data[0])), (Uint32)str._rep->size);
 } }
  
 String& String::append(const char* str, Uint32 size) String& String::append(const char* str, Uint32 size)
Line 822 
Line 822 
     size_t oldSize = _rep->size;     size_t oldSize = _rep->size;
     size_t cap = oldSize + size;     size_t cap = oldSize + size;
  
     _reserve(_rep, cap);      _reserve(_rep, (Uint32)cap);
     size_t utf8_error_index;     size_t utf8_error_index;
     size_t tmp = _convert(     size_t tmp = _convert(
         (Uint16*)_rep->data + oldSize, str, size, utf8_error_index);         (Uint16*)_rep->data + oldSize, str, size, utf8_error_index);
Line 831 
Line 831 
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index);
     }     }
  
     _rep->size += tmp;     _rep->size += tmp;
Line 843 
Line 843 
 void String::remove(Uint32 index, Uint32 n) void String::remove(Uint32 index, Uint32 n)
 { {
     if (n == PEG_NOT_FOUND)     if (n == PEG_NOT_FOUND)
         n = _rep->size - index;          n = (Uint32)(_rep->size - index);
  
     _checkBounds(index + n, _rep->size);     _checkBounds(index + n, _rep->size);
  
Line 870 
Line 870 
     if (index < _rep->size)     if (index < _rep->size)
     {     {
         if (n == PEG_NOT_FOUND || n > _rep->size - index)         if (n == PEG_NOT_FOUND || n > _rep->size - index)
             n = _rep->size - index;              n = (Uint32)(_rep->size - index);
  
         return String((Char16*)(_rep->data + index), n);         return String((Char16*)(_rep->data + index), n);
     }     }
Line 1104 
Line 1104 
     if (InitializeICU::initICUSuccessful())     if (InitializeICU::initICUSuccessful())
     {     {
         return  u_strcasecmp(         return  u_strcasecmp(
             str1._rep->data, str2._rep->data, U_FOLD_CASE_DEFAULT);              (const UChar*)str1._rep->data,
               (const UChar*)str2._rep->data,
               U_FOLD_CASE_DEFAULT
               );
     }     }
  
 #endif /* PEGASUS_HAS_ICU */ #endif /* PEGASUS_HAS_ICU */
Line 1229 
Line 1232 
  
 Boolean String::equal(const String& s1, const String& s2) Boolean String::equal(const String& s1, const String& s2)
 { {
     return s1._rep->size == s2._rep->size && memcmp(s1._rep->data,      return (s1._rep == s2._rep) ||
         s2._rep->data, s1._rep->size * sizeof(Uint16)) == 0;          (s1._rep->size == s2._rep->size) &&
           memcmp(s1._rep->data,
                  s2._rep->data,
                  s1._rep->size * sizeof(Uint16)) == 0;
 } }
  
 Boolean String::equal(const String& s1, const char* s2) Boolean String::equal(const String& s1, const char* s2)
Line 1259 
Line 1265 
  
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const String& str) PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const String& str)
 { {
 #if defined(PEGASUS_OS_OS400)  
   
     CString cstr = str.getCString();  
     const char* utf8str = cstr;  
     os << utf8str;  
     return os;  
 #else  
   
 #if defined(PEGASUS_HAS_ICU) #if defined(PEGASUS_HAS_ICU)
  
     if (InitializeICU::initICUSuccessful())     if (InitializeICU::initICUSuccessful())
Line 1302 
Line 1300 
     }     }
  
     return os;     return os;
 #endif // PEGASUS_OS_OS400  
 } }
  
 void StringAppendCharAux(StringRep*& _rep) void StringAppendCharAux(StringRep*& _rep)
Line 1325 
Line 1322 
     _rep = tmp;     _rep = tmp;
 } }
  
   void AssignASCII(String& s, const char* str, Uint32 n)
   {
       class StringLayout
       {
       public:
           StringRep* rep;
       };
   
       StringLayout* that = (StringLayout*)&s;
   
       _checkNullPointer(str);
   
       if (n > that->rep->cap || that->rep->refs.get() != 1)
       {
           StringRep::unref(that->rep);
           that->rep = StringRep::alloc(n);
       }
   
       _copy(that->rep->data, str, n);
       that->rep->size = n;
       that->rep->data[that->rep->size] = 0;
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 /* /*
Line 1453 
Line 1473 
         This avoids slower UTF8 processing when not needed.         This avoids slower UTF8 processing when not needed.
  
 ================================================================================ ================================================================================
   
 TO-DO:  
   
     (+) [DONE] Use PEGASUS_USE_EXPERIMENTAL_INTERFACES  
   
     (+) [DONE] Submit BUG-2754 (Windows buffer limit).  
   
     (+) [DONE] Eliminate char versions of find() and append().  
   
     (+) [DONE] Remove PEGASUS_MAX_PRINTABLE_CHARACTER from Config.h  
   
     (+) [DONE] Change _next_pow_2() to _roundUpToPow2().  
   
     (+) [DONE] Change '99' to '2' in StringRep constructor (comment as well).  
   
     (+) [DONE] Comment StringRep allocation layout.  
   
     (+) [DONE] Conceal private inline functions.  
   
     (+) [DONE] Shorten inclusion of StringInline.h in String.h.  
   
     (+) [DONE] Change USE_INTERNAL_INLINE TO DISABLE_INTERNAL_INLINE or get  
         rid of altogether.  
   
     (+) [DONE] useCamelNotationOnAllFunctionNames.  
   
     (+) [DONE] Check for overlow condition in StringRep::alloc().  
   
     (+) [DONE] Remove tabs (used vim ":set expandtab" and ":retab").  
   
     (+) [DONE] Fix throw-related memory leak.  
   
     (+) [DONE] Look at PEP223 for coding security guidelines.  
   
     (+) [DONE] Use old AtomicInt for now (new AtomicInt part of bug #4250).  
   
     (+) [DONE] Removed appendASCII() and the ASCII form of the constructor.  
   
     (+) DOC++ String.h - will open new bug?  
   
     (+) Added PEGASUS_DISABLE_INTERNAL_INLINES macro (to permit suppression  
         on certain platforms).  
   
 ================================================================================  
 */ */


Legend:
Removed from v.1.123  
changed lines
  Added in v.1.129.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2