ObjFW  Check-in [d0eace5cd1]

Overview
Comment:Use %@ where it is useful.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d0eace5cd11fa77736e42a0f557242797d2cf4430139b5c03c140a4420de8975
User & Date: js on 2011-01-29 19:16:18
Other Links: manifest | tags
Context
2011-01-30
00:24
Allow nil for %@. check-in: e9c2c2c599 user: js tags: trunk
2011-01-29
19:16
Use %@ where it is useful. check-in: d0eace5cd1 user: js tags: trunk
19:01
Add of_asprintf and allow %@ in format strings. check-in: 4c4608fbba user: js tags: trunk
Changes

Modified src/OFApplication.m from [c5833c27ef] to [b6ae30499e].

115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129







-
+







		for (; *env != NULL; env++) {
			OFString *key;
			OFString *value;
			char *sep;

			if ((sep = strchr(*env, '=')) == NULL) {
				fprintf(stderr, "Warning: Invalid environment "
					       "variable: %s\n", *env);
				    "variable: %s\n", *env);
				continue;
			}

			key = [OFString stringWithCString: *env
						   length: sep - *env];
			value = [OFString stringWithCString: sep + 1];
			[environment setObject: value

Modified src/OFExceptions.m from [ff08f95514] to [2044606b5e].

496
497
498
499
500
501
502
503
504


505
506
507
508
509
510
511
496
497
498
499
500
501
502


503
504
505
506
507
508
509
510
511







-
-
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to open file %s with mode %s in class %s! " ERRFMT,
	    [path cString], [mode cString], class_getName(inClass), ERRPARAM];
	    @"Failed to open file %@ with mode %@ in class %s! " ERRFMT, path,
	    mode, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
661
662
663
664
665
666
667
668
669


670
671
672
673
674
675
676
661
662
663
664
665
666
667


668
669
670
671
672
673
674
675
676







-
-
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to create directory %s in class %s! " ERRFMT,
	    [path cString], class_getName(inClass), ERRPARAM];
	    @"Failed to create directory %@ in class %s! " ERRFMT, path,
	    class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
723
724
725
726
727
728
729
730
731


732
733
734
735
736
737
738
723
724
725
726
727
728
729


730
731
732
733
734
735
736
737
738







-
-
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to change to directory %s in class %s! " ERRFMT,
	    [path cString], class_getName(inClass), ERRPARAM];
	    @"Failed to change to directory %@ in class %s! " ERRFMT, path,
	    class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
790
791
792
793
794
795
796
797
798


799
800
801
802
803
804
805
790
791
792
793
794
795
796


797
798
799
800
801
802
803
804
805







-
-
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to change mode for file %s to %d in class %s! " ERRFMT,
	    [path cString], mode, class_getName(inClass), ERRPARAM];
	    @"Failed to change mode for file %@ to %d in class %s! " ERRFMT,
	    path, mode, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
869
870
871
872
873
874
875
876

877
878

879
880
881

882
883

884
885
886
887
888



889
890
891
892
893
894
895
869
870
871
872
873
874
875

876


877
878
879

880


881
882
883



884
885
886
887
888
889
890
891
892
893







-
+
-
-
+


-
+
-
-
+


-
-
-
+
+
+







- (OFString*)description
{
	if (description != nil)
		return description;

	if (group == nil)
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %s to %s in class %s! "
		    @"Failed to change owner for file %@ to %@ in class %s! "
		    ERRFMT, [path cString], [owner cString],
		    class_getName(inClass), ERRPARAM];
		    ERRFMT, path, owner, class_getName(inClass), ERRPARAM];
	else if (owner == nil)
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change group for file %s to %s in class %s! "
		    @"Failed to change group for file %@ to %@ in class %s! "
		    ERRFMT, [path cString], [group cString],
		    class_getName(inClass), ERRPARAM];
		    ERRFMT, path, group, class_getName(inClass), ERRPARAM];
	else
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %s to %s:%s in class %s! "
		    ERRFMT, [path cString], [owner cString], [group cString],
		    class_getName(inClass), ERRPARAM];
		    @"Failed to change owner for file %@ to %@:%@ in class %s! "
		    ERRFMT, path, owner, group, class_getName(inClass),
		    ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
958
959
960
961
962
963
964
965

966
967

968
969
970
971
972
973
974
956
957
958
959
960
961
962

963


964
965
966
967
968
969
970
971







-
+
-
-
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to copy file %s to %s in class %s! " ERRFMT,
	    @"Failed to copy file %@ to %@ in class %s! " ERRFMT,
	    [sourcePath cString], [destinationPath cString],
	    class_getName(inClass), ERRPARAM];
	    sourcePath, destinationPath, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1031
1032
1033
1034
1035
1036
1037
1038

1039
1040

1041
1042
1043
1044
1045
1046
1047
1028
1029
1030
1031
1032
1033
1034

1035


1036
1037
1038
1039
1040
1041
1042
1043







-
+
-
-
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to rename file %s to %s in class %s! " ERRFMT,
	    @"Failed to rename file %@ to %@ in class %s! " ERRFMT, sourcePath,
	    [sourcePath cString], [destinationPath cString],
	    class_getName(inClass), ERRPARAM];
	    destinationPath, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1099
1100
1101
1102
1103
1104
1105
1106

1107
1108
1109
1110
1111
1112
1113
1095
1096
1097
1098
1099
1100
1101

1102
1103
1104
1105
1106
1107
1108
1109







-
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to delete file %s in class %s! " ERRFMT, [path cString],
	    @"Failed to delete file %@ in class %@! " ERRFMT, path,
	    class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
1161
1162
1163
1164
1165
1166
1167
1168
1169


1170
1171
1172
1173
1174
1175
1176
1157
1158
1159
1160
1161
1162
1163


1164
1165
1166
1167
1168
1169
1170
1171
1172







-
-
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to delete directory %s in class %s! " ERRFMT,
	    [path cString], class_getName(inClass), ERRPARAM];
	    @"Failed to delete directory %@ in class %@! " ERRFMT, path,
	    class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1224
1225
1226
1227
1228
1229
1230
1231

1232
1233

1234
1235
1236
1237
1238
1239
1240
1220
1221
1222
1223
1224
1225
1226

1227


1228
1229
1230
1231
1232
1233
1234
1235







-
+
-
-
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to link file %s to %s in class %s! " ERRFMT,
	    @"Failed to link file %@ to %@ in class %s! " ERRFMT, sourcePath,
	    [sourcePath cString], [destinationPath cString],
	    class_getName(inClass), ERRPARAM];
	    destinationPath, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1292
1293
1294
1295
1296
1297
1298
1299

1300
1301

1302
1303
1304
1305
1306
1307
1308
1287
1288
1289
1290
1291
1292
1293

1294


1295
1296
1297
1298
1299
1300
1301
1302







-
+
-
-
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Failed to symlink file %s to %s in class %s! " ERRFMT,
	    @"Failed to symlink file %@ to %@ in class %s! " ERRFMT, sourcePath,
	    [sourcePath cString], [destinationPath cString],
	    class_getName(inClass), ERRPARAM];
	    destinationPath, class_getName(inClass), ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1409
1410
1411
1412
1413
1414
1415
1416

1417
1418
1419
1420
1421
1422


1423
1424
1425
1426
1427
1428
1429
1403
1404
1405
1406
1407
1408
1409

1410
1411
1412
1413
1414


1415
1416
1417
1418
1419
1420
1421
1422
1423







-
+




-
-
+
+







- (OFString*)description
{
	if (description != nil)
		return description;

	if (node != nil && service != nil)
		description = [[OFString alloc] initWithFormat:
		    @"The service %s on %s could not be translated to an "
		    @"The service %@ on %@ could not be translated to an "
		    @"address in class %s. This means that either the node was "
		    @"not found, there is no such service on the node, there "
		    @"was a problem with the name server, there was a problem "
		    @"with your network connection or you specified an invalid "
		    @"node or service. " ERRFMT, [service cString],
		    [node cString], class_getName(inClass), AT_ERRPARAM];
		    @"node or service. " ERRFMT, service, node,
		    class_getName(inClass), AT_ERRPARAM];
	else
		description = [[OFString alloc] initWithFormat:
		    @"An address translation failed in class %s! " ERRFMT,
		    class_getName(inClass), AT_ERRPARAM];

	return description;
}
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499



1500
1501
1502
1503
1504
1505
1506
1484
1485
1486
1487
1488
1489
1490



1491
1492
1493
1494
1495
1496
1497
1498
1499
1500







-
-
-
+
+
+








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"A connection to service %s on node %s could not be established "
	    @"in class %s! " ERRFMT, [service cString], [node cString],
	    class_getName(inClass), ERRPARAM];
	    @"A connection to service %@ on node %@ could not be established "
	    @"in class %s! " ERRFMT, service, node, class_getName(inClass),
	    ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1563
1564
1565
1566
1567
1568
1569
1570
1571


1572
1573
1574
1575
1576
1577
1578
1579
1557
1558
1559
1560
1561
1562
1563


1564
1565

1566
1567
1568
1569
1570
1571
1572







-
-
+
+
-








- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Binding service %s on node %s failed in class %s! " ERRFMT,
	    [service cString], [node cString], class_getName(inClass),
	    @"Binding service %@ on node %@ failed in class %s! " ERRFMT,
	    service, node, class_getName(inClass), ERRPARAM];
	    ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
1814
1815
1816
1817
1818
1819
1820
1821

1822
1823
1824
1825
1826


1827
1828
1829
1830
1831
1832
1833
1807
1808
1809
1810
1811
1812
1813

1814
1815
1816
1817


1818
1819
1820
1821
1822
1823
1824
1825
1826







-
+



-
-
+
+







- (OFString*)description
{
	if (description != nil)
		return description;

	if (ns != nil)
		description = [[OFString alloc] initWithFormat:
		    @"The namespace %s is not bound in class %s",
		    @"The namespace %@ is not bound in class %s", ns,
		    class_getName(inClass)];
	else if (prefix != nil)
		description = [[OFString alloc] initWithFormat:
		    @"The prefix %s is not bound to any namespace in %s",
		    class_getName(inClass)];
		    @"The prefix %@ is not bound to any namespace in %s",
		    prefix, class_getName(inClass)];

	return description;
}

- (OFString*)namespace
{
	return ns;
1879
1880
1881
1882
1883
1884
1885
1886
1887


1888
1889
1890
1891
1892
1893
1894
1895
1896
1872
1873
1874
1875
1876
1877
1878


1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889







-
-
+
+










- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"The protocol of URL %s is not supported by class %s",
	    [[URL description] cString], class_getName(inClass)];
	    @"The protocol of URL %@ is not supported by class %s", URL,
	    class_getName(inClass)];

	return description;
}

- (OFURL*)URL
{
	return URL;
}
@end

Modified src/OFObject.m from [a02b47cd7d] to [a091595654].

487
488
489
490
491
492
493
494

495
496
497
498
499
500
501
502
487
488
489
490
491
492
493

494

495
496
497
498
499
500
501







-
+
-







	/* Classes containing data should reimplement this! */
	return (uint32_t)(uintptr_t)self;
}

- (OFString*)description
{
	/* Classes containing data should reimplement this! */
	return [OFString stringWithFormat: @"<%s: %p>",
	return [OFString stringWithFormat: @"<%@: %p>", [self className], self];
					   [[self className] cString], self];
}

- (void)addMemoryToPool: (void*)ptr
{
	void **memchunks;
	size_t memchunks_size;

Modified src/OFURL.m from [84444b80b2] to [8d89f1d113].

349
350
351
352
353
354
355
356
357


358
359
360
361

362
363
364

365
366
367
368
369
370
371
372
373
374
375
376

377
378
379

380
381
382

383
384
385

386
387
388
389
349
350
351
352
353
354
355


356
357
358
359
360

361

362

363
364
365
366
367
368
369
370
371
372
373
374

375
376
377

378
379
380

381
382
383

384
385
386
387
388







-
-
+
+



-
+
-

-
+











-
+


-
+


-
+


-
+




	OFString *old = fragment;
	fragment = [fragment_ copy];
	[old release];
}

- (OFString*)description
{
	OFMutableString *desc = [OFMutableString
	    stringWithFormat: @"%s://", [scheme cString]];
	OFMutableString *desc = [OFMutableString stringWithFormat: @"%@://",
								   scheme];
	BOOL needPort = YES;

	if (user != nil && password != nil)
		[desc appendFormat: @"%s:%s@", [user cString],
		[desc appendFormat: @"%@:%@@", user, password];
				    [password cString]];
	else if (user != nil)
		[desc appendFormat: @"%s@", [user cString]];
		[desc appendFormat: @"%@@", user];

	[desc appendString: host];

	if (([scheme isEqual: @"http"] && port == 80) ||
	    ([scheme isEqual: @"https"] && port == 443))
		needPort = NO;

	if (needPort)
		[desc appendFormat: @":%d", port];

	if (path != nil)
		[desc appendFormat: @"/%s", [path cString]];
		[desc appendFormat: @"/%@", path];

	if (parameters != nil)
		[desc appendFormat: @";%s", [parameters cString]];
		[desc appendFormat: @";%@", parameters];

	if (query != nil)
		[desc appendFormat: @"?%s", [query cString]];
		[desc appendFormat: @"?%@", query];

	if (fragment != nil)
		[desc appendFormat: @"#%s", [fragment cString]];
		[desc appendFormat: @"#%@", fragment];

	return desc;
}
@end

Modified src/OFXMLElement.m from [866cd32b8c] to [d813f718a7].

207
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222
207
208
209
210
211
212
213

214

215
216
217
218
219
220
221







-
+
-







	OFMutableDictionary *all_namespaces;
	OFString *def_ns;

	if (characters != nil)
		return [characters stringByXMLEscaping];

	if (cdata != nil)
		return [OFString stringWithFormat: @"<![CDATA[%s]]>",
		return [OFString stringWithFormat: @"<![CDATA[%@]]>", cdata];
						   [cdata cString]];

	if (comment != nil) {
		OFMutableString *str;

		str = [OFMutableString stringWithString: @"<!--"];
		[str appendString: comment];
		[str appendString: @"-->"];

Modified src/OFXMLParser.m from [8fc69896c1] to [c1d0bcacb5].

586
587
588
589
590
591
592
593
594


595
596
597
598
599
600
601
602
586
587
588
589
590
591
592


593
594

595
596
597
598
599
600
601







-
-
+
+
-







			[delegate parser: self
			   didEndElement: name
			      withPrefix: prefix
			       namespace: ns];

		[namespaces removeNObjects: 1];
	} else if (prefix != nil) {
		OFString *str = [OFString stringWithFormat: @"%s:%s",
							    [prefix cString],
		OFString *str = [OFString stringWithFormat: @"%@:%@",
							    prefix, name];
							    [name cString]];
		[previous addObject: str];
	} else
		[previous addObject: name];

	[pool release];

	[name release];