--- srfi-1.c.~1.10.~ 2003-07-29 09:50:41.000000000 +1000 +++ srfi-1.c 2003-08-11 12:06:49.000000000 +1000 @@ -382,6 +382,39 @@ #undef FUNC_NAME +/* This routine differs from the core list-copy in allowing improper lists. + Maybe the core could allow them similarly, but for now this code exists + to satisfy the SRFI-1 spec. */ + +SCM_DEFINE (scm_srfi1_list_copy, "list-copy", 1, 0, 0, + (SCM lst), + "Return a copy of the given list @var{lst}. @var{lst} can be a\n" + "proper or improper list. If @var{lst} is not a pair at all\n" + "then it's treated as the final tail of an improper list and\n" + "simply returned.") +#define FUNC_NAME s_scm_srfi1_list_copy +{ + SCM newlst; + SCM * fill_here; + SCM from_here; + + newlst = lst; + fill_here = &newlst; + from_here = lst; + + while (SCM_CONSP (from_here)) + { + SCM c; + c = scm_cons (SCM_CAR (from_here), SCM_CDR (from_here)); + *fill_here = c; + fill_here = SCM_CDRLOC (c); + from_here = SCM_CDR (from_here); + } + return newlst; +} +#undef FUNC_NAME + + /* Typechecking for multi-argument MAP and FOR-EACH. Verify that each element of the vector ARGV, except for the first,