ObjFW  Check-in [2cbf759299]

Overview
Comment:Add lower and upper for OFString.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2cbf7592992f7047e3f28e1a063af2e9afb88317f7532b15c4eae3d228aec040
User & Date: js on 2008-11-27 16:14:11
Other Links: manifest | tags
Context
2008-11-28
17:31
glibc needs one import more. check-in: ae389818d9 user: js tags: trunk
2008-11-27
16:14
Add lower and upper for OFString. check-in: 2cbf759299 user: js tags: trunk
2008-11-26
21:35
glibc breaks when trying to use stdio.h and wchar.h.
This is stupid, as it's possible you don't ever output a wchar_t and
just need wcscmp, but this forces us to always use wprintf when we need
a wchar_t somewhere in the file. glibc really is a nightmare.
check-in: 0889c2fc55 user: js tags: trunk
Changes

Modified src/OFString.h from [3ff6ad57f0] to [451f517c16].

129
130
131
132
133
134
135










136
 */
- appendWideCString: (const wchar_t*)str;

/**
 * Reverse the OFString.
 */
- reverse;










@end







>
>
>
>
>
>
>
>
>
>

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 */
- appendWideCString: (const wchar_t*)str;

/**
 * Reverse the OFString.
 */
- reverse;

/**
 * Upper the OFString.
 */
- upper;

/**
 * Lower the OFString.
 */
- lower;
@end

Modified src/OFString.m from [441ab9ee19] to [e4cac6da69].

205
206
207
208
209
210
211




















212
213
214

	for (i = 0, j = length - 1; i < len; i++, j--) {
		string[i] ^= string[j];
		string[j] ^= string[i];
		string[i] ^= string[j];
	}





















	return self;
}
@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



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

	for (i = 0, j = length - 1; i < len; i++, j--) {
		string[i] ^= string[j];
		string[j] ^= string[i];
		string[i] ^= string[j];
	}

	return self;
}

- upper
{
	size_t i = length;

	while (i--) 
		string[i] = towupper(string[i]);

	return self;
}

- lower
{
	size_t i = length;

	while (i--) 
		string[i] = towlower(string[i]);

	return self;
}
@end

Modified tests/OFString/OFString.m from [e5dacf305a] to [f1742cd2ab].

59
60
61
62
63
64
65














66
67
68
69
70
71
72
73

	if (!strcmp([[s1 reverse] cString], "321tset"))
		puts("Reversed s1 is expected string! GOOD!");
	else {
		puts("Reversed s1 is NOT the expected string!");
		return 1;
	}















	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>








59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

	if (!strcmp([[s1 reverse] cString], "321tset"))
		puts("Reversed s1 is expected string! GOOD!");
	else {
		puts("Reversed s1 is NOT the expected string!");
		return 1;
	}

	if (!strcmp([[s1 upper] cString], "321TSET"))
		puts("Upper s1 is expected string! GOOD!");
	else {
		puts("Upper s1 is NOT expected string!");
		return 1;
	}

	if (!strcmp([[s1 lower] cString], "321tset"))
		puts("Lower s1 is expected string! GOOD!");
	else {
		puts("Lower s1 is NOT expected string!");
		return 1;
	}

	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}