From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: include can't work Date: Sat, 16 Nov 2013 23:33:08 -0500 Message-ID: <87fvqv8x6j.fsf@netris.org> References: <1384501247.11916.8.camel@Renee-desktop.suse> <87txfb90m2.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1384662842 19065 80.91.229.3 (17 Nov 2013 04:34:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Nov 2013 04:34:02 +0000 (UTC) Cc: guile-devel@gnu.org To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Nov 17 05:34:05 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vhu3f-0006zd-6h for guile-devel@m.gmane.org; Sun, 17 Nov 2013 05:34:03 +0100 Original-Received: from localhost ([::1]:37957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vhu3e-0005p5-MI for guile-devel@m.gmane.org; Sat, 16 Nov 2013 23:34:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vhu3T-0005eD-Nk for guile-devel@gnu.org; Sat, 16 Nov 2013 23:33:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vhu3N-00085H-Ja for guile-devel@gnu.org; Sat, 16 Nov 2013 23:33:51 -0500 Original-Received: from world.peace.net ([96.39.62.75]:46788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vhu3N-000858-AJ for guile-devel@gnu.org; Sat, 16 Nov 2013 23:33:45 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Vhu3D-0001OM-OR; Sat, 16 Nov 2013 23:33:36 -0500 In-Reply-To: <87txfb90m2.fsf@netris.org> (Mark H. Weaver's message of "Sat, 16 Nov 2013 22:19:01 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16737 Archived-At: --=-=-= Content-Type: text/plain Mark H Weaver writes: > Obviously the error message should be improved, but the upshot is this: > if you want to use 'include' from the REPL, or from some other port with > no associated filename, then you must pass it an absolute pathname. Here's a patch to improve the error message. I'll push it to stable-2.0 if there are no objections. Thanks, Mark --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Improve-error-when-include-form-with-relative-path-i.patch Content-Description: [PATCH] Improve error when 'include' form with relative path is not in a file >From bd2db5da3210887d1a128f186851a780c0166b24 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sat, 16 Nov 2013 23:24:42 -0500 Subject: [PATCH] Improve error when 'include' form with relative path is not in a file. Reported by Nala Ginrut . * module/ice-9/psyntax.scm (include): Give a proper error message when given a relative pathname, and when the form is not in a file. * module/ice-9/psyntax-pp.scm: Regenerate. --- module/ice-9/psyntax-pp.scm | 9 ++++++++- module/ice-9/psyntax.scm | 12 +++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm index 254f701..3928bed 100644 --- a/module/ice-9/psyntax-pp.scm +++ b/module/ice-9/psyntax-pp.scm @@ -2974,7 +2974,14 @@ ((read-file (lambda (fn dir k) (let ((p (open-input-file - (if (absolute-file-name? fn) fn (in-vicinity dir fn))))) + (if (absolute-file-name? fn) + fn + (if dir + (in-vicinity dir fn) + (syntax-violation + 'include + "relative pathname only allowed when the include form is in a file" + x)))))) (let ((enc (file-encoding p))) (set-port-encoding! p (let ((t enc)) (if t t "UTF-8"))) (let f ((x (read p)) (result '())) diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 576fc3f..84b2ef9 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -2952,9 +2952,15 @@ (define read-file (lambda (fn dir k) (let* ((p (open-input-file - (if (absolute-file-name? fn) - fn - (in-vicinity dir fn)))) + (cond ((absolute-file-name? fn) + fn) + (dir + (in-vicinity dir fn)) + (else + (syntax-violation + 'include + "relative pathname only allowed when the include form is in a file" + x))))) (enc (file-encoding p))) ;; Choose the input encoding deterministically. -- 1.7.5.4 --=-=-=--