Differences From Artifact [250db502f2]:
- File src/OFString.m — part of check-in [590c377d8a] at 2013-04-26 19:42:52 on branch trunk — Make it possible to disable sockets. (user: js, size: 56139) [annotate] [blame] [check-ins using]
To Artifact [efdad56a90]:
- File
src/OFString.m
— part of check-in
[379d75e1bc]
at
2013-06-17 09:36:34
on branch trunk
— OFString: Fix standardize_path().
It still needs some more special casing for Windows. (user: js, size: 56600) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
171 172 173 174 175 176 177 | static OFString* standardize_path(OFArray *components, OFString *currentDirectory, OFString *parentDirectory, OFString *joinString) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *array; OFString *ret; | | > > > > > > > > > > | > < > | | | < | > < > > > > > > | 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, 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] || [object length] == 0) { [array removeObjectAtIndex: i]; done = false; break; } if ([object isEqual: parentDirectory] && parent != nil && ![parent isEqual: parentDirectory]) { [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]; } |
︙ | ︙ |