Overview
Comment: | Style improvements. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d13ff5382a8feb646f6b44c5a8453f21 |
User & Date: | js on 2011-06-27 00:10:07 |
Other Links: | manifest | tags |
Context
2011-06-27
| ||
23:44 | Add -[elements] and -[elementsForNamespace:] to OFXMLElement. check-in: 9b1baaa39b user: js tags: trunk | |
00:10 | Style improvements. check-in: d13ff5382a user: js tags: trunk | |
2011-06-26
| ||
23:54 | Add -[{decimal,hexadecimal,float,double}Value] to OFXMLAttribute. check-in: 0952a96827 user: js tags: trunk | |
Changes
Modified src/OFDataArray.m from [14e7076f02] to [57d47bf4a5].
︙ | ︙ | |||
99 100 101 102 103 104 105 | self = [super init]; @try { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; itemSize = 1; | < | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | self = [super init]; @try { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; itemSize = 1; @try { char *buffer = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { size_t length; |
︙ | ︙ | |||
162 163 164 165 166 167 168 | } - initWithBase64EncodedString: (OFString*)string { self = [super init]; itemSize = 1; | < | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | } - initWithBase64EncodedString: (OFString*)string { self = [super init]; itemSize = 1; if (!of_base64_decode(self, [string cString], [string cStringLength])) { Class c = isa; [self release]; @throw [OFInvalidEncodingException newWithClass: c]; } |
︙ | ︙ |
Modified src/base64.m from [31c95b71a3] to [5c26d78d7f].
︙ | ︙ | |||
36 37 38 39 40 41 42 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 }; OFString* | | | | | | | | | | 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 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 }; OFString* of_base64_encode(const char *data, size_t length) { OFMutableString *ret = [OFMutableString string]; uint8_t *buffer = (uint8_t*)data; size_t i; uint8_t rest; char tb[4]; uint32_t sb; rest = length % 3; for (i = 0; i < length - rest; i += 3) { sb = (buffer[i] << 16) | (buffer[i + 1] << 8) | buffer[i + 2]; tb[0] = of_base64_encode_table[(sb & 0xFC0000) >> 18]; tb[1] = of_base64_encode_table[(sb & 0x03F000) >> 12]; tb[2] = of_base64_encode_table[(sb & 0x000FC0) >> 6]; tb[3] = of_base64_encode_table[sb & 0x00003F]; [ret appendCStringWithoutUTF8Checking: tb length: 4]; } switch (rest) { case 1: tb[0] = of_base64_encode_table[buffer[i] >> 2]; tb[1] = of_base64_encode_table[(buffer[i] & 3) << 4]; tb[2] = tb[3] = '='; [ret appendCStringWithoutUTF8Checking: tb length: 4]; break; case 2: sb = (buffer[i] << 16) | (buffer[i + 1] << 8); tb[0] = of_base64_encode_table[(sb & 0xFC0000) >> 18]; tb[1] = of_base64_encode_table[(sb & 0x03F000) >> 12]; tb[2] = of_base64_encode_table[(sb & 0x000FC0) >> 6]; tb[3] = '='; [ret appendCStringWithoutUTF8Checking: tb |
︙ | ︙ | |||
93 94 95 96 97 98 99 | * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; return ret; } BOOL | | | | | | | | | | | | | | | | 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; return ret; } BOOL of_base64_decode(OFDataArray *data, const char *string, size_t length) { const uint8_t *buffer = (const uint8_t*)string; size_t i; if ((length & 3) != 0) return NO; if ([data itemSize] != 1) return NO; for (i = 0; i < length; i += 4) { uint32_t sb = 0; uint8_t count = 3; char db[3]; char tmp; if (buffer[i] > 0x7F || buffer[i + 1] > 0x7F || buffer[i + 2] > 0x7F || buffer[i + 3] > 0x7F) return NO; if (buffer[i] == '=' || buffer[i + 1] == '=' || (buffer[i + 2] == '=' && buffer[i + 3] != '=')) return NO; if (buffer[i + 2] == '=') count--; if (buffer[i + 3] == '=') count--; if ((tmp = of_base64_decode_table[buffer[i]]) == -1) return NO; sb |= tmp << 18; if ((tmp = of_base64_decode_table[buffer[i + 1]]) == -1) return NO; sb |= tmp << 12; if ((tmp = of_base64_decode_table[buffer[i + 2]]) == -1) return NO; sb |= tmp << 6; if ((tmp = of_base64_decode_table[buffer[i + 3]]) == -1) return NO; sb |= tmp; db[0] = (sb & 0xFF0000) >> 16; db[1] = (sb & 0x00FF00) >> 8; db[2] = sb & 0x0000FF; |
︙ | ︙ |