/*  GUBI - Gtk+ User Interface Builder
 *  Copyright (C) 1997	Tim Janik	<timj@psynet.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* RCS_ID("$Id: write_cond.txt,v 1.3 1997/08/18 03:41:07 timj Exp timj $")
*/
/*
	this file is dedicated to the question:
	should a target file be (over-)written or not?
	i wrote it down, because i got confused about
	this question, while checking it on the fly...
	
	we have the following basic condidtions:
	
	existence	does a target file already exist?
	update		should the file be updated?
	dynamic		is the file dynamic?
	tuncate		are we allowed to truncate the (dynamic) file?
	
	this makes up the following boolean table:
	
	Exists |Update |Dynamic	|Trunc |Action
	-------+-------+--------+------+-------
	   0   |   0   |   0   |   0   | Write
	   0   |   0   |   0   |   1   | Write
	   0   |   0   |   1   |   0   | Write
	   0   |   0   |   1   |   1   | Write
	   0   |   1   |   0   |   0   | Skip
	   0   |   1   |   0   |   1   | Skip
	   0   |   1   |   1   |   0   | Write
	   0   |   1   |   1   |   1   | Write
	   1   |   0   |   0   |   0   | Write
	   1   |   0   |   0   |   1   | Write
	   1   |   0   |   1   |   0   | Skip	*)
	   1   |   0   |   1   |   1   | Write
	   1   |   1   |   0   |   0   | Skip
	   1   |   1   |   0   |   1   | Skip
	   1   |   1   |   1   |   0   | Skip
	   1   |   1   |   1   |   1   | Write
	
	    *)	this is a little bit tricky:
		the file should be written anyway
		and is dynamic, but it already exists and
		we are not allowed to truncate it.
		for safty we skip writing it, because
		this mode (dynamic & !truncate) is aplied
		only to such files that ought to be modified
		by the user (e.g. ufunc.c).
		this behaviour can be overidden by the overwrite
		existing files flag of the builder options.
	
	therefore we get the following rule:
	
	W = (!E & !U) | (!E & U & D) | (E & !U & !D) | (E & D & T)
	
	shortened this is:
	
	W = (!E & (!U | D)) | (E & ( (!U & !D) | (D & T) ) )
	
	so we get the following macro...
	
*/

#define	_WRITE_TARGET_OK_(E,U,D,T)	((!E&(!U|D))|(E&((!U&!D)|(D&T))))
#define	WRITE_TARGET_OK(E,U,D,T)	(_WRITE_TARGET_OK_((E),(U),(D),(T)))
