ObjFW  Diff

Differences From Artifact [f4b0745ff9]:

To Artifact [82dd9b8b47]:


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
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: [OFString stringWithPath:


	    OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.m", nil]];
	[self writeHeaderToFile: [OFString stringWithPath:
	    OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.h", nil]];

	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}

- (void)parseUnicodeData







|
|
|
|






>





>
>
|
>
>
|
|
<







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
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
{
	OFString *path;
	[self parseUnicodeData];
	[self parseCaseFolding];

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

	path = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.m", nil]];
	[self writeTablesToFile: path];

	path = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.h", nil]];
	[self writeHeaderToFile: path];


	[of_stdout writeLine: @" done"];

	[OFApplication terminate];
}

- (void)parseUnicodeData
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		if ([split count] != 15) {
			of_log(@"Invalid line: %@\n", line);
			[OFApplication terminateWithStatus: 1];
		}
		splitObjects = [split objects];

		codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
		uppercaseTable[codep] =
		    (of_unichar_t)[splitObjects[12] hexadecimalValue];
		lowercaseTable[codep] =
		    (of_unichar_t)[splitObjects[13] hexadecimalValue];
		titlecaseTable[codep] =
		    (of_unichar_t)[splitObjects[14] hexadecimalValue];

		objc_autoreleasePoolPop(pool2);
	}

	[of_stdout writeLine: @" done"];








|

|

|







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
		if ([split count] != 15) {
			of_log(@"Invalid line: %@\n", line);
			[OFApplication terminateWithStatus: 1];
		}
		splitObjects = [split objects];

		codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
		_uppercaseTable[codep] =
		    (of_unichar_t)[splitObjects[12] hexadecimalValue];
		_lowercaseTable[codep] =
		    (of_unichar_t)[splitObjects[13] hexadecimalValue];
		_titlecaseTable[codep] =
		    (of_unichar_t)[splitObjects[14] hexadecimalValue];

		objc_autoreleasePoolPop(pool2);
	}

	[of_stdout writeLine: @" done"];

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
		splitObjects = [split objects];

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

		codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
		casefoldingTable[codep] =
		    (of_unichar_t)[splitObjects[2] hexadecimalValue];

		objc_autoreleasePoolPop(pool2);
	}

	[of_stdout writeLine: @" done"];








|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
		splitObjects = [split objects];

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

		codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
		_casefoldingTable[codep] =
		    (of_unichar_t)[splitObjects[2] hexadecimalValue];

		objc_autoreleasePoolPop(pool2);
	}

	[of_stdout writeLine: @" done"];

176
177
178
179
180
181
182
183
184
185






































186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229


230
231

232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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
437
438
439
440
441
442
443
				       mode: @"wb"];
	of_unichar_t i, j;

	[file writeString: COPYRIGHT
	    @"#include \"config.h\"\n"
	    @"\n"
	    @"#import \"OFString.h\"\n\n"
	    @"static const of_unichar_t nop_page[0x100] = {};\n\n"];

	/* Write uppercase_page_%u */






































	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (uppercaseTable[j] != 0) {
				isEmpty = false;
				uppercaseTableSize = i >> 8;
				uppercaseTableUsed[uppercaseTableSize] = 1;
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"uppercase_page_%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    uppercaseTable[j],
				    uppercaseTable[j + 1],
				    uppercaseTable[j + 2],
				    uppercaseTable[j + 3],
				    uppercaseTable[j + 4],
				    uppercaseTable[j + 5],
				    uppercaseTable[j + 6],
				    uppercaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write lowercase_page_%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (lowercaseTable[j] != 0) {
				isEmpty = false;


				lowercaseTableSize = i >> 8;
				lowercaseTableUsed[lowercaseTableSize] = 1;

				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"lowercase_page_%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    lowercaseTable[j],
				    lowercaseTable[j + 1],
				    lowercaseTable[j + 2],
				    lowercaseTable[j + 3],
				    lowercaseTable[j + 4],
				    lowercaseTable[j + 5],
				    lowercaseTable[j + 6],
				    lowercaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write titlecase_page_%u if it does NOT match uppercase_page_%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (titlecaseTable[j] != 0) {
				isEmpty = !memcmp(uppercaseTable + i,
				    titlecaseTable + i,
				    256 * sizeof(of_unichar_t));
				titlecaseTableSize = i >> 8;
				titlecaseTableUsed[titlecaseTableSize] =
				    (isEmpty ? 2 : 1);
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"titlecase_page_%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    titlecaseTable[j],
				    titlecaseTable[j + 1],
				    titlecaseTable[j + 2],
				    titlecaseTable[j + 3],
				    titlecaseTable[j + 4],
				    titlecaseTable[j + 5],
				    titlecaseTable[j + 6],
				    titlecaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write casefolding_page_%u if it does NOT match lowercase_page_%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (casefoldingTable[j] != 0) {
				isEmpty = !memcmp(lowercaseTable + i,
				    casefoldingTable + i,
				    256 * sizeof(of_unichar_t));
				casefoldingTableSize = i >> 8;
				casefoldingTableUsed[casefoldingTableSize] =
				    (isEmpty ? 2 : 1);
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"casefolding_page_%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    casefoldingTable[j],
				    casefoldingTable[j + 1],
				    casefoldingTable[j + 2],
				    casefoldingTable[j + 3],
				    casefoldingTable[j + 4],
				    casefoldingTable[j + 5],
				    casefoldingTable[j + 6],
				    casefoldingTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/*
	 * Those are currently set to the last index.
	 * But from now on, we need the size.
	 */
	uppercaseTableSize++;
	lowercaseTableSize++;
	titlecaseTableSize++;
	casefoldingTableSize++;

	/* Write of_unicode_uppercase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_uppercase_table[0x%X] = "
	    @"{\n\t", uppercaseTableSize]];

	for (i = 0; i < uppercaseTableSize; i++) {
		if (uppercaseTableUsed[i]) {
			[file writeString: [OFString stringWithFormat:
			    @"uppercase_page_%u", i]];
		} else
			[file writeString: @"nop_page"];

		if (i + 1 < uppercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_lowercase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_lowercase_table[0x%X] = "
	    @"{\n\t", lowercaseTableSize]];

	for (i = 0; i < lowercaseTableSize; i++) {
		if (lowercaseTableUsed[i]) {
			[file writeString: [OFString stringWithFormat:
			    @"lowercase_page_%u", i]];
		} else
			[file writeString: @"nop_page"];

		if (i + 1 < lowercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_titlecase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_titlecase_table[0x%X] = {"
	    @"\n\t", titlecaseTableSize]];

	for (i = 0; i < titlecaseTableSize; i++) {
		if (titlecaseTableUsed[i] == 1) {
			[file writeString: [OFString stringWithFormat:
			    @"titlecase_page_%u", i]];
		} else if (titlecaseTableUsed[i] == 2) {
			[file writeString: [OFString stringWithFormat:
			    @"uppercase_page_%u", i]];
		} else
			[file writeString: @"nop_page"];

		if (i + 1 < titlecaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_casefolding_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_casefolding_table[0x%X] = "
	    @"{\n\t", casefoldingTableSize]];

	for (i = 0; i < casefoldingTableSize; i++) {
		if (casefoldingTableUsed[i] == 1) {
			[file writeString: [OFString stringWithFormat:
			    @"casefolding_page_%u", i]];
		} else if (casefoldingTableUsed[i] == 2) {
			[file writeString: [OFString stringWithFormat:
			    @"lowercase_page_%u", i]];
		} else
			[file writeString: @"nop_page"];

		if (i + 1 < casefoldingTableSize) {
			if ((i + 1) % 3 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}








|

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




|

|
|









|




|
|
|
|
|
|
|
|







|




|
|
>
>
|
|
>









|




|
|
|
|
|
|
|
|







|




|
|
|

|
|










|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|











|
|
|
|




|

|
|

|

|

|












|

|
|

|

|

|












|

|
|

|
|

|

|

|












|

|
|

|
|

|

|

|







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331









































332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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
437
438
439
440
441
442
443
444
445
446
447
				       mode: @"wb"];
	of_unichar_t i, j;

	[file writeString: COPYRIGHT
	    @"#include \"config.h\"\n"
	    @"\n"
	    @"#import \"OFString.h\"\n\n"
	    @"static const of_unichar_t emptyPage[0x100] = {};\n\n"];

	/* Write uppercasePage%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (_uppercaseTable[j] != 0) {
				isEmpty = false;
				_uppercaseTableSize = i >> 8;
				_uppercaseTableUsed[_uppercaseTableSize] = 1;
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"uppercasePage%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    _uppercaseTable[j],
				    _uppercaseTable[j + 1],
				    _uppercaseTable[j + 2],
				    _uppercaseTable[j + 3],
				    _uppercaseTable[j + 4],
				    _uppercaseTable[j + 5],
				    _uppercaseTable[j + 6],
				    _uppercaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write lowercasePage%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (_lowercaseTable[j] != 0) {
				isEmpty = false;
				_lowercaseTableSize = i >> 8;
				_lowercaseTableUsed[_lowercaseTableSize] = 1;
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"lowercasePage%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    _lowercaseTable[j],
				    _lowercaseTable[j + 1],
				    _lowercaseTable[j + 2],
				    _lowercaseTable[j + 3],
				    _lowercaseTable[j + 4],
				    _lowercaseTable[j + 5],
				    _lowercaseTable[j + 6],
				    _lowercaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write titlecasePage%u if it does NOT match uppercasePage%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (_titlecaseTable[j] != 0) {
				isEmpty = !memcmp(_uppercaseTable + i,
				    _titlecaseTable + i,
				    256 * sizeof(of_unichar_t));
				_titlecaseTableSize = i >> 8;
				_titlecaseTableUsed[_titlecaseTableSize] =
				    (isEmpty ? 2 : 1);
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"titlecasePage%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",
				    _titlecaseTable[j],
				    _titlecaseTable[j + 1],
				    _titlecaseTable[j + 2],
				    _titlecaseTable[j + 3],
				    _titlecaseTable[j + 4],
				    _titlecaseTable[j + 5],
				    _titlecaseTable[j + 6],
				    _titlecaseTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/* Write casefoldingPage%u if it does NOT match lowercasePage%u */
	for (i = 0; i < 0x110000; i += 0x100) {
		bool isEmpty = true;

		for (j = i; j < i + 0x100; j++) {
			if (_casefoldingTable[j] != 0) {
				isEmpty = !memcmp(_lowercaseTable + i,
				    _casefoldingTable + i,
				    256 * sizeof(of_unichar_t));
				_casefoldingTableSize = i >> 8;
				_casefoldingTableUsed[_casefoldingTableSize] =
				    (isEmpty ? 2 : 1);
				break;
			}
		}

		if (!isEmpty) {
			void *pool2 = objc_autoreleasePoolPush();

			[file writeString: [OFString stringWithFormat:
			    @"static const of_unichar_t "
			    @"casefoldingPage%u[0x100] = {\n", i >> 8]];

			for (j = i; j < i + 0x100; j += 8)
				[file writeString: [OFString stringWithFormat:
				    @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n",









































				    _casefoldingTable[j],
				    _casefoldingTable[j + 1],
				    _casefoldingTable[j + 2],
				    _casefoldingTable[j + 3],
				    _casefoldingTable[j + 4],
				    _casefoldingTable[j + 5],
				    _casefoldingTable[j + 6],
				    _casefoldingTable[j + 7]]];

			[file writeString: @"};\n\n"];

			objc_autoreleasePoolPop(pool2);
		}
	}

	/*
	 * Those are currently set to the last index.
	 * But from now on, we need the size.
	 */
	_uppercaseTableSize++;
	_lowercaseTableSize++;
	_titlecaseTableSize++;
	_casefoldingTableSize++;

	/* Write of_unicode_uppercase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_uppercase_table[0x%X] = "
	    @"{\n\t", _uppercaseTableSize]];

	for (i = 0; i < _uppercaseTableSize; i++) {
		if (_uppercaseTableUsed[i]) {
			[file writeString: [OFString stringWithFormat:
			    @"uppercasePage%u", i]];
		} else
			[file writeString: @"emptyPage"];

		if (i + 1 < _uppercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_lowercase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_lowercase_table[0x%X] = "
	    @"{\n\t", _lowercaseTableSize]];

	for (i = 0; i < _lowercaseTableSize; i++) {
		if (_lowercaseTableUsed[i]) {
			[file writeString: [OFString stringWithFormat:
			    @"lowercasePage%u", i]];
		} else
			[file writeString: @"emptyPage"];

		if (i + 1 < _lowercaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_titlecase_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_titlecase_table[0x%X] = {"
	    @"\n\t", _titlecaseTableSize]];

	for (i = 0; i < _titlecaseTableSize; i++) {
		if (_titlecaseTableUsed[i] == 1) {
			[file writeString: [OFString stringWithFormat:
			    @"titlecasePage%u", i]];
		} else if (_titlecaseTableUsed[i] == 2) {
			[file writeString: [OFString stringWithFormat:
			    @"uppercasePage%u", i]];
		} else
			[file writeString: @"emptyPage"];

		if (i + 1 < _titlecaseTableSize) {
			if ((i + 1) % 4 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

	[file writeString: @"\n};\n\n"];

	/* Write of_unicode_casefolding_table */
	[file writeString: [OFString stringWithFormat:
	    @"const of_unichar_t* const of_unicode_casefolding_table[0x%X] = "
	    @"{\n\t", _casefoldingTableSize]];

	for (i = 0; i < _casefoldingTableSize; i++) {
		if (_casefoldingTableUsed[i] == 1) {
			[file writeString: [OFString stringWithFormat:
			    @"casefoldingPage%u", i]];
		} else if (_casefoldingTableUsed[i] == 2) {
			[file writeString: [OFString stringWithFormat:
			    @"lowercasePage%u", i]];
		} else
			[file writeString: @"emptyPage"];

		if (i + 1 < _casefoldingTableSize) {
			if ((i + 1) % 3 == 0)
				[file writeString: @",\n\t"];
			else
				[file writeString: @", "];
		}
	}

456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
	    @"#import \"OFString.h\"\n\n"];

	[file writeString: [OFString stringWithFormat:
	    @"#define OF_UNICODE_UPPERCASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x%X\n\n",
	    uppercaseTableSize, lowercaseTableSize, titlecaseTableSize,
	    casefoldingTableSize]];

	[file writeString:
	    @"#ifdef __cplusplus\n"
	    @"extern \"C\" {\n"
	    @"#endif\n"
	    @"extern const of_unichar_t* const\n"
	    @"    of_unicode_uppercase_table["







|
|







460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
	    @"#import \"OFString.h\"\n\n"];

	[file writeString: [OFString stringWithFormat:
	    @"#define OF_UNICODE_UPPERCASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x%X\n"
	    @"#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x%X\n\n",
	    _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
	    _casefoldingTableSize]];

	[file writeString:
	    @"#ifdef __cplusplus\n"
	    @"extern \"C\" {\n"
	    @"#endif\n"
	    @"extern const of_unichar_t* const\n"
	    @"    of_unicode_uppercase_table["