Hi,

On Wed, 18 Jul 2012 21:46:38 +0200 (CEST) Felix 
<[email protected]> wrote:

> From: Peter Bex <[email protected]>
> Subject: Re: [Chicken-hackers] [PATCH] Fix bad call in chicken-install error 
> situation
> Date: Tue, 17 Jul 2012 21:21:55 +0200
>
>> On Mon, Jul 16, 2012 at 02:44:58PM -0400, Mario Domenech Goulart wrote:
>>> Shouldn't `with-default-sources' give something like
>>> 
>>>       (lambda ()
>>>         (with-output-to-port (current-error-port)
>>>           (lambda ()
>>>             (print "Could not determine a source of extensions. "
>>>                    "Please, specify a location and a transport for a 
>>> source.")))
>>>         (exit 1))
>>> 
>>> as the third argument to proc?  Or maybe it could simply abort instead
>>> of calling proc.
>> 
>> I don't know.  This code is confusing.  Maybe Felix can chime in.
>
> Indeed, it is truly horrible. AFAIK "trans" will never be #f, so "next"
> should not be called in "list-available-extensions". Mario's suggestion
> looks correct to me.

Attached is patch. It takes the least intrusive path: it fixes the
number of arguments to `proc' by passing a thunk that will be called as
`next' (it allows for procedures that receive it as argument doing
whatever they want before actually calling `next').  That thunk just
makes the process exit.

Best wishes.
Mario
-- 
http://parenteses.org/mario
>From 8e60a800111595b253fa7688ab83698b33c22e42 Mon Sep 17 00:00:00 2001
From: Mario Domenech Goulart <[email protected]>
Date: Thu, 19 Jul 2012 20:40:25 -0300
Subject: [PATCH] chicken-install: abort when transport and location cannot be
 determined

This patch fixes the number of arguments passed to the procedure given
as argument to `with-default-sources', which would raise an arity
error when transport and location could not be determined (issue found
by Peter Bex).

That procedure is now given a thunk that will properly abort
chicken-install, displaying a meaningful message.
---
 chicken-install.scm |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/chicken-install.scm b/chicken-install.scm
index 2674797..b252e1d 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -339,7 +339,14 @@
   (define (with-default-sources proc)
     (let trying-sources ([defs (known-default-sources)])
       (if (null? defs)
-          (proc #f #f)
+          (proc #f #f
+                (lambda ()
+                  (with-output-to-port (current-error-port)
+                    (lambda ()
+                      (print "Could not determine a source of extensions. "
+                             "Please, specify a location and a transport for "
+                             "a source.")))
+                  (exit 1)))
           (let* ([def (car defs)]
                  [locn (resolve-location
 			(cadr (or (assq 'location def)
-- 
1.7.9.5

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to