@@ -76,11 +76,12 @@ cLen = of_string_utf8_to_unicode(s->cString + i, s->cStringLength - i, &c); if (cLen == 0 || c > 0x10FFFF) { [self freeMemory: unicodeString]; - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } if (c >> 8 < tableSize) { of_unichar_t tc = table[c >> 8][c & 0xFF]; @@ -97,11 +98,12 @@ newCStringLength += 3; else if (c < 0x110000) newCStringLength += 4; else { [self freeMemory: unicodeString]; - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } i += cLen; } @@ -117,11 +119,12 @@ for (i = 0; i < unicodeLen; i++) { if ((d = of_string_unicode_to_utf8(unicodeString[i], newCString + j)) == 0) { [self freeMemory: unicodeString]; [self freeMemory: newCString]; - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } j += d; } assert(j == newCStringLength); @@ -151,11 +154,11 @@ switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) { case 1: s->UTF8 = YES; break; case -1: - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException exceptionWithClass: isa]; } s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + UTF8StringLength + 1]; @@ -178,11 +181,11 @@ switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) { case 1: s->UTF8 = YES; break; case -1: - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException exceptionWithClass: isa]; } s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + UTF8StringLength + 1]; @@ -222,12 +225,12 @@ - (void)appendString: (OFString*)string { size_t UTF8StringLength; if (string == nil) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; UTF8StringLength = [string UTF8StringLength]; s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + @@ -259,16 +262,16 @@ { char *UTF8String; int UTF8StringLength; if (format == nil) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String], arguments)) == -1) - @throw [OFInvalidFormatException newWithClass: isa]; + @throw [OFInvalidFormatException exceptionWithClass: isa]; @try { [self appendUTF8String: UTF8String withLength: UTF8StringLength]; } @finally { @@ -307,18 +310,20 @@ continue; /* A start byte can't happen first as we reversed everything */ if (OF_UNLIKELY(s->cString[i] & 0x40)) { madvise(s->cString, s->cStringLength, MADV_NORMAL); - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } /* Next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 1 || !(s->cString[i + 1] & 0x80))) { madvise(s->cString, s->cStringLength, MADV_NORMAL); - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } /* Next byte is the start byte */ if (OF_LIKELY(s->cString[i + 1] & 0x40)) { s->cString[i] ^= s->cString[i + 1]; @@ -331,11 +336,12 @@ /* Second next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 2 || !(s->cString[i + 2] & 0x80))) { madvise(s->cString, s->cStringLength, MADV_NORMAL); - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } /* Second next byte is the start byte */ if (OF_LIKELY(s->cString[i + 2] & 0x40)) { s->cString[i] ^= s->cString[i + 2]; @@ -348,11 +354,12 @@ /* Third next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 3 || !(s->cString[i + 3] & 0x80))) { madvise(s->cString, s->cStringLength, MADV_NORMAL); - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException + exceptionWithClass: isa]; } /* Third next byte is the start byte */ if (OF_LIKELY(s->cString[i + 3] & 0x40)) { s->cString[i] ^= s->cString[i + 3]; @@ -367,11 +374,11 @@ continue; } /* UTF-8 does not allow more than 4 bytes per character */ madvise(s->cString, s->cStringLength, MADV_NORMAL); - @throw [OFInvalidEncodingException newWithClass: isa]; + @throw [OFInvalidEncodingException exceptionWithClass: isa]; } madvise(s->cString, s->cStringLength, MADV_NORMAL); } @@ -391,11 +398,11 @@ atIndex: (size_t)index { size_t newCStringLength; if (index > s->length) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; if (s->UTF8) index = of_string_index_to_position(s->cString, index, s->cStringLength); @@ -417,15 +424,15 @@ { size_t start = range.start; size_t end = range.start + range.length; if (start > end) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; if (end > s->length) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; s->length -= end - start; if (s->UTF8) { start = of_string_index_to_position(s->cString, start, @@ -441,11 +448,10 @@ @try { s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ - [e release]; } } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString*)replacement @@ -453,15 +459,15 @@ size_t start = range.start; size_t end = range.start + range.length; size_t newCStringLength, newLength; if (start > end) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException exceptionWithClass: isa + selector: _cmd]; if (end > s->length) - @throw [OFOutOfRangeException newWithClass: isa]; + @throw [OFOutOfRangeException exceptionWithClass: isa]; newLength = s->length - (end - start) + [replacement length]; if (s->UTF8) { start = of_string_index_to_position(s->cString, start, @@ -567,11 +573,10 @@ @try { s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ - [e release]; } } - (void)deleteTrailingWhitespaces { @@ -594,11 +599,10 @@ @try { s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ - [e release]; } } - (void)deleteEnclosingWhitespaces { @@ -633,11 +637,10 @@ @try { s->cString = [self resizeMemory: s->cString toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ - [e release]; } } - copy {