ObjFW  Check-in [9863810eba]

Overview
Comment:Rename -[append:] to -[appendString:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9863810ebad8724228b03490a932b8ecf382b37b2529fabdebde3f5f0745516d
User & Date: js on 2009-06-09 20:47:16
Other Links: manifest | tags
Context
2009-06-09
21:01
Fix a forgotten -[cString] in OFExceptions. check-in: d2b906b7f1 user: js tags: trunk
20:47
Rename -[append:] to -[appendString:]. check-in: 9863810eba user: js tags: trunk
20:44
Make OFSocket a class cluster. check-in: f847f82b75 user: js tags: trunk
Changes

Modified src/OFMutableString.h from [4823c3305e] to [2a9861e6dd].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41







42
43
44
45
46
47
48
21
22
23
24
25
26
27







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48







-
-
-
-
-
-
-







+
+
+
+
+
+
+







/**
 * Sets the OFString to the specified OFString.
 *
 * \param str An OFString to set the OFString to.
 */
- setToCString: (const char*)str;

/**
 * Appends another OFString to the OFString.
 *
 * \param str An OFString to append
 */
- append: (OFString*)str;

/**
 * Appends a C string to the OFString.
 *
 * \param str A C string to append
 */
- appendCString: (const char*)str;

/**
 * Appends another OFString to the OFString.
 *
 * \param str An OFString to append
 */
- appendString: (OFString*)str;

/**
 * Appends a formatted C string to the OFString.
 * See printf for the format syntax.
 *
 * \param fmt A format string which generates the string to append
 */
- appendWithFormat: (OFString*)fmt, ...;

Modified src/OFMutableString.m from [3cf489fd9b] to [69cd258f82].

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
60
61
62
63
64
65
66





67
68
69
70
71
72
73







-
-
-
-
-







	length = len;
	string = [self allocMemoryWithSize: length + 1];
	memcpy(string, str, length + 1);

	return self;
}

- append: (OFString*)str
{
	return [self appendCString: [str cString]];
}

- appendCString: (const char*)str
{
	size_t strlength;

	strlength = strlen(str);

	switch (of_string_check_utf8(str, strlength)) {
86
87
88
89
90
91
92





93
94
95
96
97
98
99
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99







+
+
+
+
+







	string = [self resizeMemory: string
			     toSize: length + strlength + 1];
	memcpy(string + length, str, strlength + 1);
	length += strlength;

	return self;
}

- appendString: (OFString*)str
{
	return [self appendCString: [str cString]];
}

- appendWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);

Modified src/OFString.h from [0a39997d8c] to [924026e22c].

131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145
146







-

+







 *
 * \param delimiter The delimiter for splitting
 * \return An autoreleased OFArray with the splitted string
 */
- (OFArray*)splitWithDelimiter: (OFString*)delimiter;

- setToCString: (const char*)str;
- append: (OFString*)str;
- appendCString: (const char*)str;
- appendString: (OFString*)str;
- appendWithFormat: (OFString*)fmt, ...;
- appendWithFormat: (OFString*)fmt
      andArguments: (va_list)args;
- reverse;
- upper;
- lower;
- replaceOccurrencesOfString: (OFString*)str

Modified src/OFString.m from [5d82d403f3] to [16153df8cd].

369
370
371
372
373
374
375
376

377
378
379
380
381
382

383
384
385
386
387
388
389
369
370
371
372
373
374
375

376
377
378
379
380
381

382
383
384
385
386
387
388
389







-
+





-
+








- setToCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- append: (OFString*)str
- appendCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- appendCString: (const char*)str
- appendString: (OFString*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- appendWithFormat: (OFString*)fmt, ...
{

Modified tests/OFString/OFString.m from [6c5bfadd7f] to [8785c62127].

66
67
68
69
70
71
72
73

74
75
76
77

78
79
80
81
82
83
84
66
67
68
69
70
71
72

73
74
75
76

77
78
79
80
81
82
83
84







-
+



-
+







	s3 = [s1 copy];

	CHECK([s1 isEqual: s3])
	CHECK(![s1 isEqual: [[OFObject alloc] init]])
	CHECK([s1 hash] == [s3 hash])

	[s2 appendCString: "12"];
	[s2 append: @"3"];
	[s2 appendString: @"3"];
	[s4 setToCString: [s2 cString]];

	CHECK(![s2 compare: s4])
	CHECK(!strcmp([[s1 append: s2] cString], "test123"))
	CHECK(!strcmp([[s1 appendString: s2] cString], "test123"))
	CHECK([s1 hash] == 0xC44F49A4)
	CHECK(strlen([s1 cString]) == [s1 length] && [s1 length] == 7)
	CHECK(!strcmp([[s1 reverse] cString], "321tset"))
	CHECK(!strcmp([[s1 upper] cString], "321TSET"))
	CHECK(!strcmp([[s1 lower] cString], "321tset"))

	/* Also clears all the memory of the returned C strings */