/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/



#include	<stdio.h>
#include	"xl.h"
#include	"memory_routine.h"



XL_SEXP *
xor_int(XLISP_ENV * env,XL_SEXP * s1,XL_SEXP * s2)
{
L_CHAR * unit;
	if ( s1->integer.unit )
		unit = s1->integer.unit;
	else 	unit = s2->integer.unit;
	return get_integer(
		((~s1->integer.data)&s2->integer.data) |
		(s1->integer.data&(~s2->integer.data)),
		unit);
}


XL_SEXP *
gb_xor(XLISP_ENV * e,XL_SEXP * s)
{
extern BINARY_TABLE xor_t[XLT_MAX][XLT_MAX];
XL_SEXP * rr;
XL_SEXP * ret;
	rr = cdr(cdr(s));
	ret = get_el(s,1);
	for ( ; get_type(rr) ; rr = cdr(rr) )
		ret = binary(
			xor_t,
			e,
			ret,
			car(rr));
	return ret;
}
