ObjFW  Diff

Differences From Artifact [9288f5195e]:

To Artifact [a950dfa678]:


250
251
252
253
254
255
256

257
258

259
260
261
262

263
264


265








266
267
268
269












270
271
272
273
274
275
276
{
	if (self == [OFMutableString class])
		return (id)&placeholder;

	return [super alloc];
}


- (void)_applyTable: (const of_unichar_t* const[])table
	   withSize: (size_t)tableSize

{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	const of_unichar_t *string = [self unicodeString];
	size_t i, length = [self length];


	for (i = 0; i < length; i++) {


		of_unichar_t c = string[i];









		if (c >> 8 < tableSize && table[c >> 8][c & 0xFF])
			[self setCharacter: table[c >> 8][c & 0xFF]
				   atIndex: i];












	}

	[pool release];
}

- (void)setCharacter: (of_unichar_t)character
	     atIndex: (size_t)index







>
|
|
>




>


>
>

>
>
>
>
>
>
>
>




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







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
{
	if (self == [OFMutableString class])
		return (id)&placeholder;

	return [super alloc];
}

- (void)_convertWithWordStartTable: (const of_unichar_t *const[])startTable
		   wordMiddleTable: (const of_unichar_t *const[])middleTable
		wordStartTableSize: (size_t)startTableSize
	       wordMiddleTableSize: (size_t)middleTableSize
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	const of_unichar_t *string = [self unicodeString];
	size_t i, length = [self length];
	BOOL isStart = YES;

	for (i = 0; i < length; i++) {
		const of_unichar_t *const *table;
		size_t tableSize;
		of_unichar_t c = string[i];

		if (isStart) {
			table = startTable;
			tableSize = middleTableSize;
		} else {
			table = middleTable;
			tableSize = middleTableSize;
		}

		if (c >> 8 < tableSize && table[c >> 8][c & 0xFF])
			[self setCharacter: table[c >> 8][c & 0xFF]
				   atIndex: i];

		switch (c) {
		case ' ':
		case '\t':
		case '\n':
		case '\r':
			isStart = YES;
			break;
		default:
			isStart = NO;
			break;
		}
	}

	[pool release];
}

- (void)setCharacter: (of_unichar_t)character
	     atIndex: (size_t)index
378
379
380
381
382
383
384

385

386
387
388
389
390

391

392








393
394
395
396
397
398
399
		[self setCharacter: tmp
			   atIndex: i];
	}
}

- (void)uppercase
{

	[self _applyTable: of_unicode_uppercase_table

		 withSize: OF_UNICODE_UPPERCASE_TABLE_SIZE];
}

- (void)lowercase
{

	[self _applyTable: of_unicode_lowercase_table

		 withSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];








}

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];







>
|
>
|




>
|
>
|
>
>
>
>
>
>
>
>







403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
		[self setCharacter: tmp
			   atIndex: i];
	}
}

- (void)uppercase
{
	[self _convertWithWordStartTable: of_unicode_uppercase_table
			 wordMiddleTable: of_unicode_uppercase_table
		      wordStartTableSize: OF_UNICODE_UPPERCASE_TABLE_SIZE
		     wordMiddleTableSize: OF_UNICODE_UPPERCASE_TABLE_SIZE];
}

- (void)lowercase
{
	[self _convertWithWordStartTable: of_unicode_lowercase_table
			 wordMiddleTable: of_unicode_lowercase_table
		      wordStartTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE
		     wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}

- (void)capitalize
{
	[self _convertWithWordStartTable: of_unicode_titlecase_table
			 wordMiddleTable: of_unicode_lowercase_table
		      wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
		     wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];