Overview
Comment: | OFString+XMLUnescaping.m: Remove code duplication |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f0cc196adc09989339fb9d23bfac0cfc |
User & Date: | js on 2014-04-14 01:11:01 |
Other Links: | manifest | tags |
Context
2014-04-14
| ||
09:37 | Fix unused variable warning with --disable-files check-in: cac74a9513 user: js tags: trunk | |
01:11 | OFString+XMLUnescaping.m: Remove code duplication check-in: f0cc196adc user: js tags: trunk | |
00:45 | Coding style check-in: 9da9b2b64c user: js tags: trunk | |
Changes
Modified src/OFString+XMLUnescaping.m from [654beb3068] to [9ce8dfa504].
︙ | ︙ | |||
71 72 73 74 75 76 77 | return nil; buffer[i] = 0; return [OFString stringWithUTF8String: buffer length: i]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | return nil; buffer[i] = 0; return [OFString stringWithUTF8String: buffer length: i]; } static OFString* parseEntities(OFString *self, id (*lookup)(void*, OFString*, OFString*), void *context) { const char *string; size_t i, last, length; bool inEntity; OFMutableString *ret; string = [self UTF8String]; |
︙ | ︙ | |||
247 248 249 250 251 252 253 | @throw [OFInvalidFormatException exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else { void *pool; | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | @throw [OFInvalidFormatException exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else { void *pool; OFString *name, *tmp; pool = objc_autoreleasePoolPush(); name = [OFString stringWithUTF8String: entity length: entityLength]; tmp = lookup(context, self, name); if (tmp == nil) @throw [OFInvalidFormatException exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
279 280 281 282 283 284 285 286 287 | [ret appendUTF8String: string + last length: i - last]; [ret makeImmutable]; return ret; } #endif @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 171 172 173 174 175 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 | [ret appendUTF8String: string + last length: i - last]; [ret makeImmutable]; return ret; } static id lookupUsingDelegate(void *context, OFString *self, OFString *entity) { id <OFStringXMLUnescapingDelegate> delegate = context; if (delegate == nil) return nil; return [delegate string: self containsUnknownEntityNamed: entity]; } #ifdef OF_HAVE_BLOCKS static id lookupUsingBlock(void *context, OFString *self, OFString *entity) { of_string_xml_unescaping_block_t block = context; if (block == NULL) return nil; return block(self, entity); } #endif @implementation OFString (XMLUnescaping) - (OFString*)stringByXMLUnescaping { return [self stringByXMLUnescapingWithDelegate: nil]; } - (OFString*)stringByXMLUnescapingWithDelegate: (id <OFStringXMLUnescapingDelegate>)delegate { return parseEntities(self, lookupUsingDelegate, delegate); } #ifdef OF_HAVE_BLOCKS - (OFString*)stringByXMLUnescapingWithBlock: (of_string_xml_unescaping_block_t)block { return parseEntities(self, lookupUsingBlock, block); } #endif @end |