From 3202b82c27a23b4f48533e65a2dcaaf254a6a79b Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Sat, 12 Mar 2011 03:45:00 -0500
Subject: [PATCH] Pd-0.42.5-extended-l2ork-dev-20110312.tar.bz2

---
 src/m_binbuf.c | 22 ++++++++++++++--------
 src/m_pd.h     |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/m_binbuf.c b/src/m_binbuf.c
index 917680426..47fca2f8c 100644
--- a/src/m_binbuf.c
+++ b/src/m_binbuf.c
@@ -608,9 +608,16 @@ void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
     t_atom *at = x->b_vec;
     int ac = x->b_n;
     int nargs, maxnargs = 0;
-    //if (ac <= SMALLMSG)
-	//IB added ac > argc check to allow for proper $@ arg (list) allocation
-    if (ac <= SMALLMSG && ac > argc)
+	//first we need to check if the list of arguments has $@
+	int count;
+	for (count = 0; count < ac; count++) {
+		if (at[count].a_type == A_DOLLAR && at[count].a_w.w_symbol==gensym("@")) {
+			//fprintf(stderr,"yes %d %d %d\n", ac, argc, ac+argc-1);
+			ac = ac + argc;
+		}
+	}
+
+    if (ac <= SMALLMSG)
         mstack = smallstack;
     else
     {
@@ -623,15 +630,13 @@ void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
             destination in the message, only because the original "target"
             points there. */
         if (target == &pd_objectmaker) {
-			//IB added ac > argc check to allow for proper $@ arg (list) allocation
-            maxnargs = (ac > argc ? ac : argc+1);
-			//if (at && x->b_n) 
-			//	fprintf(stderr,"pd_objectmaker %s %d\n", at[0].a_w.w_symbol->s_name, maxnargs);
+            maxnargs = ac;
+			//if (at && x->b_n) fprintf(stderr,"pd_objectmaker %s %d %d %d\n", at[0].a_w.w_symbol->s_name, ac, argc, maxnargs);
 		}
         else
         {
             int i, j = (target ? 0 : -1);
-            for (i = 0; i < (ac > argc ? ac : argc); i++)
+            for (i = 0; i < ac; i++)
             {
                 if (at[i].a_type == A_SEMI)
                     j = -1;
@@ -755,6 +760,7 @@ void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
                     {
                         *msp++=argv[i];
                         nargs++;
+						ac--;
                     }
                     msp--;
                     nargs--;
diff --git a/src/m_pd.h b/src/m_pd.h
index ad6b976be..f1c4f95b0 100644
--- a/src/m_pd.h
+++ b/src/m_pd.h
@@ -11,7 +11,7 @@ extern "C" {
 #define PD_MAJOR_VERSION 0
 #define PD_MINOR_VERSION 42
 #define PD_BUGFIX_VERSION 5
-#define PD_TEST_VERSION "extended-l2ork-20110310"
+#define PD_TEST_VERSION "extended-l2ork-20110312"
 
 /* old name for "MSW" flag -- we have to take it for the sake of many old
 "nmakefiles" for externs, which will define NT and not MSW */
-- 
GitLab