/* (c) Copyright 1987 Michael Goetz								*/
/*																			*/
/*				File:		  	find										*/
/*				Returns:	  	int - index of found variable		*/
/*				Parameters:	char * ztext - string of key		*/
/*																			*/
/*																			*/

#include <stdio.h>
#include <string.h>


#include "advm.h"
#include "string.h"
#include "units.h"
#include "values.h"
#include "xrflag.h"
#include "mash.h"


int find (ztext)
char *ztext;

{
	char ztexan [13];
	int found,imodx,rehash;

	strncpy(ztexan, (ztext[0] == '@')?ztext+1:ztext, 12);
	ztexan[12] = 0;
	found = mash(ztexan);
	imodx = found % rehshn;
	rehash = rehshv[imodx];
	found = found % 2000;
	if (xref)
		{
		fprintf(xreffi, "%-12.12s %2d %-12.12s %5d\n",
					ztexan,fnum,zfid,nrec);
		xrflag = TRUE;
		}
	while (zname[found][0] && strcmp(zname[found], ztexan))
		found = (found+rehash) % 2000;

		/* either found or not found */
	return (zname[found][0] ? found : -1);
}
