@@ -98,31 +98,31 @@ @end @interface OFStringPlaceholder: OFString @end -extern bool of_unicode_to_iso_8859_2(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_iso_8859_3(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_iso_8859_15(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_windows_1251(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_windows_1252(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_codepage_437(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_codepage_850(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_codepage_858(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_mac_roman(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_koi8_r(const of_unichar_t *, unsigned char *, - size_t, bool); -extern bool of_unicode_to_koi8_u(const of_unichar_t *, unsigned char *, +extern bool of_unicode_to_iso_8859_2(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_iso_8859_3(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_iso_8859_15(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_windows_1251(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_windows_1252(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_codepage_437(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_codepage_850(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_codepage_858(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_mac_roman(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_koi8_r(const OFUnichar *, unsigned char *, + size_t, bool); +extern bool of_unicode_to_koi8_u(const OFUnichar *, unsigned char *, size_t, bool); /* References for static linking */ void _references_to_categories_of_OFString(void) @@ -238,11 +238,11 @@ return nil; } size_t -of_string_utf8_encode(of_unichar_t character, char *buffer) +of_string_utf8_encode(OFUnichar character, char *buffer) { if (character < 0x80) { buffer[0] = character; return 1; } else if (character < 0x800) { @@ -264,11 +264,11 @@ return 0; } ssize_t -of_string_utf8_decode(const char *buffer_, size_t length, of_unichar_t *ret) +of_string_utf8_decode(const char *buffer_, size_t length, OFUnichar *ret) { const unsigned char *buffer = (const unsigned char *)buffer_; if (!(*buffer & 0x80)) { *ret = buffer[0]; @@ -341,15 +341,15 @@ static OFString * decomposedString(OFString *self, const char *const *const *table, size_t size) { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length = self.length; for (size_t i = 0; i < length; i++) { - of_unichar_t c = characters[i]; + OFUnichar c = characters[i]; const char *const *page; if (c >= size) { [ret appendCharacters: &c length: 1]; continue; @@ -472,11 +472,11 @@ - (instancetype)initWithString: (OFString *)string { return (id)[[OFUTF8String alloc] initWithString: string]; } -- (instancetype)initWithCharacters: (const of_unichar_t *)string +- (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { return (id)[[OFUTF8String alloc] initWithCharacters: string length: length]; } @@ -693,11 +693,11 @@ + (instancetype)stringWithString: (OFString *)string { return [[[self alloc] initWithString: string] autorelease]; } -+ (instancetype)stringWithCharacters: (const of_unichar_t *)string ++ (instancetype)stringWithCharacters: (const OFUnichar *)string length: (size_t)length { return [[[self alloc] initWithCharacters: string length: length] autorelease]; } @@ -887,11 +887,11 @@ - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } -- (instancetype)initWithCharacters: (const of_unichar_t *)string +- (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { OF_INVALID_INIT_METHOD } @@ -1116,11 +1116,11 @@ - (size_t)of_getCString: (char *)cString maxLength: (size_t)maxLength encoding: (of_string_encoding_t)encoding lossy: (bool)lossy { - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t i, length = self.length; switch (encoding) { case OF_STRING_ENCODING_UTF_8:; size_t j = 0; @@ -1455,11 +1455,11 @@ - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding { switch (encoding) { case OF_STRING_ENCODING_UTF_8:; - const of_unichar_t *characters; + const OFUnichar *characters; size_t length, UTF8StringLength = 0; characters = self.characters; length = self.length; @@ -1497,16 +1497,16 @@ - (size_t)UTF8StringLength { return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8]; } -- (of_unichar_t)characterAtIndex: (size_t)idx +- (OFUnichar)characterAtIndex: (size_t)idx { OF_UNRECOGNIZED_SELECTOR } -- (void)getCharacters: (of_unichar_t *)buffer +- (void)getCharacters: (OFUnichar *)buffer inRange: (OFRange)range { for (size_t i = 0; i < range.length; i++) buffer[i] = [self characterAtIndex: range.location + i]; } @@ -1513,11 +1513,11 @@ - (bool)isEqual: (id)object { void *pool; OFString *string; - const of_unichar_t *characters, *otherCharacters; + const OFUnichar *characters, *otherCharacters; size_t length; if (object == self) return true; @@ -1534,11 +1534,11 @@ characters = self.characters; otherCharacters = string.characters; if (memcmp(characters, otherCharacters, - length * sizeof(of_unichar_t)) != 0) { + length * sizeof(OFUnichar)) != 0) { objc_autoreleasePoolPop(pool); return false; } objc_autoreleasePoolPop(pool); @@ -1557,11 +1557,11 @@ } - (OFComparisonResult)compare: (OFString *)string { void *pool; - const of_unichar_t *characters, *otherCharacters; + const OFUnichar *characters, *otherCharacters; size_t minimumLength; if (string == self) return OFOrderedSame; @@ -1599,11 +1599,11 @@ } - (OFComparisonResult)caseInsensitiveCompare: (OFString *)string { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters, *otherCharacters; + const OFUnichar *characters, *otherCharacters; size_t length, otherLength, minimumLength; if (string == self) return OFOrderedSame; @@ -1613,23 +1613,23 @@ otherLength = string.length; minimumLength = (length > otherLength ? otherLength : length); for (size_t i = 0; i < minimumLength; i++) { - of_unichar_t c = characters[i]; - of_unichar_t oc = otherCharacters[i]; + OFUnichar c = characters[i]; + OFUnichar oc = otherCharacters[i]; #ifdef OF_HAVE_UNICODE_TABLES if (c >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) { - of_unichar_t tc = + OFUnichar tc = of_unicode_casefolding_table[c >> 8][c & 0xFF]; if (tc) c = tc; } if (oc >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) { - of_unichar_t tc = + OFUnichar tc = of_unicode_casefolding_table[oc >> 8][oc & 0xFF]; if (tc) oc = tc; } @@ -1658,18 +1658,18 @@ return OFOrderedSame; } - (unsigned long)hash { - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length = self.length; uint32_t hash; OF_HASH_INIT(hash); for (size_t i = 0; i < length; i++) { - const of_unichar_t c = characters[i]; + const OFUnichar c = characters[i]; OF_HASH_ADD(hash, (c & 0xFF0000) >> 16); OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); OF_HASH_ADD(hash, c & 0x0000FF); } @@ -1815,35 +1815,35 @@ - (OFRange)rangeOfString: (OFString *)string options: (int)options range: (OFRange)range { void *pool; - const of_unichar_t *searchCharacters; - of_unichar_t *characters; + const OFUnichar *searchCharacters; + OFUnichar *characters; size_t searchLength; if ((searchLength = string.length) == 0) return OFMakeRange(0, 0); if (searchLength > range.length) return OFMakeRange(OFNotFound, 0); - if (range.length > SIZE_MAX / sizeof(of_unichar_t)) + if (range.length > SIZE_MAX / sizeof(OFUnichar)) @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); searchCharacters = string.characters; - characters = of_alloc(range.length, sizeof(of_unichar_t)); + characters = of_alloc(range.length, sizeof(OFUnichar)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - searchLength;; i--) { if (memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t)) == 0) { + searchLength * sizeof(OFUnichar)) == 0) { objc_autoreleasePoolPop(pool); return OFMakeRange(range.location + i, searchLength); } @@ -1853,11 +1853,11 @@ } } else { for (size_t i = 0; i <= range.length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t)) == 0) { + searchLength * sizeof(OFUnichar)) == 0) { objc_autoreleasePoolPop(pool); return OFMakeRange(range.location + i, searchLength); } } @@ -1888,22 +1888,22 @@ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (int)options range: (OFRange)range { - bool (*characterIsMember)(id, SEL, of_unichar_t) = - (bool (*)(id, SEL, of_unichar_t))[characterSet + bool (*characterIsMember)(id, SEL, OFUnichar) = + (bool (*)(id, SEL, OFUnichar))[characterSet methodForSelector: @selector(characterIsMember:)]; - of_unichar_t *characters; + OFUnichar *characters; if (range.length == 0) return OFNotFound; - if (range.length > SIZE_MAX / sizeof(of_unichar_t)) + if (range.length > SIZE_MAX / sizeof(OFUnichar)) @throw [OFOutOfRangeException exception]; - characters = of_alloc(range.length, sizeof(of_unichar_t)); + characters = of_alloc(range.length, sizeof(OFUnichar)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - 1;; i--) { @@ -1931,11 +1931,11 @@ } - (bool)containsString: (OFString *)string { void *pool; - const of_unichar_t *characters, *searchCharacters; + const OFUnichar *characters, *searchCharacters; size_t length, searchLength; if ((searchLength = string.length) == 0) return true; @@ -1947,11 +1947,11 @@ characters = self.characters; searchCharacters = string.characters; for (size_t i = 0; i <= length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, - searchLength * sizeof(of_unichar_t)) == 0) { + searchLength * sizeof(OFUnichar)) == 0) { objc_autoreleasePoolPop(pool); return true; } } @@ -2100,25 +2100,25 @@ return new; } - (bool)hasPrefix: (OFString *)prefix { - of_unichar_t *tmp; + OFUnichar *tmp; size_t prefixLength; bool hasPrefix; if ((prefixLength = prefix.length) > self.length) return false; - tmp = of_alloc(prefixLength, sizeof(of_unichar_t)); + tmp = of_alloc(prefixLength, sizeof(OFUnichar)); @try { void *pool = objc_autoreleasePoolPush(); [self getCharacters: tmp inRange: OFMakeRange(0, prefixLength)]; hasPrefix = (memcmp(tmp, prefix.characters, - prefixLength * sizeof(of_unichar_t)) == 0); + prefixLength * sizeof(OFUnichar)) == 0); objc_autoreleasePoolPop(pool); } @finally { free(tmp); } @@ -2126,31 +2126,31 @@ return hasPrefix; } - (bool)hasSuffix: (OFString *)suffix { - of_unichar_t *tmp; - const of_unichar_t *suffixCharacters; + OFUnichar *tmp; + const OFUnichar *suffixCharacters; size_t length, suffixLength; bool hasSuffix; if ((suffixLength = suffix.length) > self.length) return false; length = self.length; - tmp = of_alloc(suffixLength, sizeof(of_unichar_t)); + tmp = of_alloc(suffixLength, sizeof(OFUnichar)); @try { void *pool = objc_autoreleasePoolPush(); [self getCharacters: tmp inRange: OFMakeRange(length - suffixLength, suffixLength)]; suffixCharacters = suffix.characters; hasSuffix = (memcmp(tmp, suffixCharacters, - suffixLength * sizeof(of_unichar_t)) == 0); + suffixLength * sizeof(OFUnichar)) == 0); objc_autoreleasePoolPop(pool); } @finally { free(tmp); } @@ -2166,11 +2166,11 @@ - (OFArray *)componentsSeparatedByString: (OFString *)delimiter options: (int)options { void *pool; OFMutableArray *array; - const of_unichar_t *characters, *delimiterCharacters; + const OFUnichar *characters, *delimiterCharacters; bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); size_t length = self.length; size_t delimiterLength = delimiter.length; size_t last; OFString *component; @@ -2197,11 +2197,11 @@ } last = 0; for (size_t i = 0; i <= length - delimiterLength; i++) { if (memcmp(characters + i, delimiterCharacters, - delimiterLength * sizeof(of_unichar_t)) != 0) + delimiterLength * sizeof(OFUnichar)) != 0) continue; component = [self substringWithRange: OFMakeRange(last, i - last)]; if (!skipEmpty || component.length > 0) @@ -2233,14 +2233,14 @@ options: (int)options { OFMutableArray *array = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length = self.length; - bool (*characterIsMember)(id, SEL, of_unichar_t) = - (bool (*)(id, SEL, of_unichar_t))[characterSet + bool (*characterIsMember)(id, SEL, OFUnichar) = + (bool (*)(id, SEL, OFUnichar))[characterSet methodForSelector: @selector(characterIsMember:)]; size_t last; last = 0; for (size_t i = 0; i < length; i++) { @@ -2521,22 +2521,22 @@ objc_autoreleasePoolPop(pool); return value; } -- (const of_unichar_t *)characters +- (const OFUnichar *)characters { size_t length = self.length; - of_unichar_t *buffer; + OFUnichar *buffer; - buffer = of_alloc(length, sizeof(of_unichar_t)); + buffer = of_alloc(length, sizeof(OFUnichar)); @try { [self getCharacters: buffer inRange: OFMakeRange(0, length)]; return [[OFData dataWithItemsNoCopy: buffer count: length - itemSize: sizeof(of_unichar_t) + itemSize: sizeof(OFUnichar) freeWhenDone: true] items]; } @catch (id e) { free(buffer); @throw e; } @@ -2548,11 +2548,11 @@ } - (const of_char16_t *)UTF16StringWithByteOrder: (OFByteOrder)byteOrder { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length = self.length; of_char16_t *buffer; size_t j; bool swap = (byteOrder != OFByteOrderNative); @@ -2559,11 +2559,11 @@ /* Allocate memory for the worst case */ buffer = of_alloc((length + 1) * 2, sizeof(of_char16_t)); j = 0; for (size_t i = 0; i < length; i++) { - of_unichar_t c = characters[i]; + OFUnichar c = characters[i]; if (c > 0x10FFFF) { free(buffer); @throw [OFInvalidEncodingException exception]; } @@ -2605,11 +2605,11 @@ } } - (size_t)UTF16StringLength { - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t length, UTF16StringLength; length = UTF16StringLength = self.length; for (size_t i = 0; i < length; i++) @@ -2743,11 +2743,11 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = self.characters; + const OFUnichar *characters = self.characters; size_t i, last = 0, length = self.length; bool stop = false, lastCarriageReturn = false; for (i = 0; i < length && !stop; i++) { if (lastCarriageReturn && characters[i] == '\n') {