#include<math.h>
#include<string.h>
#define false 0
#define true (!false)
menu(){}
extern int netxt;
gle_redraw(){
	fner("Running Surface");
	netxt = 0;                      /* order of commands was wrong a.r. */
	draw_hidden();
}
find_primcmd(){}
polish(){printf("polish\n"); exit(1); }
polish_eval(){printf("polish_eval\n"); exit(1); }

mystrcpy(char **d,char *s)
{
	if (*d!=0) myfree(*d);
	*d = 0;
	*d = (char *) myallocz(strlen(s)+1);
	strcpy(*d,s);
}
gclip(double *x1,double *y1,double *x2,double *y2
		,double xmin,double ymin,double xmax,double ymax,int *invis)
{
	double dx,dy;

	*invis = true;
	if (*x2 > xmax) {
		if (*x1 > xmax) return;
		dx = *x2 - *x1;
		dy = *y2 - *y1;
		if (dx==0) return;
		*y2 = *y1 + dy*(xmax-*x1)/dx;
		*x2 = xmax;
	}
	if (*x1 > xmax) {
		dx = *x1 - *x2;
		dy = *y1 - *y2;
		if (dx==0) return;
		*y1 = *y2 + dy*(xmax-*x2)/dx;
		*x1 = xmax;
	}
	if (*y2 > ymax) {
		if (*y1 > ymax) return;
		dy = *y2 - *y1;
		dx = *x2 - *x1;
		if (dy==0) return;
		*x2 = *x1 + dx*(ymax-*y1)/dy;
		*y2 = ymax;
	}
	if (*y1 > ymax) {
		dx = *x1 - *x2;
		dy = *y1 - *y2;
		if (dy==0) return;
		*x1 = *x2 + dx*(ymax-*y2)/dy;
		*y1 = ymax ;
	}
	if (*x2 < xmin) {
		if (*x1 < xmin) return;
		dx = *x2 - *x1;
		dy = *y2 - *y1;
		if (dx==0) return;
		*y2 = *y1 + dy*(xmin-*x1)/dx;
		*x2 = xmin;
	}
	if (*x1 < xmin) {
		dx = *x1 - *x2 ;
		dy = *y1 - *y2 ;
		if (dx==0) return;
		*y1 = *y2 + dy*(xmin-*x2)/dx;
		*x1 = xmin;
	}
	if (*y2 < ymin) {
		if (*y1 < ymin) return;
		dy = *y2 - *y1;
		dx = *x2 - *x1;
		if (dy==0) return;
		*x2 = *x1 + dx*(ymin-*y1)/dy;
		*y2 = ymin;
	}
	if (*y1 < ymin) {
		dy = *y1 - *y2;
		dx = *x1 - *x2;
		if (dy==0) return;
		*x1 = *x2 + dx*(ymin-*y2)/dy;
		*y1 = ymin;
	}
	*invis = false;
}
