8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mandoc / mdoc_argv.c
blob8675bdb2db56d34e282d07f31325db865102da8f
1 /* $Id: mdoc_argv.c,v 1.107 2015/10/17 00:21:07 schwarze Exp $ */
2 /*
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include "config.h"
20 #include <sys/types.h>
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
27 #include "mandoc_aux.h"
28 #include "mandoc.h"
29 #include "roff.h"
30 #include "mdoc.h"
31 #include "libmandoc.h"
32 #include "libmdoc.h"
34 #define MULTI_STEP 5 /* pre-allocate argument values */
35 #define DELIMSZ 6 /* max possible size of a delimiter */
37 enum argsflag {
38 ARGSFL_NONE = 0,
39 ARGSFL_DELIM, /* handle delimiters of [[::delim::][ ]+]+ */
40 ARGSFL_TABSEP /* handle tab/`Ta' separated phrases */
43 enum argvflag {
44 ARGV_NONE, /* no args to flag (e.g., -split) */
45 ARGV_SINGLE, /* one arg to flag (e.g., -file xxx) */
46 ARGV_MULTI /* multiple args (e.g., -column xxx yyy) */
49 struct mdocarg {
50 enum argsflag flags;
51 const enum mdocargt *argvs;
54 static void argn_free(struct mdoc_arg *, int);
55 static enum margserr args(struct roff_man *, int, int *,
56 char *, enum argsflag, char **);
57 static int args_checkpunct(const char *, int);
58 static void argv_multi(struct roff_man *, int,
59 struct mdoc_argv *, int *, char *);
60 static void argv_single(struct roff_man *, int,
61 struct mdoc_argv *, int *, char *);
63 static const enum argvflag argvflags[MDOC_ARG_MAX] = {
64 ARGV_NONE, /* MDOC_Split */
65 ARGV_NONE, /* MDOC_Nosplit */
66 ARGV_NONE, /* MDOC_Ragged */
67 ARGV_NONE, /* MDOC_Unfilled */
68 ARGV_NONE, /* MDOC_Literal */
69 ARGV_SINGLE, /* MDOC_File */
70 ARGV_SINGLE, /* MDOC_Offset */
71 ARGV_NONE, /* MDOC_Bullet */
72 ARGV_NONE, /* MDOC_Dash */
73 ARGV_NONE, /* MDOC_Hyphen */
74 ARGV_NONE, /* MDOC_Item */
75 ARGV_NONE, /* MDOC_Enum */
76 ARGV_NONE, /* MDOC_Tag */
77 ARGV_NONE, /* MDOC_Diag */
78 ARGV_NONE, /* MDOC_Hang */
79 ARGV_NONE, /* MDOC_Ohang */
80 ARGV_NONE, /* MDOC_Inset */
81 ARGV_MULTI, /* MDOC_Column */
82 ARGV_SINGLE, /* MDOC_Width */
83 ARGV_NONE, /* MDOC_Compact */
84 ARGV_NONE, /* MDOC_Std */
85 ARGV_NONE, /* MDOC_Filled */
86 ARGV_NONE, /* MDOC_Words */
87 ARGV_NONE, /* MDOC_Emphasis */
88 ARGV_NONE, /* MDOC_Symbolic */
89 ARGV_NONE /* MDOC_Symbolic */
92 static const enum mdocargt args_Ex[] = {
93 MDOC_Std,
94 MDOC_ARG_MAX
97 static const enum mdocargt args_An[] = {
98 MDOC_Split,
99 MDOC_Nosplit,
100 MDOC_ARG_MAX
103 static const enum mdocargt args_Bd[] = {
104 MDOC_Ragged,
105 MDOC_Unfilled,
106 MDOC_Filled,
107 MDOC_Literal,
108 MDOC_File,
109 MDOC_Offset,
110 MDOC_Compact,
111 MDOC_Centred,
112 MDOC_ARG_MAX
115 static const enum mdocargt args_Bf[] = {
116 MDOC_Emphasis,
117 MDOC_Literal,
118 MDOC_Symbolic,
119 MDOC_ARG_MAX
122 static const enum mdocargt args_Bk[] = {
123 MDOC_Words,
124 MDOC_ARG_MAX
127 static const enum mdocargt args_Bl[] = {
128 MDOC_Bullet,
129 MDOC_Dash,
130 MDOC_Hyphen,
131 MDOC_Item,
132 MDOC_Enum,
133 MDOC_Tag,
134 MDOC_Diag,
135 MDOC_Hang,
136 MDOC_Ohang,
137 MDOC_Inset,
138 MDOC_Column,
139 MDOC_Width,
140 MDOC_Offset,
141 MDOC_Compact,
142 MDOC_Nested,
143 MDOC_ARG_MAX
146 static const struct mdocarg mdocargs[MDOC_MAX] = {
147 { ARGSFL_DELIM, NULL }, /* Ap */
148 { ARGSFL_NONE, NULL }, /* Dd */
149 { ARGSFL_NONE, NULL }, /* Dt */
150 { ARGSFL_NONE, NULL }, /* Os */
151 { ARGSFL_NONE, NULL }, /* Sh */
152 { ARGSFL_NONE, NULL }, /* Ss */
153 { ARGSFL_NONE, NULL }, /* Pp */
154 { ARGSFL_DELIM, NULL }, /* D1 */
155 { ARGSFL_DELIM, NULL }, /* Dl */
156 { ARGSFL_NONE, args_Bd }, /* Bd */
157 { ARGSFL_NONE, NULL }, /* Ed */
158 { ARGSFL_NONE, args_Bl }, /* Bl */
159 { ARGSFL_NONE, NULL }, /* El */
160 { ARGSFL_NONE, NULL }, /* It */
161 { ARGSFL_DELIM, NULL }, /* Ad */
162 { ARGSFL_DELIM, args_An }, /* An */
163 { ARGSFL_DELIM, NULL }, /* Ar */
164 { ARGSFL_DELIM, NULL }, /* Cd */
165 { ARGSFL_DELIM, NULL }, /* Cm */
166 { ARGSFL_DELIM, NULL }, /* Dv */
167 { ARGSFL_DELIM, NULL }, /* Er */
168 { ARGSFL_DELIM, NULL }, /* Ev */
169 { ARGSFL_NONE, args_Ex }, /* Ex */
170 { ARGSFL_DELIM, NULL }, /* Fa */
171 { ARGSFL_NONE, NULL }, /* Fd */
172 { ARGSFL_DELIM, NULL }, /* Fl */
173 { ARGSFL_DELIM, NULL }, /* Fn */
174 { ARGSFL_DELIM, NULL }, /* Ft */
175 { ARGSFL_DELIM, NULL }, /* Ic */
176 { ARGSFL_DELIM, NULL }, /* In */
177 { ARGSFL_DELIM, NULL }, /* Li */
178 { ARGSFL_NONE, NULL }, /* Nd */
179 { ARGSFL_DELIM, NULL }, /* Nm */
180 { ARGSFL_DELIM, NULL }, /* Op */
181 { ARGSFL_DELIM, NULL }, /* Ot */
182 { ARGSFL_DELIM, NULL }, /* Pa */
183 { ARGSFL_NONE, args_Ex }, /* Rv */
184 { ARGSFL_DELIM, NULL }, /* St */
185 { ARGSFL_DELIM, NULL }, /* Va */
186 { ARGSFL_DELIM, NULL }, /* Vt */
187 { ARGSFL_DELIM, NULL }, /* Xr */
188 { ARGSFL_NONE, NULL }, /* %A */
189 { ARGSFL_NONE, NULL }, /* %B */
190 { ARGSFL_NONE, NULL }, /* %D */
191 { ARGSFL_NONE, NULL }, /* %I */
192 { ARGSFL_NONE, NULL }, /* %J */
193 { ARGSFL_NONE, NULL }, /* %N */
194 { ARGSFL_NONE, NULL }, /* %O */
195 { ARGSFL_NONE, NULL }, /* %P */
196 { ARGSFL_NONE, NULL }, /* %R */
197 { ARGSFL_NONE, NULL }, /* %T */
198 { ARGSFL_NONE, NULL }, /* %V */
199 { ARGSFL_DELIM, NULL }, /* Ac */
200 { ARGSFL_NONE, NULL }, /* Ao */
201 { ARGSFL_DELIM, NULL }, /* Aq */
202 { ARGSFL_DELIM, NULL }, /* At */
203 { ARGSFL_DELIM, NULL }, /* Bc */
204 { ARGSFL_NONE, args_Bf }, /* Bf */
205 { ARGSFL_NONE, NULL }, /* Bo */
206 { ARGSFL_DELIM, NULL }, /* Bq */
207 { ARGSFL_DELIM, NULL }, /* Bsx */
208 { ARGSFL_DELIM, NULL }, /* Bx */
209 { ARGSFL_NONE, NULL }, /* Db */
210 { ARGSFL_DELIM, NULL }, /* Dc */
211 { ARGSFL_NONE, NULL }, /* Do */
212 { ARGSFL_DELIM, NULL }, /* Dq */
213 { ARGSFL_DELIM, NULL }, /* Ec */
214 { ARGSFL_NONE, NULL }, /* Ef */
215 { ARGSFL_DELIM, NULL }, /* Em */
216 { ARGSFL_NONE, NULL }, /* Eo */
217 { ARGSFL_DELIM, NULL }, /* Fx */
218 { ARGSFL_DELIM, NULL }, /* Ms */
219 { ARGSFL_DELIM, NULL }, /* No */
220 { ARGSFL_DELIM, NULL }, /* Ns */
221 { ARGSFL_DELIM, NULL }, /* Nx */
222 { ARGSFL_DELIM, NULL }, /* Ox */
223 { ARGSFL_DELIM, NULL }, /* Pc */
224 { ARGSFL_DELIM, NULL }, /* Pf */
225 { ARGSFL_NONE, NULL }, /* Po */
226 { ARGSFL_DELIM, NULL }, /* Pq */
227 { ARGSFL_DELIM, NULL }, /* Qc */
228 { ARGSFL_DELIM, NULL }, /* Ql */
229 { ARGSFL_NONE, NULL }, /* Qo */
230 { ARGSFL_DELIM, NULL }, /* Qq */
231 { ARGSFL_NONE, NULL }, /* Re */
232 { ARGSFL_NONE, NULL }, /* Rs */
233 { ARGSFL_DELIM, NULL }, /* Sc */
234 { ARGSFL_NONE, NULL }, /* So */
235 { ARGSFL_DELIM, NULL }, /* Sq */
236 { ARGSFL_NONE, NULL }, /* Sm */
237 { ARGSFL_DELIM, NULL }, /* Sx */
238 { ARGSFL_DELIM, NULL }, /* Sy */
239 { ARGSFL_DELIM, NULL }, /* Tn */
240 { ARGSFL_DELIM, NULL }, /* Ux */
241 { ARGSFL_DELIM, NULL }, /* Xc */
242 { ARGSFL_NONE, NULL }, /* Xo */
243 { ARGSFL_NONE, NULL }, /* Fo */
244 { ARGSFL_DELIM, NULL }, /* Fc */
245 { ARGSFL_NONE, NULL }, /* Oo */
246 { ARGSFL_DELIM, NULL }, /* Oc */
247 { ARGSFL_NONE, args_Bk }, /* Bk */
248 { ARGSFL_NONE, NULL }, /* Ek */
249 { ARGSFL_NONE, NULL }, /* Bt */
250 { ARGSFL_NONE, NULL }, /* Hf */
251 { ARGSFL_DELIM, NULL }, /* Fr */
252 { ARGSFL_NONE, NULL }, /* Ud */
253 { ARGSFL_DELIM, NULL }, /* Lb */
254 { ARGSFL_NONE, NULL }, /* Lp */
255 { ARGSFL_DELIM, NULL }, /* Lk */
256 { ARGSFL_DELIM, NULL }, /* Mt */
257 { ARGSFL_DELIM, NULL }, /* Brq */
258 { ARGSFL_NONE, NULL }, /* Bro */
259 { ARGSFL_DELIM, NULL }, /* Brc */
260 { ARGSFL_NONE, NULL }, /* %C */
261 { ARGSFL_NONE, NULL }, /* Es */
262 { ARGSFL_DELIM, NULL }, /* En */
263 { ARGSFL_DELIM, NULL }, /* Dx */
264 { ARGSFL_NONE, NULL }, /* %Q */
265 { ARGSFL_NONE, NULL }, /* br */
266 { ARGSFL_NONE, NULL }, /* sp */
267 { ARGSFL_NONE, NULL }, /* %U */
268 { ARGSFL_NONE, NULL }, /* Ta */
269 { ARGSFL_NONE, NULL }, /* ll */
274 * Parse flags and their arguments from the input line.
275 * These come in the form -flag [argument ...].
276 * Some flags take no argument, some one, some multiple.
278 void
279 mdoc_argv(struct roff_man *mdoc, int line, int tok,
280 struct mdoc_arg **reta, int *pos, char *buf)
282 struct mdoc_argv tmpv;
283 struct mdoc_argv **retv;
284 const enum mdocargt *argtable;
285 char *argname;
286 int ipos, retc;
287 char savechar;
289 *reta = NULL;
291 /* Which flags does this macro support? */
293 argtable = mdocargs[tok].argvs;
294 if (argtable == NULL)
295 return;
297 /* Loop over the flags on the input line. */
299 ipos = *pos;
300 while (buf[ipos] == '-') {
302 /* Seek to the first unescaped space. */
304 for (argname = buf + ++ipos; buf[ipos] != '\0'; ipos++)
305 if (buf[ipos] == ' ' && buf[ipos - 1] != '\\')
306 break;
309 * We want to nil-terminate the word to look it up.
310 * But we may not have a flag, in which case we need
311 * to restore the line as-is. So keep around the
312 * stray byte, which we'll reset upon exiting.
315 if ((savechar = buf[ipos]) != '\0')
316 buf[ipos++] = '\0';
319 * Now look up the word as a flag. Use temporary
320 * storage that we'll copy into the node's flags.
323 while ((tmpv.arg = *argtable++) != MDOC_ARG_MAX)
324 if ( ! strcmp(argname, mdoc_argnames[tmpv.arg]))
325 break;
327 /* If it isn't a flag, restore the saved byte. */
329 if (tmpv.arg == MDOC_ARG_MAX) {
330 if (savechar != '\0')
331 buf[ipos - 1] = savechar;
332 break;
335 /* Read to the next word (the first argument). */
337 while (buf[ipos] == ' ')
338 ipos++;
340 /* Parse the arguments of the flag. */
342 tmpv.line = line;
343 tmpv.pos = *pos;
344 tmpv.sz = 0;
345 tmpv.value = NULL;
347 switch (argvflags[tmpv.arg]) {
348 case ARGV_SINGLE:
349 argv_single(mdoc, line, &tmpv, &ipos, buf);
350 break;
351 case ARGV_MULTI:
352 argv_multi(mdoc, line, &tmpv, &ipos, buf);
353 break;
354 case ARGV_NONE:
355 break;
358 /* Append to the return values. */
360 if (*reta == NULL)
361 *reta = mandoc_calloc(1, sizeof(**reta));
363 retc = ++(*reta)->argc;
364 retv = &(*reta)->argv;
365 *retv = mandoc_reallocarray(*retv, retc, sizeof(**retv));
366 memcpy(*retv + retc - 1, &tmpv, sizeof(**retv));
368 /* Prepare for parsing the next flag. */
370 *pos = ipos;
371 argtable = mdocargs[tok].argvs;
375 void
376 mdoc_argv_free(struct mdoc_arg *p)
378 int i;
380 if (NULL == p)
381 return;
383 if (p->refcnt) {
384 --(p->refcnt);
385 if (p->refcnt)
386 return;
388 assert(p->argc);
390 for (i = (int)p->argc - 1; i >= 0; i--)
391 argn_free(p, i);
393 free(p->argv);
394 free(p);
397 static void
398 argn_free(struct mdoc_arg *p, int iarg)
400 struct mdoc_argv *arg;
401 int j;
403 arg = &p->argv[iarg];
405 if (arg->sz && arg->value) {
406 for (j = (int)arg->sz - 1; j >= 0; j--)
407 free(arg->value[j]);
408 free(arg->value);
411 for (--p->argc; iarg < (int)p->argc; iarg++)
412 p->argv[iarg] = p->argv[iarg+1];
415 enum margserr
416 mdoc_args(struct roff_man *mdoc, int line, int *pos,
417 char *buf, int tok, char **v)
419 struct roff_node *n;
420 char *v_local;
421 enum argsflag fl;
423 if (v == NULL)
424 v = &v_local;
425 fl = tok == TOKEN_NONE ? ARGSFL_NONE : mdocargs[tok].flags;
426 if (tok != MDOC_It)
427 return args(mdoc, line, pos, buf, fl, v);
430 * We know that we're in an `It', so it's reasonable to expect
431 * us to be sitting in a `Bl'. Someday this may not be the case
432 * (if we allow random `It's sitting out there), so provide a
433 * safe fall-back into the default behaviour.
436 for (n = mdoc->last; n; n = n->parent)
437 if (MDOC_Bl == n->tok)
438 if (LIST_column == n->norm->Bl.type) {
439 fl = ARGSFL_TABSEP;
440 break;
443 return args(mdoc, line, pos, buf, fl, v);
446 static enum margserr
447 args(struct roff_man *mdoc, int line, int *pos,
448 char *buf, enum argsflag fl, char **v)
450 char *p;
451 int pairs;
453 if (buf[*pos] == '\0') {
454 if (mdoc->flags & MDOC_PHRASELIT &&
455 ! (mdoc->flags & MDOC_PHRASE)) {
456 mandoc_msg(MANDOCERR_ARG_QUOTE,
457 mdoc->parse, line, *pos, NULL);
458 mdoc->flags &= ~MDOC_PHRASELIT;
460 return ARGS_EOLN;
463 *v = buf + *pos;
465 if (fl == ARGSFL_DELIM && args_checkpunct(buf, *pos))
466 return ARGS_PUNCT;
469 * Tabs in `It' lines in `Bl -column' can't be escaped.
470 * Phrases are reparsed for `Ta' and other macros later.
473 if (fl == ARGSFL_TABSEP) {
474 if ((p = strchr(*v, '\t')) != NULL) {
477 * Words right before and right after
478 * tab characters are not parsed,
479 * unless there is a blank in between.
482 if (p[-1] != ' ')
483 mdoc->flags |= MDOC_PHRASEQL;
484 if (p[1] != ' ')
485 mdoc->flags |= MDOC_PHRASEQN;
488 * One or more blanks after a tab cause
489 * one leading blank in the next column.
490 * So skip all but one of them.
493 *pos += (int)(p - *v) + 1;
494 while (buf[*pos] == ' ' && buf[*pos + 1] == ' ')
495 (*pos)++;
498 * A tab at the end of an input line
499 * switches to the next column.
502 if (buf[*pos] == '\0' || buf[*pos + 1] == '\0')
503 mdoc->flags |= MDOC_PHRASEQN;
504 } else {
505 p = strchr(*v, '\0');
506 if (p[-1] == ' ')
507 mandoc_msg(MANDOCERR_SPACE_EOL,
508 mdoc->parse, line, *pos, NULL);
509 *pos += (int)(p - *v);
512 /* Skip any trailing blank characters. */
513 while (p > *v && p[-1] == ' ' &&
514 (p - 1 == *v || p[-2] != '\\'))
515 p--;
516 *p = '\0';
518 return ARGS_PHRASE;
522 * Process a quoted literal. A quote begins with a double-quote
523 * and ends with a double-quote NOT preceded by a double-quote.
524 * NUL-terminate the literal in place.
525 * Collapse pairs of quotes inside quoted literals.
526 * Whitespace is NOT involved in literal termination.
529 if (mdoc->flags & MDOC_PHRASELIT || buf[*pos] == '\"') {
530 if ( ! (mdoc->flags & MDOC_PHRASELIT))
531 *v = &buf[++(*pos)];
533 if (mdoc->flags & MDOC_PHRASE)
534 mdoc->flags |= MDOC_PHRASELIT;
536 pairs = 0;
537 for ( ; buf[*pos]; (*pos)++) {
538 /* Move following text left after quoted quotes. */
539 if (pairs)
540 buf[*pos - pairs] = buf[*pos];
541 if ('\"' != buf[*pos])
542 continue;
543 /* Unquoted quotes end quoted args. */
544 if ('\"' != buf[*pos + 1])
545 break;
546 /* Quoted quotes collapse. */
547 pairs++;
548 (*pos)++;
550 if (pairs)
551 buf[*pos - pairs] = '\0';
553 if (buf[*pos] == '\0') {
554 if ( ! (mdoc->flags & MDOC_PHRASE))
555 mandoc_msg(MANDOCERR_ARG_QUOTE,
556 mdoc->parse, line, *pos, NULL);
557 return ARGS_QWORD;
560 mdoc->flags &= ~MDOC_PHRASELIT;
561 buf[(*pos)++] = '\0';
563 if ('\0' == buf[*pos])
564 return ARGS_QWORD;
566 while (' ' == buf[*pos])
567 (*pos)++;
569 if ('\0' == buf[*pos])
570 mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse,
571 line, *pos, NULL);
573 return ARGS_QWORD;
576 p = &buf[*pos];
577 *v = mandoc_getarg(mdoc->parse, &p, line, pos);
580 * After parsing the last word in this phrase,
581 * tell lookup() whether or not to interpret it.
584 if (*p == '\0' && mdoc->flags & MDOC_PHRASEQL) {
585 mdoc->flags &= ~MDOC_PHRASEQL;
586 mdoc->flags |= MDOC_PHRASEQF;
588 return ARGS_WORD;
592 * Check if the string consists only of space-separated closing
593 * delimiters. This is a bit of a dance: the first must be a close
594 * delimiter, but it may be followed by middle delimiters. Arbitrary
595 * whitespace may separate these tokens.
597 static int
598 args_checkpunct(const char *buf, int i)
600 int j;
601 char dbuf[DELIMSZ];
602 enum mdelim d;
604 /* First token must be a close-delimiter. */
606 for (j = 0; buf[i] && ' ' != buf[i] && j < DELIMSZ; j++, i++)
607 dbuf[j] = buf[i];
609 if (DELIMSZ == j)
610 return 0;
612 dbuf[j] = '\0';
613 if (DELIM_CLOSE != mdoc_isdelim(dbuf))
614 return 0;
616 while (' ' == buf[i])
617 i++;
619 /* Remaining must NOT be open/none. */
621 while (buf[i]) {
622 j = 0;
623 while (buf[i] && ' ' != buf[i] && j < DELIMSZ)
624 dbuf[j++] = buf[i++];
626 if (DELIMSZ == j)
627 return 0;
629 dbuf[j] = '\0';
630 d = mdoc_isdelim(dbuf);
631 if (DELIM_NONE == d || DELIM_OPEN == d)
632 return 0;
634 while (' ' == buf[i])
635 i++;
638 return '\0' == buf[i];
641 static void
642 argv_multi(struct roff_man *mdoc, int line,
643 struct mdoc_argv *v, int *pos, char *buf)
645 enum margserr ac;
646 char *p;
648 for (v->sz = 0; ; v->sz++) {
649 if (buf[*pos] == '-')
650 break;
651 ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
652 if (ac == ARGS_EOLN)
653 break;
655 if (v->sz % MULTI_STEP == 0)
656 v->value = mandoc_reallocarray(v->value,
657 v->sz + MULTI_STEP, sizeof(char *));
659 v->value[(int)v->sz] = mandoc_strdup(p);
663 static void
664 argv_single(struct roff_man *mdoc, int line,
665 struct mdoc_argv *v, int *pos, char *buf)
667 enum margserr ac;
668 char *p;
670 ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
671 if (ac == ARGS_EOLN)
672 return;
674 v->sz = 1;
675 v->value = mandoc_malloc(sizeof(char *));
676 v->value[0] = mandoc_strdup(p);