written by Kirk McKusick; add Berkeley specific copyright notice
[unix-history] / usr / src / usr.bin / pascal / libpc / NAM.c
CommitLineData
0d78ca85
KB
1/*-
2 * Copyright (c) 1979 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
3cdfbf8d 7
0d78ca85
KB
8#ifndef lint
9static char sccsid[] = "@(#)NAM.c 1.5 (Berkeley) %G%";
10#endif /* not lint */
3cdfbf8d
KM
11
12#include "h00vars.h"
3cdfbf8d
KM
13
14char *
492cc5d3 15NAM(val, name)
3cdfbf8d 16
492cc5d3 17 long val; /* internal enumerated type value */
3cdfbf8d
KM
18 char *name; /* ptr to enumerated type name descriptor */
19{
492cc5d3 20 register int value = val;
3cdfbf8d
KM
21 register short *sptr;
22
23 sptr = (short *)name;
24 if (value < 0 || value >= *sptr) {
86997b19
KM
25 ERROR("Enumerated type value of %D is out of range on output\n",
26 val);
3cdfbf8d
KM
27 }
28 sptr++;
29 return name + 2 + sptr[value];
30}