ObjFW  Diff

Differences From Artifact [250db502f2]:

To Artifact [efdad56a90]:


171
172
173
174
175
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
171
172
173
174
175
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







-
+


+
+
+
+








+

+
+
+
+
+
-
+
+

-

+



-
-
-
+
+
+
-
-
+
+


-





+
+
+
+
+
+







static OFString*
standardize_path(OFArray *components, OFString *currentDirectory,
    OFString *parentDirectory, OFString *joinString)
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableArray *array;
	OFString *ret;
	bool done = false;
	bool done = false, startsWithEmpty, endsWithEmpty;

	array = [[components mutableCopy] autorelease];

	if ((startsWithEmpty = [[array firstObject] isEqual: @""]))
		[array removeObjectAtIndex: 0];
	endsWithEmpty = [[array lastObject] isEqual: @""];

	while (!done) {
		size_t i, length = [array count];

		done = true;

		for (i = 0; i < length; i++) {
			id object = [array objectAtIndex: i];
			id parent;

			if (i > 0)
				parent = [array objectAtIndex: i - 1];
			else
				parent = nil;

			if ([object isEqual: currentDirectory]) {
			if ([object isEqual: currentDirectory] ||
			   [object length] == 0) {
				[array removeObjectAtIndex: i];
				done = false;

				done = false;
				break;
			}

			if ([object isEqual: parentDirectory]) {
				[array removeObjectAtIndex: i];

			if ([object isEqual: parentDirectory] &&
			    parent != nil &&
			    ![parent isEqual: parentDirectory]) {
				if (i > 0)
					[array removeObjectAtIndex: i - 1];
				[array removeObjectsInRange:
				    of_range(i - 1, 2)];

				done = false;

				break;
			}
		}
	}

	if (startsWithEmpty)
		[array insertObject: @""
			    atIndex: 0];
	if (endsWithEmpty)
		[array addObject: @""];

	ret = [[array componentsJoinedByString: joinString] retain];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}