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 struct dict
*mapdict
;
11 /* map register names to [0..NREGS] */
15 if (s
[0] == '.' && s
[1] && !s
[2]) /* ".x" is mapped to 'x' */
16 return (unsigned char) s
[1];
18 mapdict
= dict_make(-1, 1, 2);
19 i
= dict_idx(mapdict
, s
);
21 dict_put(mapdict
, s
, 0);
22 i
= dict_idx(mapdict
, s
);
23 if (MAPBEG
+ i
>= NREGS
)
24 errdie("neatroff: increase NREGS\n");
29 /* return the name mapped to id; returns a static buffer */
30 char *map_name(int id
)
32 static char map_buf
[NMLEN
];
34 return dict_key(mapdict
, id
- MAPBEG
);