Re: "tla build-config" question and suggestion
[email protected] (Ludovic Courtès)
| Newsgroups | gmane.comp.version-control.arch.user |
|---|---|
| Organization | LAAS-CNRS |
| Message-ID | <[email protected]> |
Hello Sir, Thomas Lord <[email protected]> writes: > Ok, yr just f'ing around now, right? (Looks like the communication channel discarded a few bytes.) > I mean, you do understand that the paths in question *don't exist* at the > point in time where canonicalization is desired, right? And therefore > the functions you mention can not possibly do a Right Thing. Oh right. Indeed, I was a bit sloppy, sorry about that. Anyway, I guess you'd agree that `is_non_upwards_relative_path ()' could also be fixed quite trivially (let alone symlinks first). Roughly (in Scheme): (define (canonicalize-path path) (let loop ((path (string-split path #\/)) (result '())) (if (null? path) (fold (lambda (comp res) (if (string=? res "") comp (string-append res "/" comp))) "" (reverse! result)) (loop (cdr path) (let ((component (car path))) (cond ((string=? component "..") (if (null? result) (error "breaking out of tree root" path) (cdr result))) ((string=? component ".") result) (else (cons component result)))))))) I admit that implementing it in C would be a bit harder, though not unfeasible. IMO, that's typically the kind of functionality we'd expect from the C library instead of having to roll our own every time... Thanks, Ludovic.