Differences From Artifact [db5fef86d0]:
- File
src/OFINICategory.m
— part of check-in
[48980f2297]
at
2015-11-29 11:43:05
on branch trunk
— Make properties a requirement and clean up code
This increases the required GCC version from 4.0 to 4.6 (exception:
Apple GCC, which already supports this with >= 4.0 starting with OS X
10.5). Since even GCC 4.6 is really old by now, there is no point in
still supporting something even older and making the code ugly because
of that. While some hardware and OS support was dropped from GCC 4.6
compared to GCC 4.0, there is nothing in there that would be an
interesting target with the exception of BeOS maybe - but a port to BeOS
can also be achieved using the Haiku support. The other dropped OSes are
mostly old versions of OSes while newer ones are still being supported
(and those newer versions of those OSes still support the same
hardware). (user: js, size: 11290) [annotate] [blame] [check-ins using]
To Artifact [ab1f7455cf]:
- File
src/OFINICategory.m
— part of check-in
[6b13727ce0]
at
2015-11-29 14:02:11
on branch trunk
— Make use of fast enumeration
Now that we require GCC >= 4.6 anyway, there's no more reason to not use
it anymore. (user: js, size: 10807) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
188 189 190 191 192 193 194 | return [self stringForKey: key defaultValue: nil]; } - (OFString*)stringForKey: (OFString*)key defaultValue: (OFString*)defaultValue { | < < | < < | | | < < < < < < < | 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 | return [self stringForKey: key defaultValue: nil]; } - (OFString*)stringForKey: (OFString*)key defaultValue: (OFString*)defaultValue { for (id line in _lines) { OFINICategory_Pair *pair; if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; if ([pair->_key isEqual: key]) return [[pair->_value copy] autorelease]; } return defaultValue; } - (intmax_t)integerForKey: (OFString*)key defaultValue: (intmax_t)defaultValue { |
︙ | ︙ | |||
298 299 300 301 302 303 304 | return ret; } - (OFArray*)arrayForKey: (OFString*)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); | < < | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | return ret; } - (OFArray*)arrayForKey: (OFString*)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { OFINICategory_Pair *pair; if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; |
︙ | ︙ | |||
324 325 326 327 328 329 330 | return ret; } - (void)setString: (OFString*)string forKey: (OFString*)key { void *pool = objc_autoreleasePoolPush(); | < < | > > > > | | | > > > > > > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 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 | return ret; } - (void)setString: (OFString*)string forKey: (OFString*)key { void *pool = objc_autoreleasePoolPush(); OFINICategory_Pair *pair; for (id line in _lines) { if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; if ([pair->_key isEqual: key]) { OFString *old = pair->_value; pair->_value = [string copy]; [old release]; objc_autoreleasePoolPop(pool); return; } } pair = [[[OFINICategory_Pair alloc] init] autorelease]; pair->_key = nil; pair->_value = nil; @try { pair->_key = [key copy]; pair->_value = [string copy]; [_lines addObject: pair]; } @catch (id e) { [pair->_key release]; [pair->_value release]; @throw e; } objc_autoreleasePoolPop(pool); } - (void)setInteger: (intmax_t)integer forKey: (OFString*)key { |
︙ | ︙ | |||
397 398 399 400 401 402 403 | objc_autoreleasePoolPop(pool); } - (void)setArray: (OFArray*)array forKey: (OFString*)key { void *pool; | < < < | | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | objc_autoreleasePoolPop(pool); } - (void)setArray: (OFArray*)array forKey: (OFString*)key { void *pool; OFMutableArray *pairs; id const *lines; size_t i, count; bool replaced; if ([array count] == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); pairs = [OFMutableArray arrayWithCapacity: [array count]]; for (id object in array) { OFINICategory_Pair *pair; if (![object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategory_Pair alloc] init] autorelease]; pair->_key = [key copy]; |
︙ | ︙ | |||
497 498 499 500 501 502 503 | objc_autoreleasePoolPop(pool); } - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first { | < < < | < | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | objc_autoreleasePoolPop(pool); } - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first { if ([_lines count] == 0) return false; if (first) [stream writeFormat: @"[%@]\n", _name]; else [stream writeFormat: @"\n[%@]\n", _name]; for (id line in _lines) { if ([line isKindOfClass: [OFINICategory_Comment class]]) { OFINICategory_Comment *comment = line; [stream writeLine: comment->_comment]; } else if ([line isKindOfClass: [OFINICategory_Pair class]]) { OFINICategory_Pair *pair = line; OFString *key = escapeString(pair->_key); OFString *value = escapeString(pair->_value); |
︙ | ︙ |