ObjFW  Diff

Differences From Artifact [29e52abbc7]:

To Artifact [3b4d8b06cc]:


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "of_asprintf.h"
#import "unicode.h"

static struct {
	Class isa;
} placeholder;

#ifndef OF_HAVE_UNICODE_TABLES
/* Wrap these, as they can be macros. */
static int
toupperWrapper(int c)
{
	return toupper(c);
}

static int
tolowerWrapper(int c)
{
	return tolower(c);
}
#endif

@interface OFMutableString_placeholder: OFMutableString
@end

@implementation OFMutableString_placeholder
- init
{
	return (id)[[OFMutableString_UTF8 alloc] init];







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







33
34
35
36
37
38
39















40
41
42
43
44
45
46
#import "of_asprintf.h"
#import "unicode.h"

static struct {
	Class isa;
} placeholder;
















@interface OFMutableString_placeholder: OFMutableString
@end

@implementation OFMutableString_placeholder
- init
{
	return (id)[[OFMutableString_UTF8 alloc] init];
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
			break;
		}
	}

	objc_autoreleasePoolPop(pool);
}
#else
- (void)OF_convertWithWordStartFunction: (int (*)(int))startFunction
		     wordMiddleFunction: (int (*)(int))middleFunction
{
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = [self characters];
	size_t length = [self length];
	bool isStart = true;

	for (size_t i = 0; i < length; i++) {
		int (*function)(int) =
		    (isStart ? startFunction : middleFunction);;
		of_unichar_t c = characters[i];

		if (c <= 0x7F)
			[self setCharacter: (int)function(c)
				   atIndex: i];








|
|







|







278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
			break;
		}
	}

	objc_autoreleasePoolPop(pool);
}
#else
- (void)OF_convertWithWordStartFunction: (char (*)(char))startFunction
		     wordMiddleFunction: (char (*)(char))middleFunction
{
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = [self characters];
	size_t length = [self length];
	bool isStart = true;

	for (size_t i = 0; i < length; i++) {
		char (*function)(char) =
		    (isStart ? startFunction : middleFunction);;
		of_unichar_t c = characters[i];

		if (c <= 0x7F)
			[self setCharacter: (int)function(c)
				   atIndex: i];

480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
			   wordMiddleTable: of_unicode_lowercase_table
			wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
		       wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}
#else
- (void)uppercase
{
	[self OF_convertWithWordStartFunction: toupperWrapper
			   wordMiddleFunction: toupperWrapper];
}

- (void)lowercase
{
	[self OF_convertWithWordStartFunction: tolowerWrapper
			   wordMiddleFunction: tolowerWrapper];
}

- (void)capitalize
{
	[self OF_convertWithWordStartFunction: toupperWrapper
			   wordMiddleFunction: tolowerWrapper];
}
#endif

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	[self replaceCharactersInRange: of_range(index, 0)







|
|




|
|




|
|







465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
			   wordMiddleTable: of_unicode_lowercase_table
			wordStartTableSize: OF_UNICODE_TITLECASE_TABLE_SIZE
		       wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE];
}
#else
- (void)uppercase
{
	[self OF_convertWithWordStartFunction: of_ascii_toupper
			   wordMiddleFunction: of_ascii_toupper];
}

- (void)lowercase
{
	[self OF_convertWithWordStartFunction: of_ascii_tolower
			   wordMiddleFunction: of_ascii_tolower];
}

- (void)capitalize
{
	[self OF_convertWithWordStartFunction: of_ascii_toupper
			   wordMiddleFunction: of_ascii_tolower];
}
#endif

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	[self replaceCharactersInRange: of_range(index, 0)