/* Copyright (c) 1979 Regents of the University of California */ static char sccsid[] = "@(#)READE.c 1.6 10/28/83"; #include "h00vars.h" long READE(curfile, name) register struct iorec *curfile; char *name; { register short *sptr; register int len; register int nextlen; register int cnt; char *cp; char namebuf[NAMSIZ]; int retval; if (curfile->funit & FWRITE) { ERROR("%s: Attempt to read, but open for writing\n", curfile->pfname); return; } UNSYNC(curfile); retval = fscanf(curfile->fbuf, "%*[ \t\n]%74[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]", namebuf); if (retval == EOF) { ERROR("%s: Tried to read past end of file\n", curfile->pfname); return; } if (retval == 0) goto ename; for (len = 0; len < NAMSIZ && namebuf[len]; len++) /* void */; len++; sptr = (short *)name; cnt = *sptr++; cp = name + sizeof (short) + *sptr; do { nextlen = *sptr++; nextlen = *sptr - nextlen; if (nextlen == len && RELEQ(len, namebuf, cp)) { return *((short *) name) - cnt; } cp += (int)nextlen; } while (--cnt); ename: ERROR("Unknown name \"%s\" found on enumerated type read\n", namebuf); }