From: David Kastrup Date: Wed, 23 Sep 2015 19:50:39 +0000 (+0200) Subject: Issue 4618: Correct argument handling of Unpure_pure_call::call X-Git-Tag: release/2.19.29-1~41 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=7b8fc6cb7d8ed1b072b7027ad5035ff90f8dfabc;p=lilypond.git Issue 4618: Correct argument handling of Unpure_pure_call::call When ly:make-unpure-pure-container is called with a single procedure argument, this procedure is used for both unpure and pure calls. It turns out that the calling convention in call_pure_function places the start/end arguments always in position 2/3 of the call. Unpure_pure_call::call previously always dropped the last 2 arguments of a pure call before passing the rest on. Most calls take exactly 3 arguments (grob start end) where this does not make a difference, but there may be use cases with a different number of arguments. --- diff --git a/lily/unpure-pure-container.cc b/lily/unpure-pure-container.cc index 2dff6eea99..81bba591e4 100644 --- a/lily/unpure-pure-container.cc +++ b/lily/unpure-pure-container.cc @@ -19,18 +19,21 @@ */ #include "unpure-pure-container.hh" -// Reroutes a call to the contained function after dropping last two -// arguments. Used for applying an "unpure" function in a "pure" +// Reroutes a call to the contained function after dropping second and +// third argument. Used for applying an "unpure" function in a "pure" // context. class Unpure_pure_call : public Smob1 { public: + // Smob procedures unfortunately can only take at most 3 SCM + // arguments. Otherwise we could use a "3, 0, 1" call signature and + // not require an argument count check of our own. LY_DECLARE_SMOB_PROC (&Unpure_pure_call::call, 2, 0, 1) - SCM call (SCM arg1, SCM arg2, SCM rest) + SCM call (SCM arg1, SCM, SCM rest) { - return scm_apply_0 (scm1 (), - scm_list_head (scm_cons2 (arg1, arg2, rest), - scm_length (rest))); + if (!scm_is_pair (rest)) + scm_wrong_num_args (scm1 ()); + return scm_apply_1 (scm1 (), arg1, scm_cdr (rest)); } };