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] */
17 if (s
[0] == '.' && s
[1] && !s
[2]) /* ".x" is mapped to 'x' */
18 return (unsigned char) s
[1];
20 mapdict
= dict_make(-1, 1, 2);
21 i
= dict_idx(mapdict
, s
);
23 dict_put(mapdict
, s
, 0);
24 i
= dict_idx(mapdict
, s
);
25 if (MAPBEG
+ i
>= NREGS
)
26 errdie("neatroff: increase NREGS\n");
31 /* return the name mapped to id; returns a static buffer */
32 char *map_name(int id
)
34 static char map_buf
[NMLEN
];
36 return dict_key(mapdict
, id
- MAPBEG
);