xref: /original-bsd/usr.bin/pascal/libpc/NAM.c (revision 188f7363)
1 /*-
2  * Copyright (c) 1979 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)NAM.c	1.5 (Berkeley) 04/09/90";
10 #endif /* not lint */
11 
12 #include "h00vars.h"
13 
14 char *
15 NAM(val, name)
16 
17 	long		val;	/* internal enumerated type value */
18 	char		*name;	/* ptr to enumerated type name descriptor */
19 {
20 	register int	value = val;
21 	register short	*sptr;
22 
23 	sptr = (short *)name;
24 	if (value < 0 || value >= *sptr) {
25 		ERROR("Enumerated type value of %D is out of range on output\n",
26 			val);
27 	}
28 	sptr++;
29 	return	name + 2 + sptr[value];
30 }
31