From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: port-filename and path canonicalization Date: Thu, 22 Apr 2010 13:10:55 +0200 Message-ID: References: <878w8jyr3w.fsf@gnu.org> <87iq7mrrj0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1271935880 4684 80.91.229.12 (22 Apr 2010 11:31:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 22 Apr 2010 11:31:20 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Apr 22 13:31:18 2010 connect(): No such file or directory Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O4ucl-00085k-AM for guile-devel@m.gmane.org; Thu, 22 Apr 2010 13:31:15 +0200 Original-Received: from localhost ([127.0.0.1]:33845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4uck-0007dr-Gb for guile-devel@m.gmane.org; Thu, 22 Apr 2010 07:31:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4ubc-0006EV-JL for guile-devel@gnu.org; Thu, 22 Apr 2010 07:30:04 -0400 Original-Received: from [140.186.70.92] (port=60736 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4ubb-0006Dh-7e for guile-devel@gnu.org; Thu, 22 Apr 2010 07:30:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4ubW-0002R9-JY for guile-devel@gnu.org; Thu, 22 Apr 2010 07:30:02 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:57651 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4ubW-0002R3-DE; Thu, 22 Apr 2010 07:29:58 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 3D10FAD71A; Thu, 22 Apr 2010 07:29:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=NUQN1ygfD3/H uoXQH7naWgq99rk=; b=O414+pAu0+aLH48PC28XMd/A3cw97DTHdy3pj0UZ9h/t fnJYnhLhN1XU+Dd/sc7jHpsOamvBQszBCcuBj9OfErivMutr11FHHIzW1ZrQ6lfh EIsYXCNCH4BlmgBOJY2bPO5QJ9HEQRseR8kY7/LvBBT6LvwqvUTYDVqLwkJC99o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=CknOf/ bDnVsPl0ykUf8VMPBpKUbfJjaBCHLQWweO5tJmxcN3JoQN5TyMT5WqMpgyNpg7bU Ebh61sTIOBOdr16UJHXHAz6paJiUKxRGwPyjDx0Ck0JL9lziFp9BipfX+J6ZXc5o QSyQ0l7YA+xJSYojSKJC0yU1TB6KGz+rSpwSU= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 26F41AD719; Thu, 22 Apr 2010 07:29:57 -0400 (EDT) Original-Received: from unquote (unknown [83.202.100.241]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 87CBFAD718; Thu, 22 Apr 2010 07:29:55 -0400 (EDT) In-Reply-To: <87iq7mrrj0.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 20 Apr 2010 18:57:07 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: 6127D2E6-4E02-11DF-A622-D033EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10287 Archived-At: Hi Ludovic, On Tue 20 Apr 2010 18:57, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> 2. I think a fluid is still necessary, because a file being >> compiled can do an `include' or `include-from-path', or even >> `open-input-file' in a macro, and all these cases you would want the >> same %file-port-name-canonicalization to take effect. > > Indeed, this one is tricky. > > I still think it=E2=80=99s application-specific, though. How about calli= ng the > fluid, say, %compiler-file-name-canonicalization instead? :-) Are you proposing that all file-opening functions check the %compiler-file-name-canonicalization fluid? Seems better to me for the name of the fluid to be "close" to the function whose behavior it changes. >> 4. The application-level code is nastier if it has to canonicalize, >> because a relative canonicalization > > What do you mean by =E2=80=9Crelative canonicalization=E2=80=9D? > > (I have Glibc=E2=80=99s =E2=80=98canonicalize_file_name ()=E2=80=99 in mi= nd, which returns an > absolute path, so I=E2=80=99m confused.) > >> cannot in general be passed to open-input-file. For example >> >> (open-input-file "../../module/ice-9/boot-9.scm") >> >> is not the same as >> >> (open-input-file "ice-9/boot-9.scm") > > Agreed. :-) If you build out-of-source, you might end up with guile-tools compile -o ice-9/boot-9.go ../../modules/ice-9/boot-9.scm So the file you open is "../../modules/ice-9/boot-9.scm", but you want to give it a "relative canonicalization" -- in this case "ice-9/boot-9.scm" is the canonicalization of ../../modules/ice-9/boot-9.scm, *relative* to "../../modules" (or indeed to "/home/wingo/src/guile/modules"). >> So you'd have to do a set-port-filename! on the port, mucking up your >> code -- and how would you decide what to set? In N places you'd have to >> duplicate fport_canonicalize_filename, and you'd probably have to make >> scm_i_relativize_path public. > > I failed to get the transition at =E2=80=9CSo=E2=80=9D. :-) > > What does scm_i_relativize_path do? (It lacks a leading comment, hint > hint. ;-)) You could try a little harder ;-) Perhaps the paragraph above explains; you would have to do: (define (open-input-file* path) (let ((p (open-input-file path))) (case (fluid-ref %file-port-name-canonicalization) ((absolute) (set-port-filename! p (canonicalize-path path))) ((relative) (set-port-filename! p (relativize-path (canonicalize-path path) %l= oad-path)))) p)) which is a bit ugly; e.g. include-from-path would need to do this, as would any third-party equivalent of include-from-path, and even down to the open-file level. Yuk. Andy --=20 http://wingolog.org/