ObjFW  Diff

Differences From Artifact [d89cfa703e]:

To Artifact [baeef6024f]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22
23
24
25


26
27
28
29
30
31
32
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
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"

#import "OFExceptions.h"

#import "TableGenerator.h"
#import "copyright.h"



@implementation TableGenerator
- init
{
	self = [super init];

	upper_size = SIZE_MAX;
	lower_size = SIZE_MAX;
	casefolding_size = SIZE_MAX;

	return self;
}










- (void)readUnicodeDataFile: (OFString*)path
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"rb"];
	OFString *line;

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((line = [file readLine])) {
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		splitted = [line splitWithDelimiter: @";"];
		if ([splitted count] != 15) {
			fprintf(stderr, "Invalid line: %s\n", [line cString]);

			exit(1);
		}
		splitted_carray = [splitted cArray];

		codep = [splitted_carray[0] hexadecimalValueAsInteger];
		upper[codep] = [splitted_carray[12] hexadecimalValueAsInteger];
		lower[codep] = [splitted_carray[13] hexadecimalValueAsInteger];













<







>




>
>












>
>
>
>
>
>
>
>
>














|

|
>







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"


#include <stdlib.h>
#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"
#import "OFApplication.h"
#import "OFExceptions.h"

#import "TableGenerator.h"
#import "copyright.h"

OF_APPLICATION_DELEGATE(TableGenerator)

@implementation TableGenerator
- init
{
	self = [super init];

	upper_size = SIZE_MAX;
	lower_size = SIZE_MAX;
	casefolding_size = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{
	TableGenerator *tgen = [[[TableGenerator alloc] init] autorelease];
	[tgen readUnicodeDataFile: @"UnicodeData.txt"];
	[tgen readCaseFoldingFile: @"CaseFolding.txt"];
	[tgen writeTablesToFile: @"../src/unicode.m"];
	[tgen writeHeaderToFile: @"../src/unicode.h"];
}

- (void)readUnicodeDataFile: (OFString*)path
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"rb"];
	OFString *line;

	pool2 = [[OFAutoreleasePool alloc] init];
	while ((line = [file readLine])) {
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		splitted = [line componentsSeparatedByString: @";"];
		if ([splitted count] != 15) {
			[of_stderr writeFormat: @"Invalid line: %s\n",
						[line cString]];
			exit(1);
		}
		splitted_carray = [splitted cArray];

		codep = [splitted_carray[0] hexadecimalValueAsInteger];
		upper[codep] = [splitted_carray[12] hexadecimalValueAsInteger];
		lower[codep] = [splitted_carray[13] hexadecimalValueAsInteger];
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		if ([line characterAtIndex: 0] == '#')
			continue;

		splitted = [line splitWithDelimiter: @"; "];
		if ([splitted count] != 4) {
			fprintf(stderr, "Invalid line: %s\n", [line cString]);

			exit(1);
		}
		splitted_carray = [splitted cArray];

		if (![splitted_carray[1] isEqual: @"S"] &&
		    ![splitted_carray[1] isEqual: @"C"])
			continue;







|

|
>







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
		OFArray *splitted;
		OFString **splitted_carray;
		of_unichar_t codep;

		if ([line characterAtIndex: 0] == '#')
			continue;

		splitted = [line componentsSeparatedByString: @"; "];
		if ([splitted count] != 4) {
			[of_stderr writeFormat: @"Invalid line: %s\n",
						[line cString]];
			exit(1);
		}
		splitted_carray = [splitted cArray];

		if (![splitted_carray[1] isEqual: @"S"] &&
		    ![splitted_carray[1] isEqual: @"C"])
			continue;