Differences From Artifact [4eb8ccee47]:
- File
src/OFMutableString_UTF8.m
— part of check-in
[2f4e0df8be]
at
2017-10-17 00:33:37
on branch trunk
— Do not use implicit method return types
Instead, explicitly declare them, as OF_ASSUME_NONNULL_{BEGIN,END} does
not apply to implicit return types. This means that after this commit,
all init methods have a nonnull return type, as they should have. (user: js, size: 20072) [annotate] [blame] [check-ins using]
To Artifact [7d0da4b4a5]:
- File src/OFMutableString_UTF8.m — part of check-in [a06354b42a] at 2017-10-22 15:05:39 on branch trunk — Make Apple GCC with -Wshadow happy (user: js, size: 20010) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
176 177 178 179 180 181 182 | /* * Even though cStringLength can change, length cannot, therefore no * need to change it. */ } - (void)setCharacter: (of_unichar_t)character | | | | | | | | | | < | | | < | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | /* * Even though cStringLength can change, length cannot, therefore no * need to change it. */ } - (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx { char buffer[4]; of_unichar_t c; size_t lenNew; ssize_t lenOld; if (_s->isUTF8) idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength); if (idx > _s->cStringLength) @throw [OFOutOfRangeException exception]; /* Shortcut if old and new character both are ASCII */ if (character < 0x80 && !(_s->cString[idx] & 0x80)) { _s->hashed = false; _s->cString[idx] = character; return; } if ((lenNew = of_string_utf8_encode(character, buffer)) == 0) @throw [OFInvalidEncodingException exception]; if ((lenOld = of_string_utf8_decode(_s->cString + idx, _s->cStringLength - idx, &c)) <= 0) @throw [OFInvalidEncodingException exception]; _s->hashed = false; if (lenNew == (size_t)lenOld) memcpy(_s->cString + idx, buffer, lenNew); else if (lenNew > (size_t)lenOld) { _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength - lenOld + lenNew + 1]; memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld, _s->cStringLength - idx - lenOld); memcpy(_s->cString + idx, buffer, lenNew); _s->cStringLength -= lenOld; _s->cStringLength += lenNew; _s->cString[_s->cStringLength] = '\0'; if (character >= 0x80) _s->isUTF8 = true; } else if (lenNew < (size_t)lenOld) { memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld, _s->cStringLength - idx - lenOld); memcpy(_s->cString + idx, buffer, lenNew); _s->cStringLength -= lenOld; _s->cStringLength += lenNew; _s->cString[_s->cStringLength] = '\0'; if (character >= 0x80) _s->isUTF8 = true; |
︙ | ︙ | |||
506 507 508 509 510 511 512 | /* UTF-8 does not allow more than 4 bytes per character */ @throw [OFInvalidEncodingException exception]; } } - (void)insertString: (OFString *)string | | | | | | | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | /* UTF-8 does not allow more than 4 bytes per character */ @throw [OFInvalidEncodingException exception]; } } - (void)insertString: (OFString *)string atIndex: (size_t)idx { size_t newCStringLength; if (idx > _s->length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength); newCStringLength = _s->cStringLength + [string UTF8StringLength]; _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: newCStringLength + 1]; memmove(_s->cString + idx + [string UTF8StringLength], _s->cString + idx, _s->cStringLength - idx); memcpy(_s->cString + idx, [string UTF8String], [string UTF8StringLength]); _s->cString[newCStringLength] = '\0'; _s->cStringLength = newCStringLength; _s->length += [string length]; if ([string isKindOfClass: [OFString_UTF8 class]] || |
︙ | ︙ |