# define swap(i,j)  {t=i; i=j; j=t;}

char *uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *lowercase "abcdefghijklmnopqrstuvwxyz";
char *digits "0123456789";

range(lp, a, b)
	int *lp;
{
int i,j,t,x;
if (x= ifrange(a,b, uppercase, lp))
	return(x);
if (x= ifrange(a,b, lowercase, lp))
	return(x);
if (x= ifrange(a,b,digits,lp))
	return(x);
warning("Non-portable character class");
if (a>b) {t=i; i=j; j=t;};
while (a<=b) *lp++ = a++;
return(lp);
}
index(a,s)
	char *s;
{
int k;
for(k=0; s[k]; k++)
	if (s[k]== a)
		return(k);
return(-1);
}

ifrange(a,b,s,lp)
	char *s; int *lp;
{
int i,j,t;
if ( ((i=index(a, s))>=0) && ((j=index(b,s))>=0))
	{
	if (i>j) {t=i; i=j; j=t;};
	while (i <= j)
		*lp++ = s[i++];
	return(lp);
	}
return(0);
}
