Overview
Comment: | OFString+XMLUnescaping: Get rid of -[appendCStringWithoutUTF8Checking:].
-[appendCStringWithoutUTF8Checking:] will be removed soon, as it is |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
898c2a781bbaabe24a1d269d079adeb0 |
User & Date: | js on 2011-07-09 13:29:03 |
Other Links: | manifest | tags |
Context
2011-07-09
| ||
13:33 | Get rid of -[appendCStringWithoutUTF8Checking:] in base64.m. check-in: 56c98bf847 user: js tags: trunk | |
13:29 | OFString+XMLUnescaping: Get rid of -[appendCStringWithoutUTF8Checking:]. check-in: 898c2a781b user: js tags: trunk | |
13:15 | Use OFDataArray instead of OFMutableString in OFXMLElement. check-in: a2c6391204 user: js tags: trunk | |
Changes
Modified src/OFString+XMLUnescaping.m from [55d286875d] to [f26dc131a5].
︙ | ︙ | |||
90 91 92 93 94 95 96 | OFMutableString *ret; string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; | < < < < < < < | | | | | | | | | | | | | 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 | OFMutableString *ret; string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; last = 0; inEntity = NO; for (i = 0; i < length; i++) { if (!inEntity && string[i] == '&') { [ret appendCString: string + last withLength: i - last]; last = i + 1; inEntity = YES; } else if (inEntity && string[i] == ';') { const char *entity = string + last; size_t entityLength = i - last; if (entityLength == 2 && !memcmp(entity, "lt", 2)) [ret appendCString: "<" withLength: 1]; else if (entityLength == 2 && !memcmp(entity, "gt", 2)) [ret appendCString: ">" withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "quot", 4)) [ret appendCString: "\"" withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "apos", 4)) [ret appendCString: "'" withLength: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withLength: 1]; else if (entity[0] == '#') { OFAutoreleasePool *pool; OFString *tmp; pool = [[OFAutoreleasePool alloc] init]; tmp = parse_numeric_entity(entity, entityLength); |
︙ | ︙ | |||
171 172 173 174 175 176 177 | inEntity = NO; } } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; | | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | inEntity = NO; } } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; [ret appendCString: string + last withLength: i - last]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; |
︙ | ︙ | |||
197 198 199 200 201 202 203 | OFMutableString *ret; string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; | < < < < < < < | | | | | | | | | | | | | 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 | OFMutableString *ret; string = [self cString]; length = [self cStringLength]; ret = [OFMutableString string]; last = 0; inEntity = NO; for (i = 0; i < length; i++) { if (!inEntity && string[i] == '&') { [ret appendCString: string + last withLength: i - last]; last = i + 1; inEntity = YES; } else if (inEntity && string[i] == ';') { const char *entity = string + last; size_t entityLength = i - last; if (entityLength == 2 && !memcmp(entity, "lt", 2)) [ret appendCString: "<" withLength: 1]; else if (entityLength == 2 && !memcmp(entity, "gt", 2)) [ret appendCString: ">" withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "quot", 4)) [ret appendCString: "\"" withLength: 1]; else if (entityLength == 4 && !memcmp(entity, "apos", 4)) [ret appendCString: "'" withLength: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withLength: 1]; else if (entity[0] == '#') { OFAutoreleasePool *pool; OFString *tmp; pool = [[OFAutoreleasePool alloc] init]; tmp = parse_numeric_entity(entity, entityLength); |
︙ | ︙ | |||
276 277 278 279 280 281 282 | inEntity = NO; } } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; | | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | inEntity = NO; } } if (inEntity) @throw [OFInvalidEncodingException newWithClass: isa]; [ret appendCString: string + last withLength: i - last]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; return ret; } #endif @end |