/**********************************************************************
 
	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	"long_char.h"

void
set_convert(WCT * w,
	L_CHAR from,L_CHAR mask,
	L_CHAR to,
	int flag)
{
WRITABLE_CODE_TABLE * t;
L_CHAR _to;
	t = get_wct(w,to);
	if ( t ) {
		_to = t->tbl[(~t->mask)&to];
		if ( _to )
			to = _to;
	}
	t = get_wct(w,from);
	if ( t == 0 ) {
		t = set_wct(w,from&mask,mask,0,0);
		t->tbl[(~mask)&from] = to;
	}
	else {
		mask = t->mask;
		if ( flag == SC_ALL )
			t->tbl[(~mask)&from] = to;
		else if ( t->tbl[(~mask)&from] == 0 )
			t->tbl[(~mask)&from] = to;
	}
}
