ObjFW  Diff

Differences From Artifact [169ecc0832]:

To Artifact [2bd483c89b]:


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
74
75
76
77
78
79
80
81
82
83
84
85
86

87
88
89
90

91
92

93
94
95
96
97
98
99
100
101

#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURL.h"



#import "OFFile.h"

#import "autorelease.h"

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

#define UNICODE_DATA_URL \
	@"http://unicode.org/Public/UNIDATA/UnicodeData.txt"
#define CASE_FOLDING_URL \
	@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"

OF_APPLICATION_DELEGATE(TableGenerator)

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

	uppercaseTableSize   = SIZE_MAX;
	lowercaseTableSize   = SIZE_MAX;
	titlecaseTableSize   = SIZE_MAX;
	casefoldingTableSize = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{
	[self downloadFiles];

	[self parseUnicodeData];
	[self parseCaseFolding];

	[of_stdout writeString: @"Writing files..."];

	[self writeTablesToFile: @"../src/unicode.m"];
	[self writeHeaderToFile: @"../src/unicode.h"];

	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}

- (void)downloadFiles
{
	[of_stdout writeString: @"Downloading " UNICODE_DATA_URL @"..."];
	unicodeData = [[OFString alloc] initWithContentsOfURL:
	    [OFURL URLWithString: UNICODE_DATA_URL]];
	[of_stdout writeLine: @" done"];

	[of_stdout writeString: @"Downloading " CASE_FOLDING_URL @"..."];
	caseFolding = [[OFString alloc] initWithContentsOfURL:
	    [OFURL URLWithString: CASE_FOLDING_URL]];
	[of_stdout writeLine: @" done"];
}

- (void)parseUnicodeData
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *lines;
	OFEnumerator *enumerator;

	OFString *line;

	[of_stdout writeString: @"Parsing UnicodeData.txt..."];


	lines = [unicodeData componentsSeparatedByString: @"\n"];
	enumerator = [lines objectEnumerator];


	while ((line = [enumerator nextObject]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0)
			continue;







>
>
>








|




















<
<













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



|
|
>


|

>
|
|
>

|







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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

#include <string.h>

#import "OFString.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURL.h"
#import "OFHTTPRequest.h"
#import "OFHTTPRequestReply.h"
#import "OFHTTPClient.h"
#import "OFFile.h"

#import "autorelease.h"

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

#define UNICODE_DATA_URL \
	@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt"
#define CASE_FOLDING_URL \
	@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"

OF_APPLICATION_DELEGATE(TableGenerator)

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

	uppercaseTableSize   = SIZE_MAX;
	lowercaseTableSize   = SIZE_MAX;
	titlecaseTableSize   = SIZE_MAX;
	casefoldingTableSize = SIZE_MAX;

	return self;
}

- (void)applicationDidFinishLaunching
{


	[self parseUnicodeData];
	[self parseCaseFolding];

	[of_stdout writeString: @"Writing files..."];

	[self writeTablesToFile: @"../src/unicode.m"];
	[self writeHeaderToFile: @"../src/unicode.h"];

	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}














- (void)parseUnicodeData
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPRequest *request;
	OFHTTPClient *client;
	OFHTTPRequestReply *reply;
	OFString *line;

	[of_stdout writeString: @"Downloading and parsing UnicodeData.txt..."];

	request = [OFHTTPRequest requestWithURL:
	    [OFURL URLWithString: UNICODE_DATA_URL]];
	client = [OFHTTPClient client];
	reply = [client performRequest: request];

	while ((line = [reply readLine]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0)
			continue;
124
125
126
127
128
129
130
131
132

133
134
135
136

137
138

139
140
141
142
143
144
145
146
147

	objc_autoreleasePoolPop(pool);
}

- (void)parseCaseFolding
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *lines;
	OFEnumerator *enumerator;

	OFString *line;

	[of_stdout writeString: @"Parsing CaseFolding.txt..."];


	lines = [caseFolding componentsSeparatedByString: @"\n"];
	enumerator = [lines objectEnumerator];


	while ((line = [enumerator nextObject]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0 || [line hasPrefix: @"#"])
			continue;







|
|
>


|

>
|
|
>

|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

	objc_autoreleasePoolPop(pool);
}

- (void)parseCaseFolding
{
	void *pool = objc_autoreleasePoolPush();
	OFHTTPRequest *request;
	OFHTTPClient *client;
	OFHTTPRequestReply *reply;
	OFString *line;

	[of_stdout writeString: @"Downloading and parsing CaseFolding.txt..."];

	request = [OFHTTPRequest requestWithURL:
	    [OFURL URLWithString: CASE_FOLDING_URL]];
	client = [OFHTTPClient client];
	reply = [client performRequest: request];

	while ((line = [reply readLine]) != nil) {
		void *pool2;
		OFArray *split;
		OFString **splitObjects;
		of_unichar_t codep;

		if ([line length] == 0 || [line hasPrefix: @"#"])
			continue;