/* Searches a source string with an argument string (like PL/I).
   Returns a pointer to the first occurence of the argument in the
   source; returns NULL if the argument is not found. */

/* Copyright 1986 John Navas II, All Rights Reserved.
INDEX is made available for personal, non-commercial use only.  You
are granted a limited license to use INDEX, and to copy it and
distribute it, provided that no fee is charged for such copying and
distribution, and that it is ONLY distributed in its original,
unmodified state. */

/* Language: Microsoft C Version 3.00 */

#include <stdio.h>

char *index( s, a )						/* search a string with an arg */
register char *s;						/* source string */
char *a;								/* argument string */
{
	for ( ; ; ++s ) {
		char *p;
		register char *q;
		for ( p = s, q = a; ; ++s, ++q ) {
			if ( ! *q ) return s;
			if ( *s != *q ) break;
			}
		if ( ! *( s = p ) ) return NULL;
		}
	}
