ObjFW  Diff

Differences From Artifact [684f4e251d]:

To Artifact [4bf97fa647]:


1134
1135
1136
1137
1138
1139
1140



































































1141
1142
1143
1144
1145
1146
1147
		objc_autoreleasePoolPop(pool);
	}

	[ret makeImmutable];

	return ret;
}




































































- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>",
					   [self class], [self string]];
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
		objc_autoreleasePoolPop(pool);
	}

	[ret makeImmutable];

	return ret;
}

- (OFURL *)URLByStandardizingPath
{
	void *pool;
	OFMutableArray OF_GENERIC(OFString *) *array;
	bool done = false, endsWithEmpty;
	OFString *path;
	OFMutableURL *URL;

	if (_URLEncodedPath == nil)
		return self;

	pool = objc_autoreleasePoolPush();

	array = [[[_URLEncodedPath
	    componentsSeparatedByString: @"/"] mutableCopy] autorelease];

	if ([[array firstObject] length] != 0)
		@throw [OFInvalidFormatException exception];

	endsWithEmpty = ([[array lastObject] length] == 0);

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

		done = true;

		for (size_t i = 0; i < length; i++) {
			id object = [array objectAtIndex: i];
			id parent =
			    (i > 0 ? [array objectAtIndex: i - 1] : nil);

			if ([object isEqual: @"."] || [object length] == 0) {
				[array removeObjectAtIndex: i];

				done = false;
				break;
			}

			if ([object isEqual: @".."] && parent != nil &&
			    ![parent isEqual: @".."]) {
				[array removeObjectsInRange:
				    of_range(i - 1, 2)];

				done = false;
				break;
			}
		}
	}

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

	path = [array componentsJoinedByString: @"/"];
	if ([path length] == 0)
		path = @"/";

	URL = [[self mutableCopy] autorelease];
	[URL setURLEncodedPath: path];
	[URL makeImmutable];

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

- (OFString *)description
{
	return [OFString stringWithFormat: @"<%@: %@>",
					   [self class], [self string]];
}