1 /* mapping register/macro names to indices */
6 #define MAPBEG 256 /* the entries reserved for .x names */
8 /* register, macro, or environments names */
9 static char keys
[NREGS
][GNLEN
];
11 /* per starting character name lists */
12 static int key_head
[256];
13 static int key_next
[NREGS
];
15 /* return the index of s in keys[]; insert it if not in keys[] */
16 static int key_get(char *s
)
18 int head
= (unsigned char) s
[0];
19 int i
= key_head
[head
];
23 if (keys
[i
][1] == s
[1] && !strcmp(keys
[i
], s
))
27 if (nkeys
>= NREGS
- MAPBEG
)
28 errdie("neatroff: out of register names (NREGS)\n");
31 key_next
[i
] = key_head
[head
];
36 /* map register names to [0..NREGS] */
39 if (s
[0] == '.' && s
[1] && !s
[2]) /* ".x" is mapped to 'x' */
40 return (unsigned char) s
[1];
41 return MAPBEG
+ key_get(s
);
44 /* return the name mapped to id; returns a static buffer */
45 char *map_name(int id
)
47 static char map_buf
[NMLEN
];
49 return keys
[id
- MAPBEG
];