7 static int cp_buf
[CPBUF
]; /* pushed character stack */
8 static int cp_backed
; /* number of pushed characters */
9 static int cp_nblk
; /* input block depth (text in \{ and \}) */
10 static int cp_sblk
[NIES
]; /* skip \} escape at this depth, if set */
12 static int regid(void)
24 static void cp_num(void)
28 if (c
!= '-' && c
!= '+')
31 if (c
== '-' || c
== '+')
32 num_get(id
, c
== '+' ? 1 : -1);
34 in_push(num_str(id
), NULL
);
37 static void cp_str(void)
39 char *buf
= str_get(regid());
44 static void cp_arg(void)
49 if (c
>= '1' && c
<= '9')
50 arg
= in_arg(c
- '0');
55 static int cp_raw(void)
59 return cp_buf
[--cp_backed
];
67 if (c
== '{' && cp_nblk
< LEN(cp_sblk
))
68 cp_sblk
[cp_nblk
++] = 0;
69 if (c
== '}' && cp_nblk
> 0)
70 if (cp_sblk
[--cp_nblk
])
82 return cp_buf
[--cp_backed
];
87 while (c
>= 0 && c
!= '\n')
89 } else if (c
== 'n') {
92 } else if (c
== '*') {
95 } else if (c
== '$') {
108 if (cp_backed
< CPBUF
)
109 cp_buf
[cp_backed
++] = c
;
112 static int cp_top(void)
114 return cp_backed
? cp_buf
[cp_backed
- 1] : -1;
117 void cp_blk(int skip
)
123 } while (c
== ' ' || c
== '\t');
124 if (c
== '\\' && cp_top() == '{') { /* a troff \{ \} block */
126 while (skip
&& cp_nblk
> nblk
&& c
>= 0)
136 while (skip
&& c
!= '\n') /* skip until the end of the line */