1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

(scm_cons_star): Don't modify the rest list, it belongs to

the caller when cons* is reached through apply.
This commit is contained in:
Kevin Ryde 2005-04-22 23:18:59 +00:00
parent 01adf598d9
commit b906b056e4

View file

@ -119,18 +119,20 @@ SCM_DEFINE (scm_cons_star, "cons*", 1, 0, 1,
"Schemes and in Common LISP.") "Schemes and in Common LISP.")
#define FUNC_NAME s_scm_cons_star #define FUNC_NAME s_scm_cons_star
{ {
SCM ret = SCM_EOL;
SCM *p = &ret;
SCM_VALIDATE_REST_ARGUMENT (rest); SCM_VALIDATE_REST_ARGUMENT (rest);
if (!scm_is_null (rest))
for ( ; scm_is_pair (rest); rest = SCM_CDR (rest))
{ {
SCM prev = arg = scm_cons (arg, rest); *p = scm_cons (arg, SCM_EOL);
while (!scm_is_null (SCM_CDR (rest))) p = SCM_CDRLOC (*p);
{ arg = SCM_CAR (rest);
prev = rest;
rest = SCM_CDR (rest);
} }
SCM_SETCDR (prev, SCM_CAR (rest));
} *p = arg;
return arg; return ret;
} }
#undef FUNC_NAME #undef FUNC_NAME