[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] "tla build-config" question and suggestion
From: |
Ludovic Courtès |
Subject: |
Re: [Gnu-arch-users] "tla build-config" question and suggestion |
Date: |
Fri, 14 Apr 2006 11:24:52 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
Hello Sir,
Thomas Lord <address@hidden> 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.
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, (continued)
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Thomas Lord, 2006/04/12
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Andy Tai, 2006/04/12
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Matthew Hannigan, 2006/04/12
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Pedro Perez, 2006/04/12
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Ludovic Courtès, 2006/04/13
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Andrew Suffield, 2006/04/13
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Thomas Lord, 2006/04/13
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Thomas Lord, 2006/04/13
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Ludovic Courtès, 2006/04/14
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Thomas Lord, 2006/04/14
- Re: [Gnu-arch-users] "tla build-config" question and suggestion,
Ludovic Courtès <=
- Re: [Gnu-arch-users] "tla build-config" question and suggestion, Thomas Lord, 2006/04/14