mandoc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/COPYING +674 -0
  4. data/README.md +117 -0
  5. data/ext/mandoc/extconf.rb +59 -0
  6. data/ext/mandoc/rb_mandoc.c +548 -0
  7. data/ext/mandoc/rb_mandoc.h +22 -0
  8. data/lib/mandoc/version.rb +19 -0
  9. data/lib/mandoc.rb +26 -0
  10. data/mandoc-1.14.6/LICENSE +55 -0
  11. data/mandoc-1.14.6/arch.c +54 -0
  12. data/mandoc-1.14.6/att.c +49 -0
  13. data/mandoc-1.14.6/catman.c +260 -0
  14. data/mandoc-1.14.6/cgi.c +1279 -0
  15. data/mandoc-1.14.6/chars.c +507 -0
  16. data/mandoc-1.14.6/compat_err.c +103 -0
  17. data/mandoc-1.14.6/compat_fts.c +696 -0
  18. data/mandoc-1.14.6/compat_fts.h +106 -0
  19. data/mandoc-1.14.6/compat_getline.c +59 -0
  20. data/mandoc-1.14.6/compat_getsubopt.c +87 -0
  21. data/mandoc-1.14.6/compat_isblank.c +23 -0
  22. data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
  23. data/mandoc-1.14.6/compat_mkstemps.c +63 -0
  24. data/mandoc-1.14.6/compat_ohash.c +330 -0
  25. data/mandoc-1.14.6/compat_ohash.h +72 -0
  26. data/mandoc-1.14.6/compat_progname.c +31 -0
  27. data/mandoc-1.14.6/compat_reallocarray.c +40 -0
  28. data/mandoc-1.14.6/compat_recallocarray.c +99 -0
  29. data/mandoc-1.14.6/compat_strcasestr.c +64 -0
  30. data/mandoc-1.14.6/compat_stringlist.c +135 -0
  31. data/mandoc-1.14.6/compat_stringlist.h +48 -0
  32. data/mandoc-1.14.6/compat_strlcat.c +57 -0
  33. data/mandoc-1.14.6/compat_strlcpy.c +52 -0
  34. data/mandoc-1.14.6/compat_strndup.c +42 -0
  35. data/mandoc-1.14.6/compat_strsep.c +70 -0
  36. data/mandoc-1.14.6/compat_strtonum.c +67 -0
  37. data/mandoc-1.14.6/compat_vasprintf.c +47 -0
  38. data/mandoc-1.14.6/config.h +52 -0
  39. data/mandoc-1.14.6/dba.c +508 -0
  40. data/mandoc-1.14.6/dba.h +50 -0
  41. data/mandoc-1.14.6/dba_array.c +190 -0
  42. data/mandoc-1.14.6/dba_array.h +47 -0
  43. data/mandoc-1.14.6/dba_read.c +74 -0
  44. data/mandoc-1.14.6/dba_write.c +127 -0
  45. data/mandoc-1.14.6/dba_write.h +30 -0
  46. data/mandoc-1.14.6/dbm.c +480 -0
  47. data/mandoc-1.14.6/dbm.h +68 -0
  48. data/mandoc-1.14.6/dbm_map.c +194 -0
  49. data/mandoc-1.14.6/dbm_map.h +29 -0
  50. data/mandoc-1.14.6/demandoc.c +260 -0
  51. data/mandoc-1.14.6/eqn.c +1132 -0
  52. data/mandoc-1.14.6/eqn.h +72 -0
  53. data/mandoc-1.14.6/eqn_html.c +246 -0
  54. data/mandoc-1.14.6/eqn_parse.h +48 -0
  55. data/mandoc-1.14.6/eqn_term.c +174 -0
  56. data/mandoc-1.14.6/html.c +1102 -0
  57. data/mandoc-1.14.6/html.h +142 -0
  58. data/mandoc-1.14.6/lib.c +35 -0
  59. data/mandoc-1.14.6/libman.h +42 -0
  60. data/mandoc-1.14.6/libmandoc.h +85 -0
  61. data/mandoc-1.14.6/libmdoc.h +87 -0
  62. data/mandoc-1.14.6/main.c +1375 -0
  63. data/mandoc-1.14.6/main.h +53 -0
  64. data/mandoc-1.14.6/man.c +345 -0
  65. data/mandoc-1.14.6/man.h +21 -0
  66. data/mandoc-1.14.6/man_html.c +640 -0
  67. data/mandoc-1.14.6/man_macro.c +470 -0
  68. data/mandoc-1.14.6/man_term.c +1143 -0
  69. data/mandoc-1.14.6/man_validate.c +660 -0
  70. data/mandoc-1.14.6/manconf.h +58 -0
  71. data/mandoc-1.14.6/mandoc.c +669 -0
  72. data/mandoc-1.14.6/mandoc.h +329 -0
  73. data/mandoc-1.14.6/mandoc_aux.c +118 -0
  74. data/mandoc-1.14.6/mandoc_aux.h +27 -0
  75. data/mandoc-1.14.6/mandoc_msg.c +375 -0
  76. data/mandoc-1.14.6/mandoc_ohash.c +65 -0
  77. data/mandoc-1.14.6/mandoc_ohash.h +23 -0
  78. data/mandoc-1.14.6/mandoc_parse.h +44 -0
  79. data/mandoc-1.14.6/mandoc_xr.c +123 -0
  80. data/mandoc-1.14.6/mandoc_xr.h +31 -0
  81. data/mandoc-1.14.6/mandocd.c +282 -0
  82. data/mandoc-1.14.6/mandocdb.c +2448 -0
  83. data/mandoc-1.14.6/manpath.c +363 -0
  84. data/mandoc-1.14.6/mansearch.c +851 -0
  85. data/mandoc-1.14.6/mansearch.h +118 -0
  86. data/mandoc-1.14.6/mdoc.c +433 -0
  87. data/mandoc-1.14.6/mdoc.h +158 -0
  88. data/mandoc-1.14.6/mdoc_argv.c +682 -0
  89. data/mandoc-1.14.6/mdoc_html.c +1762 -0
  90. data/mandoc-1.14.6/mdoc_macro.c +1600 -0
  91. data/mandoc-1.14.6/mdoc_man.c +1850 -0
  92. data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
  93. data/mandoc-1.14.6/mdoc_state.c +256 -0
  94. data/mandoc-1.14.6/mdoc_term.c +1964 -0
  95. data/mandoc-1.14.6/mdoc_validate.c +3062 -0
  96. data/mandoc-1.14.6/msec.c +37 -0
  97. data/mandoc-1.14.6/out.c +544 -0
  98. data/mandoc-1.14.6/out.h +70 -0
  99. data/mandoc-1.14.6/preconv.c +179 -0
  100. data/mandoc-1.14.6/read.c +732 -0
  101. data/mandoc-1.14.6/roff.c +4390 -0
  102. data/mandoc-1.14.6/roff.h +561 -0
  103. data/mandoc-1.14.6/roff_html.c +119 -0
  104. data/mandoc-1.14.6/roff_int.h +94 -0
  105. data/mandoc-1.14.6/roff_term.c +266 -0
  106. data/mandoc-1.14.6/roff_validate.c +151 -0
  107. data/mandoc-1.14.6/soelim.c +182 -0
  108. data/mandoc-1.14.6/st.c +82 -0
  109. data/mandoc-1.14.6/tag.c +327 -0
  110. data/mandoc-1.14.6/tag.h +35 -0
  111. data/mandoc-1.14.6/tbl.c +183 -0
  112. data/mandoc-1.14.6/tbl.h +121 -0
  113. data/mandoc-1.14.6/tbl_data.c +323 -0
  114. data/mandoc-1.14.6/tbl_html.c +293 -0
  115. data/mandoc-1.14.6/tbl_int.h +47 -0
  116. data/mandoc-1.14.6/tbl_layout.c +376 -0
  117. data/mandoc-1.14.6/tbl_opts.c +173 -0
  118. data/mandoc-1.14.6/tbl_parse.h +30 -0
  119. data/mandoc-1.14.6/tbl_term.c +948 -0
  120. data/mandoc-1.14.6/term.c +1113 -0
  121. data/mandoc-1.14.6/term.h +158 -0
  122. data/mandoc-1.14.6/term_ascii.c +424 -0
  123. data/mandoc-1.14.6/term_ps.c +1362 -0
  124. data/mandoc-1.14.6/term_tab.c +130 -0
  125. data/mandoc-1.14.6/term_tag.c +227 -0
  126. data/mandoc-1.14.6/term_tag.h +34 -0
  127. data/mandoc-1.14.6/tree.c +536 -0
  128. metadata +170 -0
@@ -0,0 +1,470 @@
1
+ /* $Id: man_macro.c,v 1.145 2020/09/09 17:01:10 schwarze Exp $ */
2
+ /*
3
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4
+ * Copyright (c) 2012-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
5
+ * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
6
+ *
7
+ * Permission to use, copy, modify, and distribute this software for any
8
+ * purpose with or without fee is hereby granted, provided that the above
9
+ * copyright notice and this permission notice appear in all copies.
10
+ *
11
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
12
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
14
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
+ */
19
+ #include "config.h"
20
+
21
+ #include <sys/types.h>
22
+
23
+ #include <assert.h>
24
+ #include <ctype.h>
25
+ #include <stdio.h>
26
+ #include <stdlib.h>
27
+ #include <string.h>
28
+
29
+ #include "mandoc.h"
30
+ #include "roff.h"
31
+ #include "man.h"
32
+ #include "libmandoc.h"
33
+ #include "roff_int.h"
34
+ #include "libman.h"
35
+
36
+ static void blk_close(MACRO_PROT_ARGS);
37
+ static void blk_exp(MACRO_PROT_ARGS);
38
+ static void blk_imp(MACRO_PROT_ARGS);
39
+ static void in_line_eoln(MACRO_PROT_ARGS);
40
+ static int man_args(struct roff_man *, int,
41
+ int *, char *, char **);
42
+ static void rew_scope(struct roff_man *, enum roff_tok);
43
+
44
+ static const struct man_macro man_macros[MAN_MAX - MAN_TH] = {
45
+ { in_line_eoln, MAN_XSCOPE }, /* TH */
46
+ { blk_imp, MAN_XSCOPE | MAN_BSCOPED }, /* SH */
47
+ { blk_imp, MAN_XSCOPE | MAN_BSCOPED }, /* SS */
48
+ { blk_imp, MAN_XSCOPE | MAN_BSCOPED }, /* TP */
49
+ { blk_imp, MAN_XSCOPE | MAN_BSCOPED }, /* TQ */
50
+ { blk_imp, MAN_XSCOPE }, /* LP */
51
+ { blk_imp, MAN_XSCOPE }, /* PP */
52
+ { blk_imp, MAN_XSCOPE }, /* P */
53
+ { blk_imp, MAN_XSCOPE }, /* IP */
54
+ { blk_imp, MAN_XSCOPE }, /* HP */
55
+ { in_line_eoln, MAN_NSCOPED | MAN_ESCOPED | MAN_JOIN }, /* SM */
56
+ { in_line_eoln, MAN_NSCOPED | MAN_ESCOPED | MAN_JOIN }, /* SB */
57
+ { in_line_eoln, 0 }, /* BI */
58
+ { in_line_eoln, 0 }, /* IB */
59
+ { in_line_eoln, 0 }, /* BR */
60
+ { in_line_eoln, 0 }, /* RB */
61
+ { in_line_eoln, MAN_NSCOPED | MAN_ESCOPED | MAN_JOIN }, /* R */
62
+ { in_line_eoln, MAN_NSCOPED | MAN_ESCOPED | MAN_JOIN }, /* B */
63
+ { in_line_eoln, MAN_NSCOPED | MAN_ESCOPED | MAN_JOIN }, /* I */
64
+ { in_line_eoln, 0 }, /* IR */
65
+ { in_line_eoln, 0 }, /* RI */
66
+ { blk_close, MAN_XSCOPE }, /* RE */
67
+ { blk_exp, MAN_XSCOPE }, /* RS */
68
+ { in_line_eoln, 0 }, /* DT */
69
+ { in_line_eoln, 0 }, /* UC */
70
+ { in_line_eoln, MAN_NSCOPED }, /* PD */
71
+ { in_line_eoln, 0 }, /* AT */
72
+ { in_line_eoln, MAN_NSCOPED }, /* in */
73
+ { blk_imp, MAN_XSCOPE }, /* SY */
74
+ { blk_close, MAN_XSCOPE }, /* YS */
75
+ { in_line_eoln, 0 }, /* OP */
76
+ { in_line_eoln, MAN_XSCOPE }, /* EX */
77
+ { in_line_eoln, MAN_XSCOPE }, /* EE */
78
+ { blk_exp, MAN_XSCOPE }, /* UR */
79
+ { blk_close, MAN_XSCOPE }, /* UE */
80
+ { blk_exp, MAN_XSCOPE }, /* MT */
81
+ { blk_close, MAN_XSCOPE }, /* ME */
82
+ };
83
+
84
+
85
+ const struct man_macro *
86
+ man_macro(enum roff_tok tok)
87
+ {
88
+ assert(tok >= MAN_TH && tok <= MAN_MAX);
89
+ return man_macros + (tok - MAN_TH);
90
+ }
91
+
92
+ void
93
+ man_unscope(struct roff_man *man, const struct roff_node *to)
94
+ {
95
+ struct roff_node *n;
96
+
97
+ to = to->parent;
98
+ n = man->last;
99
+ while (n != to) {
100
+
101
+ /* Reached the end of the document? */
102
+
103
+ if (to == NULL && ! (n->flags & NODE_VALID)) {
104
+ if (man->flags & (MAN_BLINE | MAN_ELINE) &&
105
+ man_macro(n->tok)->flags &
106
+ (MAN_BSCOPED | MAN_NSCOPED)) {
107
+ mandoc_msg(MANDOCERR_BLK_LINE,
108
+ n->line, n->pos,
109
+ "EOF breaks %s", roff_name[n->tok]);
110
+ if (man->flags & MAN_ELINE) {
111
+ if ((man_macro(n->parent->tok)->flags &
112
+ MAN_ESCOPED) == 0)
113
+ man->flags &= ~MAN_ELINE;
114
+ } else {
115
+ assert(n->type == ROFFT_HEAD);
116
+ n = n->parent;
117
+ man->flags &= ~MAN_BLINE;
118
+ }
119
+ man->last = n;
120
+ n = n->parent;
121
+ roff_node_delete(man, man->last);
122
+ continue;
123
+ }
124
+ if (n->type == ROFFT_BLOCK &&
125
+ man_macro(n->tok)->fp == blk_exp)
126
+ mandoc_msg(MANDOCERR_BLK_NOEND,
127
+ n->line, n->pos, "%s",
128
+ roff_name[n->tok]);
129
+ }
130
+
131
+ /*
132
+ * We might delete the man->last node
133
+ * in the post-validation phase.
134
+ * Save a pointer to the parent such that
135
+ * we know where to continue the iteration.
136
+ */
137
+
138
+ man->last = n;
139
+ n = n->parent;
140
+ man->last->flags |= NODE_VALID;
141
+ }
142
+
143
+ /*
144
+ * If we ended up at the parent of the node we were
145
+ * supposed to rewind to, that means the target node
146
+ * got deleted, so add the next node we parse as a child
147
+ * of the parent instead of as a sibling of the target.
148
+ */
149
+
150
+ man->next = (man->last == to) ?
151
+ ROFF_NEXT_CHILD : ROFF_NEXT_SIBLING;
152
+ }
153
+
154
+ /*
155
+ * Rewinding entails ascending the parse tree until a coherent point,
156
+ * for example, the `SH' macro will close out any intervening `SS'
157
+ * scopes. When a scope is closed, it must be validated and actioned.
158
+ */
159
+ static void
160
+ rew_scope(struct roff_man *man, enum roff_tok tok)
161
+ {
162
+ struct roff_node *n;
163
+
164
+ /* Preserve empty paragraphs before RS. */
165
+
166
+ n = man->last;
167
+ if (tok == MAN_RS && n->child == NULL &&
168
+ (n->tok == MAN_P || n->tok == MAN_PP || n->tok == MAN_LP))
169
+ return;
170
+
171
+ for (;;) {
172
+ if (n->type == ROFFT_ROOT)
173
+ return;
174
+ if (n->flags & NODE_VALID) {
175
+ n = n->parent;
176
+ continue;
177
+ }
178
+ if (n->type != ROFFT_BLOCK) {
179
+ if (n->parent->type == ROFFT_ROOT) {
180
+ man_unscope(man, n);
181
+ return;
182
+ } else {
183
+ n = n->parent;
184
+ continue;
185
+ }
186
+ }
187
+ if (tok != MAN_SH && (n->tok == MAN_SH ||
188
+ (tok != MAN_SS && (n->tok == MAN_SS ||
189
+ man_macro(n->tok)->fp == blk_exp))))
190
+ return;
191
+ man_unscope(man, n);
192
+ n = man->last;
193
+ }
194
+ }
195
+
196
+
197
+ /*
198
+ * Close out a generic explicit macro.
199
+ */
200
+ void
201
+ blk_close(MACRO_PROT_ARGS)
202
+ {
203
+ enum roff_tok ctok, ntok;
204
+ const struct roff_node *nn;
205
+ char *p, *ep;
206
+ int cline, cpos, la, nrew, target;
207
+
208
+ nrew = 1;
209
+ switch (tok) {
210
+ case MAN_RE:
211
+ ntok = MAN_RS;
212
+ la = *pos;
213
+ if ( ! man_args(man, line, pos, buf, &p))
214
+ break;
215
+ for (nn = man->last->parent; nn; nn = nn->parent)
216
+ if (nn->tok == ntok && nn->type == ROFFT_BLOCK)
217
+ nrew++;
218
+ target = strtol(p, &ep, 10);
219
+ if (*ep != '\0')
220
+ mandoc_msg(MANDOCERR_ARG_EXCESS, line,
221
+ la + (buf[la] == '"') + (int)(ep - p),
222
+ "RE ... %s", ep);
223
+ free(p);
224
+ if (target == 0)
225
+ target = 1;
226
+ nrew -= target;
227
+ if (nrew < 1) {
228
+ mandoc_msg(MANDOCERR_RE_NOTOPEN,
229
+ line, ppos, "RE %d", target);
230
+ return;
231
+ }
232
+ break;
233
+ case MAN_YS:
234
+ ntok = MAN_SY;
235
+ break;
236
+ case MAN_UE:
237
+ ntok = MAN_UR;
238
+ break;
239
+ case MAN_ME:
240
+ ntok = MAN_MT;
241
+ break;
242
+ default:
243
+ abort();
244
+ }
245
+
246
+ for (nn = man->last->parent; nn; nn = nn->parent)
247
+ if (nn->tok == ntok && nn->type == ROFFT_BLOCK && ! --nrew)
248
+ break;
249
+
250
+ if (nn == NULL) {
251
+ mandoc_msg(MANDOCERR_BLK_NOTOPEN,
252
+ line, ppos, "%s", roff_name[tok]);
253
+ rew_scope(man, MAN_PP);
254
+ if (tok == MAN_RE) {
255
+ roff_elem_alloc(man, line, ppos, ROFF_br);
256
+ man->last->flags |= NODE_LINE |
257
+ NODE_VALID | NODE_ENDED;
258
+ man->next = ROFF_NEXT_SIBLING;
259
+ }
260
+ return;
261
+ }
262
+
263
+ cline = man->last->line;
264
+ cpos = man->last->pos;
265
+ ctok = man->last->tok;
266
+ man_unscope(man, nn);
267
+
268
+ if (tok == MAN_RE && nn->head->aux > 0)
269
+ roff_setreg(man->roff, "an-margin", nn->head->aux, '-');
270
+
271
+ /* Trailing text. */
272
+
273
+ if (buf[*pos] != '\0') {
274
+ roff_word_alloc(man, line, ppos, buf + *pos);
275
+ man->last->flags |= NODE_DELIMC;
276
+ if (mandoc_eos(man->last->string, strlen(man->last->string)))
277
+ man->last->flags |= NODE_EOS;
278
+ }
279
+
280
+ /* Move a trailing paragraph behind the block. */
281
+
282
+ if (ctok == MAN_LP || ctok == MAN_PP || ctok == MAN_P) {
283
+ *pos = strlen(buf);
284
+ blk_imp(man, ctok, cline, cpos, pos, buf);
285
+ }
286
+
287
+ /* Synopsis blocks need an explicit end marker for spacing. */
288
+
289
+ if (tok == MAN_YS && man->last == nn) {
290
+ roff_elem_alloc(man, line, ppos, tok);
291
+ man_unscope(man, man->last);
292
+ }
293
+ }
294
+
295
+ void
296
+ blk_exp(MACRO_PROT_ARGS)
297
+ {
298
+ struct roff_node *head;
299
+ char *p;
300
+ int la;
301
+
302
+ if (tok == MAN_RS) {
303
+ rew_scope(man, tok);
304
+ man->flags |= ROFF_NONOFILL;
305
+ }
306
+ roff_block_alloc(man, line, ppos, tok);
307
+ head = roff_head_alloc(man, line, ppos, tok);
308
+
309
+ la = *pos;
310
+ if (man_args(man, line, pos, buf, &p)) {
311
+ roff_word_alloc(man, line, la, p);
312
+ if (tok == MAN_RS) {
313
+ if (roff_getreg(man->roff, "an-margin") == 0)
314
+ roff_setreg(man->roff, "an-margin",
315
+ 7 * 24, '=');
316
+ if ((head->aux = strtod(p, NULL) * 24.0) > 0)
317
+ roff_setreg(man->roff, "an-margin",
318
+ head->aux, '+');
319
+ }
320
+ free(p);
321
+ }
322
+
323
+ if (buf[*pos] != '\0')
324
+ mandoc_msg(MANDOCERR_ARG_EXCESS, line, *pos,
325
+ "%s ... %s", roff_name[tok], buf + *pos);
326
+
327
+ man_unscope(man, head);
328
+ roff_body_alloc(man, line, ppos, tok);
329
+ man->flags &= ~ROFF_NONOFILL;
330
+ }
331
+
332
+ /*
333
+ * Parse an implicit-block macro. These contain a ROFFT_HEAD and a
334
+ * ROFFT_BODY contained within a ROFFT_BLOCK. Rules for closing out other
335
+ * scopes, such as `SH' closing out an `SS', are defined in the rew
336
+ * routines.
337
+ */
338
+ void
339
+ blk_imp(MACRO_PROT_ARGS)
340
+ {
341
+ int la;
342
+ char *p;
343
+ struct roff_node *n;
344
+
345
+ rew_scope(man, tok);
346
+ man->flags |= ROFF_NONOFILL;
347
+ if (tok == MAN_SH || tok == MAN_SS)
348
+ man->flags &= ~ROFF_NOFILL;
349
+ roff_block_alloc(man, line, ppos, tok);
350
+ n = roff_head_alloc(man, line, ppos, tok);
351
+
352
+ /* Add line arguments. */
353
+
354
+ for (;;) {
355
+ la = *pos;
356
+ if ( ! man_args(man, line, pos, buf, &p))
357
+ break;
358
+ roff_word_alloc(man, line, la, p);
359
+ free(p);
360
+ }
361
+
362
+ /*
363
+ * For macros having optional next-line scope,
364
+ * keep the head open if there were no arguments.
365
+ * For `TP' and `TQ', always keep the head open.
366
+ */
367
+
368
+ if (man_macro(tok)->flags & MAN_BSCOPED &&
369
+ (tok == MAN_TP || tok == MAN_TQ || n == man->last)) {
370
+ man->flags |= MAN_BLINE;
371
+ return;
372
+ }
373
+
374
+ /* Close out the head and open the body. */
375
+
376
+ man_unscope(man, n);
377
+ roff_body_alloc(man, line, ppos, tok);
378
+ man->flags &= ~ROFF_NONOFILL;
379
+ }
380
+
381
+ void
382
+ in_line_eoln(MACRO_PROT_ARGS)
383
+ {
384
+ int la;
385
+ char *p;
386
+ struct roff_node *n;
387
+
388
+ roff_elem_alloc(man, line, ppos, tok);
389
+ n = man->last;
390
+
391
+ if (tok == MAN_EX)
392
+ man->flags |= ROFF_NOFILL;
393
+ else if (tok == MAN_EE)
394
+ man->flags &= ~ROFF_NOFILL;
395
+
396
+ for (;;) {
397
+ if (buf[*pos] != '\0' && man->last != n && tok == MAN_PD) {
398
+ mandoc_msg(MANDOCERR_ARG_EXCESS, line, *pos,
399
+ "%s ... %s", roff_name[tok], buf + *pos);
400
+ break;
401
+ }
402
+ la = *pos;
403
+ if ( ! man_args(man, line, pos, buf, &p))
404
+ break;
405
+ if (man_macro(tok)->flags & MAN_JOIN &&
406
+ man->last->type == ROFFT_TEXT)
407
+ roff_word_append(man, p);
408
+ else
409
+ roff_word_alloc(man, line, la, p);
410
+ free(p);
411
+ }
412
+
413
+ /*
414
+ * Append NODE_EOS in case the last snipped argument
415
+ * ends with a dot, e.g. `.IR syslog (3).'
416
+ */
417
+
418
+ if (n != man->last &&
419
+ mandoc_eos(man->last->string, strlen(man->last->string)))
420
+ man->last->flags |= NODE_EOS;
421
+
422
+ /*
423
+ * If no arguments are specified and this is MAN_ESCOPED (i.e.,
424
+ * next-line scoped), then set our mode to indicate that we're
425
+ * waiting for terms to load into our context.
426
+ */
427
+
428
+ if (n == man->last && man_macro(tok)->flags & MAN_ESCOPED) {
429
+ man->flags |= MAN_ELINE;
430
+ return;
431
+ }
432
+
433
+ assert(man->last->type != ROFFT_ROOT);
434
+ man->next = ROFF_NEXT_SIBLING;
435
+
436
+ /* Rewind our element scope. */
437
+
438
+ for ( ; man->last; man->last = man->last->parent) {
439
+ man->last->flags |= NODE_VALID;
440
+ if (man->last == n)
441
+ break;
442
+ }
443
+
444
+ /* Rewind next-line scoped ancestors, if any. */
445
+
446
+ if (man_macro(tok)->flags & MAN_ESCOPED)
447
+ man_descope(man, line, ppos, NULL);
448
+ }
449
+
450
+ void
451
+ man_endparse(struct roff_man *man)
452
+ {
453
+ man_unscope(man, man->meta.first);
454
+ }
455
+
456
+ static int
457
+ man_args(struct roff_man *man, int line, int *pos, char *buf, char **v)
458
+ {
459
+ char *start;
460
+
461
+ assert(*pos);
462
+ *v = start = buf + *pos;
463
+ assert(' ' != *start);
464
+
465
+ if ('\0' == *start)
466
+ return 0;
467
+
468
+ *v = roff_getarg(man->roff, v, line, pos);
469
+ return 1;
470
+ }