/* /usr/local/devel/postgres-v4r2/src/backend/lib/RCS/lisplist.c,v 1.6 1994/02/07 11:55:51 aoki Exp */

#include <varargs.h>
#include "nodes/pg_lisp.h"

/*
 * lispList will take a list of "valid" lispValues
 * and produce a pg_lisp list
 * NOTE: terminates on first "-1" it finds.
 * e.g. lispList ( lispAtom("foo"), lispString("bar"), -1 , x )
 *      will produce ( foo "bar" )
 */

LispValue
MakeList ( va_alist )
va_dcl
{
    va_list args;
    List retval = LispNil;
    List temp = LispNil;
    List tempcons = LispNil;

    va_start(args);

    while ((temp = va_arg(args, LispValue)) != (LispValue) -1) {
	temp = lispCons ( temp, LispNil );
	if ( tempcons == LispNil )
	    retval = temp;
	else
	    CDR(tempcons) = temp;
	tempcons = temp;
    }

    va_end(args);

    return ( retval );
}
