ObjFW  Diff

Differences From Artifact [cf929b13b9]:

To Artifact [5595432660]:


122
123
124
125
126
127
128
129

130
131
132
133
134
135


136
137
138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158


159
160
161
162


163
164
165
166
167
168
169
122
123
124
125
126
127
128

129
130
131
132
133


134
135
136
137
138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
154
155
156


157
158
159
160


161
162
163
164
165
166
167
168
169







-
+




-
-
+
+










-
+










-
-
+
+


-
-
+
+







{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	char *str_c;
	size_t len, i, j, attrs_count;
	OFXMLAttribute **attrs_data;
	OFString *ret, *tmp;

	len = [name length] + 4;
	len = [name cStringLength] + 4;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	*str_c = '<';
	memcpy(str_c + 1, [name cString], [name length]);
	i = [name length] + 1;
	memcpy(str_c + 1, [name cString], [name cStringLength]);
	i = [name cStringLength] + 1;

	/* Attributes */
	attrs_data = [attrs data];
	attrs_count = [attrs count];

	for (j = 0; j < attrs_count; j++) {
		/* FIXME: Add namespace support */
		OFString *attr_name = [attrs_data[j] name];
		tmp = [[attrs_data[j] stringValue] stringByXMLEscaping];

		len += [attr_name length] + [tmp length] + 4;
		len += [attr_name cStringLength] + [tmp cStringLength] + 4;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
			@throw e;
		}

		str_c[i++] = ' ';
		memcpy(str_c + i, [attr_name cString],
				[attr_name length]);
		i += [attr_name length];
				[attr_name cStringLength]);
		i += [attr_name cStringLength];
		str_c[i++] = '=';
		str_c[i++] = '\'';
		memcpy(str_c + i, [tmp cString], [tmp length]);
		i += [tmp length];
		memcpy(str_c + i, [tmp cString], [tmp cStringLength]);
		i += [tmp cStringLength];
		str_c[i++] = '\'';

		[pool releaseObjects];
	}

	/* Childen */
	if (stringval != nil || children != nil) {
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
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







-
+









-
-
+
+


-
-
+
+








			for (j = 0; j < count; j++)
				append(tmp, @selector(
				    appendCStringWithoutUTF8Checking:),
				    [[data[j] string] cString]);
		}

		len += [tmp length] + [name length] + 2;
		len += [tmp cStringLength] + [name cStringLength] + 2;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
			@throw e;
		}

		str_c[i++] = '>';
		memcpy(str_c + i, [tmp cString], [tmp length]);
		i += [tmp length];
		memcpy(str_c + i, [tmp cString], [tmp cStringLength]);
		i += [tmp cStringLength];
		str_c[i++] = '<';
		str_c[i++] = '/';
		memcpy(str_c + i, [name cString], [name length]);
		i += [name length];
		memcpy(str_c + i, [name cString], [name cStringLength]);
		i += [name cStringLength];
	} else
		str_c[i++] = '/';

	str_c[i++] = '>';
	str_c[i++] = '\0';
	assert(i == len);