ObjFW  Check-in [d511962e09]

Overview
Comment:Remove -[setToCString:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d511962e09c73e897495b31a6ce6ad97fbf1324a0597fb9970f628909cae04d2
User & Date: js on 2011-09-12 19:14:28
Other Links: manifest | tags
Context
2011-09-12
19:57
Rename -[cString] to -[UTF8String]. check-in: e6fd39d11e user: js tags: trunk
19:14
Remove -[setToCString:]. check-in: d511962e09 user: js tags: trunk
18:57
Add -[cStringWithEncoding:] and -[cStringLengthWithEncoding:]. check-in: 90369e9323 user: js tags: trunk
Changes

Modified src/OFMutableString.h from [a723d0168a] to [eaba6860c9].

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

#import "OFString.h"

/**
 * \brief A class for storing and modifying strings.
 */
@interface OFMutableString: OFString
/**
 * \brief Sets the OFMutableString to the specified UTF-8 encoded C string.
 *
 * \param newCString A UTF-8 encoded C string to set the OFMutableString to.
 */
- (void)setToCString: (const char*)newCString;

/**
 * \brief Appends a UTF-8 encoded C string to the OFMutableString.
 *
 * \param cString A UTF-8 encoded C string to append
 */
- (void)appendCString: (const char*)cString;








<
<
<
<
<
<
<







19
20
21
22
23
24
25







26
27
28
29
30
31
32

#import "OFString.h"

/**
 * \brief A class for storing and modifying strings.
 */
@interface OFMutableString: OFString







/**
 * \brief Appends a UTF-8 encoded C string to the OFMutableString.
 *
 * \param cString A UTF-8 encoded C string to append
 */
- (void)appendCString: (const char*)cString;

Modified src/OFMutableString.m from [79d9601955] to [f3abcc1339].

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

	/*
	 * Even though cStringLength can change, length cannot, therefore no
	 * need to change it.
	 */
}

- (void)setToCString: (const char*)newCString
{
	size_t newCStringLength = strlen(newCString);
	size_t newLength;

	if (newCStringLength >= 3 && !memcmp(newCString, "\xEF\xBB\xBF", 3)) {
		newCString += 3;
		newCStringLength -= 3;
	}

	switch (of_string_check_utf8(newCString, newCStringLength,
	    &newLength)) {
	case 0:
		s->isUTF8 = NO;
		break;
	case 1:
		s->isUTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];
	}

	[self freeMemory: s->cString];

	s->cStringLength = newCStringLength;
	s->length = newLength;

	s->cString = [self allocMemoryWithSize: newCStringLength + 1];
	memcpy(s->cString, newCString, newCStringLength + 1);
}

- (void)appendCString: (const char*)cString
{
	size_t cStringLength = strlen(cString);
	size_t length;

	if (cStringLength >= 3 && !memcmp(cString, "\xEF\xBB\xBF", 3)) {
		cString += 3;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







134
135
136
137
138
139
140































141
142
143
144
145
146
147

	/*
	 * Even though cStringLength can change, length cannot, therefore no
	 * need to change it.
	 */
}
































- (void)appendCString: (const char*)cString
{
	size_t cStringLength = strlen(cString);
	size_t length;

	if (cStringLength >= 3 && !memcmp(cString, "\xEF\xBB\xBF", 3)) {
		cString += 3;