ObjFW  Diff

Differences From Artifact [5528604b06]:

To Artifact [3aa7e5466a]:


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
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







-
-
+
+



-
+







-
+







	if (freeWhenDone)
		free(UTF8String);

	return self;
}

#ifdef OF_HAVE_UNICODE_TABLES
- (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable
		     wordMiddleTable: (const of_unichar_t *const [])middleTable
- (void)of_convertWithWordStartTable: (const OFUnichar *const [])startTable
		     wordMiddleTable: (const OFUnichar *const [])middleTable
		  wordStartTableSize: (size_t)startTableSize
		 wordMiddleTableSize: (size_t)middleTableSize
{
	of_unichar_t *unicodeString;
	OFUnichar *unicodeString;
	size_t unicodeLen, newCStringLength;
	size_t i, j;
	char *newCString;
	bool isStart = true;

	if (!_s->isUTF8) {
		uint8_t t;
		const of_unichar_t *const *table;
		const OFUnichar *const *table;

		assert(startTableSize >= 1 && middleTableSize >= 1);

		_s->hashed = false;

		for (i = 0; i < _s->cStringLength; i++) {
			if (isStart)
95
96
97
98
99
100
101
102

103
104
105
106
107
108

109
110

111
112
113
114
115
116
117
95
96
97
98
99
100
101

102
103
104
105
106
107

108
109

110
111
112
113
114
115
116
117







-
+





-
+

-
+







				_s->cString[i] = t;
		}

		return;
	}

	unicodeLen = self.length;
	unicodeString = of_alloc(unicodeLen, sizeof(of_unichar_t));
	unicodeString = of_alloc(unicodeLen, sizeof(OFUnichar));

	i = j = 0;
	newCStringLength = 0;

	while (i < _s->cStringLength) {
		const of_unichar_t *const *table;
		const OFUnichar *const *table;
		size_t tableSize;
		of_unichar_t c;
		OFUnichar c;
		ssize_t cLen;

		if (isStart) {
			table = startTable;
			tableSize = middleTableSize;
		} else {
			table = middleTable;
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139







-
+







			free(unicodeString);
			@throw [OFInvalidEncodingException exception];
		}

		isStart = of_ascii_isspace(c);

		if (c >> 8 < tableSize) {
			of_unichar_t tc = table[c >> 8][c & 0xFF];
			OFUnichar tc = table[c >> 8][c & 0xFF];

			if (tc)
				c = tc;
		}
		unicodeString[j++] = c;

		if (c < 0x80)
185
186
187
188
189
190
191
192

193
194
195

196
197
198
199
200
201
202
185
186
187
188
189
190
191

192
193
194

195
196
197
198
199
200
201
202







-
+


-
+







	/*
	 * Even though cStringLength can change, length cannot, therefore no
	 * need to change it.
	 */
}
#endif

- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx
- (void)setCharacter: (OFUnichar)character atIndex: (size_t)idx
{
	char buffer[4];
	of_unichar_t c;
	OFUnichar c;
	size_t lenNew;
	ssize_t lenOld;

	if (_s->isUTF8)
		idx = of_string_utf8_get_position(_s->cString, idx,
		    _s->cStringLength);

365
366
367
368
369
370
371
372

373
374
375
376
377
378
379
365
366
367
368
369
370
371

372
373
374
375
376
377
378
379







-
+







	    [string isKindOfClass: [OFMutableUTF8String class]]) {
		if (((OFMutableUTF8String *)string)->_s->isUTF8)
			_s->isUTF8 = true;
	} else
		_s->isUTF8 = true;
}

- (void)appendCharacters: (const of_unichar_t *)characters
- (void)appendCharacters: (const OFUnichar *)characters
		  length: (size_t)length
{
	char *tmp = of_alloc((length * 4) + 1, 1);

	@try {
		size_t j = 0;
		bool isUTF8 = false;