#include	"ksysdefs.h"
#include	"ksysvtyp.h"
#include	"ksysprot.h"
extern	char	*hassubstr();
KENV	kenv;
void
terror(ty)
int		ty;
{
	exit(ty);
}
main()
{
	auto	char	os[FNMSIZ];
	auto	char	is[FNMSIZ];
	auto	char	ss[FNMSIZ];
	auto	char	ls[FNMSIZ];
	while(putchar('?'),fflush(stdout),gets(ls))
		switch(ls[0])	{
			case	'q':	exit(0);
			case	'<':	strcpy(os,ls+1);break;
			case	'>':	strcpy(is,ls+1);break;
			case	'#':	strcpy(ss,ls+1);break;
			case	'$':	puts(hassubstr(os,is,ss));break;
			case	'?':	
							printf("<%s\n",os);
							printf(">%s\n",is);
							printf("#%s\n",ss);
			}
}
char	*
hassubstr(os,is,ss)	/* is in os delineated by ss */
char	*os;
char	*is;
char	*ss;
{
	auto	char	*osx = os;
	auto	char	*esx;
	auto	int		lss = strlen(ss);
	auto	char	*rsx = NULL;
	while(rsx == NULL && osx != 0)	{
		esx = strstr(osx,ss);
		if(esx)	*esx = 0;
fprintf(stderr,"osx(%s) is(%s)\n",osx,is);
		if(strcmp(osx,is) == 0)	rsx = osx;
		if(esx)	{
			*esx = *ss;
			osx = esx + lss;
			}
		else	break;
		}
	return(rsx);
}
