ObjFW  Diff

Differences From Artifact [9261f4b9e0]:

To Artifact [0eff2f55bc]:


130
131
132
133
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
179
180



181
182
183
184
185





186
187
188
189
190
191
192
130
131
132
133
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
179
180
181
182
183
184
185



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205







-
+



-
+

+
+
+
+
+
-
+














-
+






-
+

+
-
-
-
+
+
+
+
+








-
-
-
+
+
+





+
+
+
+
+







	[self freeMemory: string];
	string = newString;
	length = newLength;
}

- (void)setToCString: (const char*)string_
{
	size_t len;
	size_t length_;

	[self freeMemory: string];

	len = strlen(string_);
	length_ = strlen(string_);

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

	switch (of_string_check_utf8(string_, len)) {
	switch (of_string_check_utf8(string_, length_)) {
	case 0:
		isUTF8 = NO;
		break;
	case 1:
		isUTF8 = YES;
		break;
	case -1:
		string = NULL;
		length = 0;
		isUTF8 = NO;

		@throw [OFInvalidEncodingException newWithClass: isa];
	}

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

- (void)appendCString: (const char*)string_
{
	size_t len;
	size_t length_ = strlen(string_);

	if (length_ >= 3 && !memcmp(string_, "\xEF\xBB\xBF", 3)) {
	len = strlen(string_);

	switch (of_string_check_utf8(string_, len)) {
		string_ += 3;
		length_ -= 3;
	}

	switch (of_string_check_utf8(string_, length_)) {
	case 1:
		isUTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];
	}

	string = [self resizeMemory: string
			     toSize: length + len + 1];
	memcpy(string + length, string_, len + 1);
	length += len;
			     toSize: length + length_ + 1];
	memcpy(string + length, string_, length_ + 1);
	length += length_;
}

- (void)appendCString: (const char*)string_
	   withLength: (size_t)length_
{
	if (length_ >= 3 && !memcmp(string_, "\xEF\xBB\xBF", 3)) {
		string_ += 3;
		length_ -= 3;
	}

	switch (of_string_check_utf8(string_, length_)) {
	case 1:
		isUTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];
	}