Overview
Comment: | Fix -[initWithUTF8StringNoCopy:freeWhenDone:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c16e6aca5600d1b80d75b639d0713794 |
User & Date: | js on 2012-12-30 00:22:55 |
Other Links: | manifest | tags |
Context
2013-01-02
| ||
21:07 | sparsearray.m: Cast to 32 bit before shifting. check-in: 74e605a0f1 user: js tags: trunk | |
2012-12-30
| ||
00:22 | Fix -[initWithUTF8StringNoCopy:freeWhenDone:]. check-in: c16e6aca56 user: js tags: trunk | |
00:19 | -[performSelector:]: Never call NULL. check-in: 0389649320 user: js tags: trunk | |
Changes
Modified src/OFMutableString_UTF8.m from [e81ab65f1c] to [c46f09aef2].
︙ | ︙ | |||
40 41 42 43 44 45 46 | @implementation OFMutableString_UTF8 + (void)initialize { if (self == [OFMutableString_UTF8 class]) [self inheritMethodsFromClass: [OFString_UTF8 class]]; } | | > | > > > > > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | @implementation OFMutableString_UTF8 + (void)initialize { if (self == [OFMutableString_UTF8 class]) [self inheritMethodsFromClass: [OFString_UTF8 class]]; } - initWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { @try { self = [self initWithUTF8String: UTF8String]; } @finally { if (freeWhenDone) free(UTF8String); } return self; } - (void)OF_convertWithWordStartTable: (const of_unichar_t *const[])startTable wordMiddleTable: (const of_unichar_t *const[])middleTable wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { |
︙ | ︙ |
Modified src/OFString.h from [05df72695a] to [931dc2b046].
︙ | ︙ | |||
99 100 101 102 103 104 105 | * the string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when the OFString gets * deallocated * @return A new autoreleased OFString */ | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | * the string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when the OFString gets * deallocated * @return A new autoreleased OFString */ + (instancetype)stringWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone; /*! * @brief Creates a new OFString from a C string with the specified encoding. * * @param cString A C string to initialize the OFString with * @param encoding The encoding of the C string |
︙ | ︙ | |||
277 278 279 280 281 282 283 | * @note Mutable versions always create a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when it is not needed * anymore * @return An initialized OFString */ | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | * @note Mutable versions always create a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when it is not needed * anymore * @return An initialized OFString */ - initWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone; /*! * @brief Initializes an already allocated OFString from a C string with the * specified encoding. * * @param cString A C string to initialize the OFString with |
︙ | ︙ |
Modified src/OFString.m from [2366afaf49] to [e59e2f0949].
︙ | ︙ | |||
226 227 228 229 230 231 232 | UTF8StringLength + 1, 1, &storage); return (id)[string OF_initWithUTF8String: UTF8String length: UTF8StringLength storage: storage]; } | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | UTF8StringLength + 1, 1, &storage); return (id)[string OF_initWithUTF8String: UTF8String length: UTF8StringLength storage: storage]; } - initWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { return (id)[[OFString_UTF8 alloc] initWithUTF8StringNoCopy: UTF8String freeWhenDone: freeWhenDone]; } |
︙ | ︙ | |||
439 440 441 442 443 444 445 | length: (size_t)UTF8StringLength { return [[[self alloc] initWithUTF8String: UTF8String length: UTF8StringLength] autorelease]; } | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | length: (size_t)UTF8StringLength { return [[[self alloc] initWithUTF8String: UTF8String length: UTF8StringLength] autorelease]; } + (instancetype)stringWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { return [[[self alloc] initWithUTF8StringNoCopy: UTF8String freeWhenDone: freeWhenDone] autorelease]; } |
︙ | ︙ | |||
580 581 582 583 584 585 586 | length: (size_t)UTF8StringLength { return [self initWithCString: UTF8String encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } | | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | length: (size_t)UTF8StringLength { return [self initWithCString: UTF8String encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - initWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { return [self initWithUTF8String: UTF8String]; } - initWithCString: (const char*)cString encoding: (of_string_encoding_t)encoding |
︙ | ︙ |
Modified src/OFString_UTF8.m from [797a478d4d] to [0ddb5e507a].
︙ | ︙ | |||
332 333 334 335 336 337 338 | [self release]; @throw e; } return self; } | | | < | | | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | [self release]; @throw e; } return self; } - initWithUTF8StringNoCopy: (char*)UTF8String freeWhenDone: (BOOL)freeWhenDone { self = [super init]; @try { size_t UTF8StringLength = strlen(UTF8String); if (UTF8StringLength >= 3 && !memcmp(UTF8String, "\xEF\xBB\xBF", 3)) { UTF8String += 3; UTF8StringLength -= 3; } s = &s_store; s->cString = (char*)UTF8String; s->cStringLength = UTF8StringLength; if (freeWhenDone) s->freeWhenDone = UTF8String; switch (of_string_utf8_check(UTF8String, UTF8StringLength, &s->length)) { case 1: s->isUTF8 = YES; break; case -1: |
︙ | ︙ |