9 static int sreg_max
; /* maximum allocated string register */
10 static int sreg_free
[NREGS
]; /* free string registers */
11 static int sreg_n
; /* number of items in sreg_free[] */
12 static char sreg_name
[NREGS
][RLEN
];
13 static char sreg_read
[NREGS
][RLEN
];
16 static int nreg_free
[NREGS
];
18 static char nreg_name
[NREGS
][RLEN
];
19 static char nreg_read
[NREGS
][RLEN
];
21 /* allocate a troff string register */
24 int id
= sreg_n
? sreg_free
[--sreg_n
] : ++sreg_max
;
25 sprintf(sreg_name
[id
], "%s%02d", EPREFIX
, id
);
26 sprintf(sreg_read
[id
], "\\*%s", escarg(sreg_name
[id
]));
30 /* free a troff string register */
33 sreg_free
[sreg_n
++] = id
;
36 char *sregname(int id
)
46 /* allocate a troff number register */
49 int id
= nreg_n
? nreg_free
[--nreg_n
] : ++nreg_max
;
50 sprintf(nreg_name
[id
], "%s%02d", EPREFIX
, id
);
51 sprintf(nreg_read
[id
], "\\n%s", escarg(nreg_name
[id
]));
55 /* free a troff number register */
58 nreg_free
[nreg_n
++] = id
;
61 char *nregname(int id
)
71 /* free all allocated registers */
80 /* format the argument of a troff escape like \s or \f */
81 char *escarg(char *arg
)
85 sprintf(buf
, "%c", arg
[0]);
87 sprintf(buf
, "(%c%c", arg
[0], arg
[1]);
89 sprintf(buf
, "[%s]", arg
);