ObjFW  Diff

Differences From Artifact [6fce01c941]:

To Artifact [36e450e8e9]:


112
113
114
115
116
117
118







119
120
121
122
123
124
125
	return [[[self alloc] init] autorelease];
}

+ stringWithCString: (const char*)str
{
	return [[[self alloc] initWithCString: str] autorelease];
}








+ stringWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);







>
>
>
>
>
>
>







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	return [[[self alloc] init] autorelease];
}

+ stringWithCString: (const char*)str
{
	return [[[self alloc] initWithCString: str] autorelease];
}

+ stringWithCString: (const char*)str
	  andLength: (size_t)len
{
	return [[[self alloc] initWithCString: str
				    andLength: len] autorelease];
}

+ stringWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
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

	self = [super init];

	if (str != NULL) {
		length = strlen(str);

		switch (of_string_check_utf8(str, length)) {
			case 1:
				is_utf8 = YES;
				break;
			case -1:
				c = isa;
				[super dealloc];
				@throw [OFInvalidEncodingException
					newWithClass: c];
		}

		@try {
			string = [self allocMemoryWithSize: length + 1];
		} @catch (OFException *e) {
			/*
			 * We can't use [super dealloc] on OS X here.
			 * Compiler bug? Anyway, [self dealloc] will do here as
			 * we don't reimplement dealloc.
			 */
			[self dealloc];
			@throw e;
		}
		memcpy(string, str, length + 1);
	}











































	return self;
}

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







|
|
|
|
|
|
|
<
















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







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
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
235

	self = [super init];

	if (str != NULL) {
		length = strlen(str);

		switch (of_string_check_utf8(str, length)) {
		case 1:
			is_utf8 = YES;
			break;
		case -1:
			c = isa;
			[super dealloc];
			@throw [OFInvalidEncodingException newWithClass: c];

		}

		@try {
			string = [self allocMemoryWithSize: length + 1];
		} @catch (OFException *e) {
			/*
			 * We can't use [super dealloc] on OS X here.
			 * Compiler bug? Anyway, [self dealloc] will do here as
			 * we don't reimplement dealloc.
			 */
			[self dealloc];
			@throw e;
		}
		memcpy(string, str, length + 1);
	}

	return self;
}

- initWithCString: (const char*)str
	andLength: (size_t)len
{
	Class c;

	self = [super init];

	if (len > strlen(str)) {
		c = isa;
		[super dealloc];
		@throw [OFOutOfRangeException newWithClass: c];
	}

	length = len;

	switch (of_string_check_utf8(str, length)) {
	case 1:
		is_utf8 = YES;
		break;
	case -1:
		c = isa;
		[super dealloc];
		@throw [OFInvalidEncodingException newWithClass: c];
	}

	@try {
		string = [self allocMemoryWithSize: length + 1];
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here.
		 * Compiler bug? Anyway, [self dealloc] will do here as
		 * we don't reimplement dealloc.
		 */
		[self dealloc];
		@throw e;
	}
	memcpy(string, str, length);
	string[length] = 0;

	return self;
}

- initWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;
447
448
449
450
451
452
453
454







455







456
457
458
459
460
461
462
}

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








- appendCStringWithoutUTF8Checking: (const char*)str







{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- appendString: (OFString*)str
{








>
>
>
>
>
>
>

>
>
>
>
>
>
>







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
}

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

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

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

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

- appendString: (OFString*)str
{