ObjFW  Diff

Differences From Artifact [223d3e3c81]:

To Artifact [800379d99e]:


23
24
25
26
27
28
29













30




31
32
33
34
35
36
37
#import "OFOutOfRangeException.h"

int _OFString_PathAdditions_reference;

@implementation OFString (PathAdditions)
+ (OFString *)pathWithComponents: (OFArray *)components
{













	return [components componentsJoinedByString: @"/"];




}

- (bool)isAbsolutePath
{
	return [self hasPrefix: @"/"];
}








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







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#import "OFOutOfRangeException.h"

int _OFString_PathAdditions_reference;

@implementation OFString (PathAdditions)
+ (OFString *)pathWithComponents: (OFArray *)components
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret;

	if ([[components firstObject] isEqual: @"/"]) {
		OFMutableArray OF_GENERIC(OFString *) *mutableComponents =
		    [[components mutableCopy] autorelease];

		[mutableComponents replaceObjectAtIndex: 0
					     withObject: @""];

		components = mutableComponents;
	}

	ret = [components componentsJoinedByString: @"/"];

	[ret retain];
	objc_autoreleasePoolPop(pool);
	return [ret autorelease];
}

- (bool)isAbsolutePath
{
	return [self hasPrefix: @"/"];
}

56
57
58
59
60
61
62




63
64
65
66
67
68
69
			    [OFString stringWithUTF8String: cString + last
						    length: i - last]];
			last = i + 1;
		}
	}
	[ret addObject: [OFString stringWithUTF8String: cString + last
						length: i - last]];





	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}







>
>
>
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
			    [OFString stringWithUTF8String: cString + last
						    length: i - last]];
			last = i + 1;
		}
	}
	[ret addObject: [OFString stringWithUTF8String: cString + last
						length: i - last]];

	if ([[ret firstObject] isEqual: @""])
		[ret replaceObjectAtIndex: 0
			       withObject: @"/"];

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}
208
209
210
211
212
213
214
215
216
217
218
219










220




221
222
223
224
225
226
227
228
229
230
231
	objc_autoreleasePoolPop(pool);
	return [ret autorelease];
}

- (OFString *)stringByStandardizingPath
{
	void *pool = objc_autoreleasePoolPush();
	OFArray OF_GENERIC(OFString *) *components = [self pathComponents];
	OFMutableArray OF_GENERIC(OFString *) *array;
	OFString *ret;
	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 length = [array count];

		done = true;

		for (size_t i = 0; i < length; i++) {







|

|
|

>
>
>
>
>
>
>
>
>
>

>
>
>
>

|

<







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
	objc_autoreleasePoolPop(pool);
	return [ret autorelease];
}

- (OFString *)stringByStandardizingPath
{
	void *pool = objc_autoreleasePoolPush();
	OFArray OF_GENERIC(OFString *) *components;
	OFMutableArray OF_GENERIC(OFString *) *array;
	OFString *firstComponent, *ret;
	bool done = false, startsWithSlash, endsWithEmpty;

	if ([self length] == 0)
		return @"";

	components = [self pathComponents];

	if ([components count] == 1) {
		objc_autoreleasePoolPop(pool);
		return self;
	}

	array = [[components mutableCopy] autorelease];
	firstComponent = [array firstObject];
	startsWithSlash =
	    ([firstComponent isEqual: @"/"] || [firstComponent length] == 0);
	endsWithEmpty = ([[array lastObject] length] == 0);

	if (startsWithSlash)
		[array removeObjectAtIndex: 0];


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

		done = true;

		for (size_t i = 0; i < length; i++) {
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264

				done = false;
				break;
			}
		}
	}

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

	if (endsWithEmpty)
		[array addObject: @""];

	ret = [[array componentsJoinedByString: @"/"] retain];

	objc_autoreleasePoolPop(pool);








|


>







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299

				done = false;
				break;
			}
		}
	}

	if (startsWithSlash)
		[array insertObject: @""
			    atIndex: 0];

	if (endsWithEmpty)
		[array addObject: @""];

	ret = [[array componentsJoinedByString: @"/"] retain];

	objc_autoreleasePoolPop(pool);