Overview
Comment: | OFMutableString's -[upper] and -[lower]: Get rid of code duplication. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8389241a055d3fecfc8f6b4354abaf2e |
User & Date: | js on 2009-10-16 08:44:46 |
Other Links: | manifest | tags |
Context
2009-10-16
| ||
10:46 | Implement -[hash] for OFArray. check-in: deea33a4d9 user: js tags: trunk | |
08:44 | OFMutableString's -[upper] and -[lower]: Get rid of code duplication. check-in: 8389241a05 user: js tags: trunk | |
2009-10-15
| ||
20:38 | Full Unicode support for OFMutableString's -[upper] and -[lower]. check-in: 0480a27d5e user: js tags: trunk | |
Changes
Modified src/Makefile from [58a18bd0f1] to [2b51a81e8b].
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | - - + | objfw.h \ threading.h SRCS += ${OBJC_SYNC_M} \ ${ASPRINTF_C} \ iso_8859_15.c \ windows_1252.c \ |
Modified src/OFMutableString.m from [faf789896c] to [feeaa349e9].
︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 28 29 30 31 32 33 34 35 36 37 38 39 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #import "OFExceptions.h" #import "OFMacros.h" #import "asprintf.h" extern const of_unichar_t* const of_unicode_upper_table[0x1100]; extern const of_unichar_t* const of_unicode_lower_table[0x1100]; static void apply_table(id self, Class isa, char **string, unsigned int *length, BOOL is_utf8, const of_unichar_t* const table[]) { of_unichar_t c, tc; of_unichar_t *ustr; size_t ulen, nlen; size_t i, j, d; char *nstr; if (!is_utf8) { uint8_t *p = (uint8_t*)*string + *length; uint8_t t; while (--p >= (uint8_t*)*string) { t = table[0][*p]; if (t != 0) *p = t; } return; } ulen = [self length]; ustr = [self allocMemoryForNItems: [self length] withSize: ulen]; j = 0; nlen = 0; for (i = 0; i < *length; i++) { c = of_string_utf8_to_unicode(*string + i, *length - i); if (c == OF_INVALID_UNICHAR || c > 0x10FFFF) { [self freeMemory: ustr]; @throw [OFInvalidEncodingException newWithClass: isa]; } if ((tc = table[c >> 8][c & 0xFF]) == 0) tc = c; ustr[j++] = tc; if (tc < 0x80) nlen++; else if (tc < 0x800) nlen += 2; else if (tc < 0x10000) nlen += 3; else if (tc < 0x110000) nlen += 4; else { [self freeMemory: ustr]; @throw [OFInvalidEncodingException newWithClass: isa]; } if (c < 0x80); else if (c < 0x800) i++; else if (c < 0x10000) i += 2; else if (c < 0x110000) i += 3; else { [self freeMemory: ustr]; @throw [OFInvalidEncodingException newWithClass: isa]; } } @try { nstr = [self allocMemoryWithSize: nlen + 1]; } @catch (OFException *e) { [self freeMemory: ustr]; @throw e; } j = 0; for (i = 0; i < ulen; i++) { if ((d = of_string_unicode_to_utf8(ustr[i], nstr + j)) == 0) { [self freeMemory: ustr]; [self freeMemory: nstr]; @throw [OFInvalidEncodingException newWithClass: isa]; } j += d; } assert(j == nlen); nstr[j] = 0; [self freeMemory: ustr]; [self freeMemory: *string]; *string = nstr; *length = nlen; } @implementation OFMutableString - setToCString: (const char*)str { size_t len; if (string != NULL) |
︙ | |||
275 276 277 278 279 280 281 | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | - - - - - - + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | madvise(string, len, MADV_NORMAL); return self; } - upper { |
︙ |
Modified src/OFString.h from [0ac3d63fc6] to [72b442269e].
︙ | |||
34 35 36 37 38 39 40 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | - - - - + - | /** * A class for managing strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying> { char *string; |
︙ |