ObjFW  Diff

Differences From Artifact [53b4061156]:

To Artifact [55d286875d]:


80
81
82
83
84
85
86

87

88
89
90












91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105


106
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122







+
-
+



+
+
+
+
+
+
+
+
+
+
+
+


-
-









-
+







{
	return [self stringByXMLUnescapingWithDelegate: nil];
}

- (OFString*)stringByXMLUnescapingWithDelegate:
    (id <OFStringXMLUnescapingDelegate>)delegate
{
	const char *string;
	size_t i, last;
	size_t i, last, length;
	BOOL inEntity;
	OFMutableString *ret;

	string = [self cString];
	length = [self cStringLength];

	ret = [OFMutableString string];

	/*
	 * This is safe as we already called -[cString] on self and thus can be
	 * sure the string is correctly initialized, even if it is a constant
	 * string.
	 */
	((OFString*)ret)->s->isUTF8 = s->isUTF8;

	last = 0;
	inEntity = NO;
	ret = [OFMutableString string];
	((OFString*)ret)->isUTF8 = [self isUTF8];

	for (i = 0; i < length; i++) {
		if (!inEntity && string[i] == '&') {
			[ret appendCStringWithoutUTF8Checking: string + last
						       length: i - last];

			last = i + 1;
			inEntity = YES;
		} else if (inEntity && string[i] == ';') {
			char *entity = string + last;
			const char *entity = string + last;
			size_t entityLength = i - last;

			if (entityLength == 2 && !memcmp(entity, "lt", 2))
				[ret appendCStringWithoutUTF8Checking: "<"
							       length: 1];
			else if (entityLength == 2 && !memcmp(entity, "gt", 2))
				[ret appendCStringWithoutUTF8Checking: ">"
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
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







+
-
+



+
+
+
+
+
+
+
+
+
+
+
+


-
-









-
+







	return ret;
}

#ifdef OF_HAVE_BLOCKS
- (OFString*)stringByXMLUnescapingWithBlock:
    (of_string_xml_unescaping_block_t)block
{
	const char *string;
	size_t i, last;
	size_t i, last, length;
	BOOL inEntity;
	OFMutableString *ret;

	string = [self cString];
	length = [self cStringLength];

	ret = [OFMutableString string];

	/*
	 * This is safe as we already called -[cString] on self and thus can be
	 * sure the string is correctly initialized, even if it is a constant
	 * string.
	 */
	((OFString*)ret)->s->isUTF8 = s->isUTF8;

	last = 0;
	inEntity = NO;
	ret = [OFMutableString string];
	((OFString*)ret)->isUTF8 = [self isUTF8];

	for (i = 0; i < length; i++) {
		if (!inEntity && string[i] == '&') {
			[ret appendCStringWithoutUTF8Checking: string + last
						       length: i - last];

			last = i + 1;
			inEntity = YES;
		} else if (inEntity && string[i] == ';') {
			char *entity = string + last;
			const char *entity = string + last;
			size_t entityLength = i - last;

			if (entityLength == 2 && !memcmp(entity, "lt", 2))
				[ret appendCStringWithoutUTF8Checking: "<"
							       length: 1];
			else if (entityLength == 2 && !memcmp(entity, "gt", 2))
				[ret appendCStringWithoutUTF8Checking: ">"