ObjFW  Diff

Differences From Artifact [17605d93c9]:

To Artifact [7a74906b05]:


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
	[self freeMemory: s->string];
	s->string = newString;
	s->length = newLength;
}

- (void)setToCString: (const char*)string
{
	size_t length;

	[self freeMemory: s->string];

	length = strlen(string);

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

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

		@throw [OFInvalidEncodingException newWithClass: isa];
	}


	s->length = length;
	s->string = [self allocMemoryWithSize: length + 1];
	memcpy(s->string, string, length + 1);
}

- (void)appendCString: (const char*)string







<
<
<
<
|














|
<
<
|
<
|
>







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
	[self freeMemory: s->string];
	s->string = newString;
	s->length = newLength;
}

- (void)setToCString: (const char*)string
{




	size_t length = strlen(string);

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

	switch (of_string_check_utf8(string, length)) {
	case 0:
		s->isUTF8 = NO;
		break;
	case 1:
		s->isUTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];


	}


	[self freeMemory: s->string];

	s->length = length;
	s->string = [self allocMemoryWithSize: length + 1];
	memcpy(s->string, string, length + 1);
}

- (void)appendCString: (const char*)string