~ chicken-core (chicken-5) fe34c3bfd667a5a1bb7b61cbf323e51a1bdc1123
commit fe34c3bfd667a5a1bb7b61cbf323e51a1bdc1123
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Tue Jul 14 11:04:42 2015 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Tue Jul 14 11:04:42 2015 +0200
C_build_rest needs to know effective argc
diff --git a/chicken.h b/chicken.h
index 4c5a7b30..660d0b13 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1673,7 +1673,7 @@ C_fctexport C_word C_fcall C_h_intern(C_word *slot, int len, C_char *str) C_regp
C_fctexport C_word C_fcall C_h_intern_in(C_word *slot, int len, C_char *str, C_SYMBOL_TABLE *stable) C_regparm;
C_fctexport C_word C_fcall C_intern2(C_word **ptr, C_char *str) C_regparm;
C_fctexport C_word C_fcall C_intern3(C_word **ptr, C_char *str, C_word value) C_regparm;
-C_fctexport C_word C_fcall C_build_rest(C_word *ptr, C_word n, C_word *av) C_regparm;
+C_fctexport C_word C_fcall C_build_rest(C_word **ptr, C_word c, C_word n, C_word *av) C_regparm;
C_fctexport void C_bad_memory(void) C_noret;
C_fctexport void C_bad_memory_2(void) C_noret;
C_fctexport void C_bad_argc(int c, int n) C_noret;
diff --git a/runtime.c b/runtime.c
index b9f9fb43..0fd9e2ee 100644
--- a/runtime.c
+++ b/runtime.c
@@ -2245,21 +2245,25 @@ C_regparm int C_fcall C_in_fromspacep(C_word x)
/* Cons the rest-aguments together: */
-C_regparm C_word C_fcall C_build_rest(C_word *ptr, C_word n, C_word *av)
+C_regparm C_word C_fcall C_build_rest(C_word **ptr, C_word c, C_word n, C_word *av)
{
- C_word x = C_SCHEME_END_OF_LIST;
+ C_word
+ x = C_SCHEME_END_OF_LIST,
+ *p = *ptr;
C_SCHEME_BLOCK *node;
- av += n;
- while(--n) {
- node = (C_SCHEME_BLOCK *)ptr;
- ptr += 3;
+ av += c;
+
+ while(--c >= n) {
+ node = (C_SCHEME_BLOCK *)p;
+ p += 3;
node->header = C_PAIR_TYPE | (C_SIZEOF_PAIR - 1);
node->data[ 0 ] = *(--av);
node->data[ 1 ] = x;
x = (C_word)node;
}
+ *ptr = p;
return x;
}
Trap