gnu-arch-users
[Top][All Lists]
Advanced

[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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]