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
|
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
|
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* 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.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#import "OFString.h"
#import "OFApplication.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURI.h"
#import "OFFile.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFHTTPClient.h"
#import "OFFile.h"
#import "OFStdIOStream.h"
#import "OFIRI.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFOutOfRangeException.h"
#import "TableGenerator.h"
#import "copyright.h"
static OFString *const unicodeDataURI =
static OFString *const unicodeDataIRI =
@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
static OFString *const caseFoldingURI =
static OFString *const caseFoldingIRI =
@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
OF_APPLICATION_DELEGATE(TableGenerator)
@implementation TableGenerator
- (instancetype)init
{
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
-
+
+
|
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFHTTPRequest *request;
[OFStdOut writeString: @"Downloading UnicodeData.txt…"];
_state = stateUnicodeData;
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: unicodeDataURI]];
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: unicodeDataIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
exception: (id)exception
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
+
+
|
[self applyDecompositionRecursivelyForTable: _decompositionTable];
[self applyDecompositionRecursivelyForTable: _decompositionCompatTable];
[OFStdOut writeLine: @" done"];
[OFStdOut writeString: @"Downloading CaseFolding.txt…"];
_state = stateCaseFolding;
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: caseFoldingURI]];
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: caseFoldingIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)parseCaseFolding: (OFHTTPResponse *)response
{
OFString *line;
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
-
+
-
-
+
+
-
-
+
+
|
objc_autoreleasePoolPop(pool);
}
} while (!done);
}
- (void)writeFiles
{
OFURI *URI;
OFIRI *IRI;
[OFStdOut writeString: @"Writing files…"];
URI = [OFURI fileURIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: URI.fileSystemRepresentation];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: IRI.fileSystemRepresentation];
URI = [OFURI fileURIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: URI.fileSystemRepresentation];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: IRI.fileSystemRepresentation];
[OFStdOut writeLine: @" done"];
[OFApplication terminate];
}
- (void)writeTablesToFile: (OFString *)path
|