chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Simplify get-environment-variable and ##sy


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Simplify get-environment-variable and ##sys#get-argument
Date: Sat, 2 Mar 2013 14:25:14 +0100
User-agent: Mutt/1.4.2.3i

On Sat, Mar 02, 2013 at 01:33:21PM +0100, Christian Kellermann wrote:
> I have checked the usage of ##sys#get-argument and it has been used
> only to get the program name and none of the (SVN) eggs used it.
> So I took the liberty of changing the patch to get rid of it. As
> it is the version is not safe when passing negative indices (as you
> mentioned on #chicken, this has been unsafe in the original version
> too).

If we're going to do this, we might as wel simplify further and get rid
of the check altogether, since we fully control how it's being called.
The attached patch simply loops from argc-1 to 0 and fetches the argument
from there, consing it onto the result.  By doing it back-to-front, no
call to reverse is needed.

I've converted to scheme-object to avoid any extra argument checking
for fixnum, which means now we're only relying on the FFI for copying
the return string.

Also, I noticed program-name was checking whether argv was null, rather
than checking whether its return value was null.  That's now fixed.

Cheers,
Peter
-- 
http://www.more-magic.net

Attachment: 0001-Remove-sys-get-argument-and-simplify-get-environment.patch
Description: Text document


reply via email to

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