Print this page
5051 import mdocml-1.12.3
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Approved by: TBD

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mandoc/mdoc_argv.c
          +++ new/usr/src/cmd/mandoc/mdoc_argv.c
   1      -/*      $Id: mdoc_argv.c,v 1.82 2012/03/23 05:50:24 kristaps Exp $ */
        1 +/*      $Id: mdoc_argv.c,v 1.89 2013/12/25 00:50:05 schwarze Exp $ */
   2    2  /*
   3    3   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
        4 + * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
   4    5   *
   5    6   * Permission to use, copy, modify, and distribute this software for any
   6    7   * purpose with or without fee is hereby granted, provided that the above
   7    8   * copyright notice and this permission notice appear in all copies.
   8    9   *
   9   10   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10   11   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11   12   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12   13   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13   14   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
↓ open down ↓ 21 lines elided ↑ open up ↑
  35   36  
  36   37  enum    argsflag {
  37   38          ARGSFL_NONE = 0,
  38   39          ARGSFL_DELIM, /* handle delimiters of [[::delim::][ ]+]+ */
  39   40          ARGSFL_TABSEP /* handle tab/`Ta' separated phrases */
  40   41  };
  41   42  
  42   43  enum    argvflag {
  43   44          ARGV_NONE, /* no args to flag (e.g., -split) */
  44   45          ARGV_SINGLE, /* one arg to flag (e.g., -file xxx)  */
  45      -        ARGV_MULTI, /* multiple args (e.g., -column xxx yyy) */
  46      -        ARGV_OPT_SINGLE /* optional arg (e.g., -offset [xxx]) */
       46 +        ARGV_MULTI /* multiple args (e.g., -column xxx yyy) */
  47   47  };
  48   48  
  49   49  struct  mdocarg {
  50   50          enum argsflag    flags;
  51   51          const enum mdocargt *argvs;
  52   52  };
  53   53  
  54   54  static  void             argn_free(struct mdoc_arg *, int);
  55   55  static  enum margserr    args(struct mdoc *, int, int *, 
  56   56                                  char *, enum argsflag, char **);
  57   57  static  int              args_checkpunct(const char *, int);
  58   58  static  int              argv_multi(struct mdoc *, int, 
  59   59                                  struct mdoc_argv *, int *, char *);
  60      -static  int              argv_opt_single(struct mdoc *, int, 
  61      -                                struct mdoc_argv *, int *, char *);
  62   60  static  int              argv_single(struct mdoc *, int, 
  63   61                                  struct mdoc_argv *, int *, char *);
  64   62  
  65   63  static  const enum argvflag argvflags[MDOC_ARG_MAX] = {
  66   64          ARGV_NONE,      /* MDOC_Split */
  67   65          ARGV_NONE,      /* MDOC_Nosplit */
  68   66          ARGV_NONE,      /* MDOC_Ragged */
  69   67          ARGV_NONE,      /* MDOC_Unfilled */
  70   68          ARGV_NONE,      /* MDOC_Literal */
  71   69          ARGV_SINGLE,    /* MDOC_File */
  72      -        ARGV_OPT_SINGLE, /* MDOC_Offset */
       70 +        ARGV_SINGLE,    /* MDOC_Offset */
  73   71          ARGV_NONE,      /* MDOC_Bullet */
  74   72          ARGV_NONE,      /* MDOC_Dash */
  75   73          ARGV_NONE,      /* MDOC_Hyphen */
  76   74          ARGV_NONE,      /* MDOC_Item */
  77   75          ARGV_NONE,      /* MDOC_Enum */
  78   76          ARGV_NONE,      /* MDOC_Tag */
  79   77          ARGV_NONE,      /* MDOC_Diag */
  80   78          ARGV_NONE,      /* MDOC_Hang */
  81   79          ARGV_NONE,      /* MDOC_Ohang */
  82   80          ARGV_NONE,      /* MDOC_Inset */
  83   81          ARGV_MULTI,     /* MDOC_Column */
  84      -        ARGV_OPT_SINGLE, /* MDOC_Width */
       82 +        ARGV_SINGLE,    /* MDOC_Width */
  85   83          ARGV_NONE,      /* MDOC_Compact */
  86   84          ARGV_NONE,      /* MDOC_Std */
  87   85          ARGV_NONE,      /* MDOC_Filled */
  88   86          ARGV_NONE,      /* MDOC_Words */
  89   87          ARGV_NONE,      /* MDOC_Emphasis */
  90   88          ARGV_NONE,      /* MDOC_Symbolic */
  91   89          ARGV_NONE       /* MDOC_Symbolic */
  92   90  };
  93   91  
  94   92  static  const enum mdocargt args_Ex[] = {
↓ open down ↓ 44 lines elided ↑ open up ↑
 139  137          MDOC_Inset,
 140  138          MDOC_Column,
 141  139          MDOC_Width,
 142  140          MDOC_Offset,
 143  141          MDOC_Compact,
 144  142          MDOC_Nested,
 145  143          MDOC_ARG_MAX
 146  144  };
 147  145  
 148  146  static  const struct mdocarg mdocargs[MDOC_MAX] = {
 149      -        { ARGSFL_NONE, NULL }, /* Ap */
      147 +        { ARGSFL_DELIM, NULL }, /* Ap */
 150  148          { ARGSFL_NONE, NULL }, /* Dd */
 151  149          { ARGSFL_NONE, NULL }, /* Dt */
 152  150          { ARGSFL_NONE, NULL }, /* Os */
 153  151          { ARGSFL_NONE, NULL }, /* Sh */
 154  152          { ARGSFL_NONE, NULL }, /* Ss */ 
 155  153          { ARGSFL_NONE, NULL }, /* Pp */ 
 156  154          { ARGSFL_DELIM, NULL }, /* D1 */
 157  155          { ARGSFL_DELIM, NULL }, /* Dl */
 158  156          { ARGSFL_NONE, args_Bd }, /* Bd */
 159  157          { ARGSFL_NONE, NULL }, /* Ed */
 160  158          { ARGSFL_NONE, args_Bl }, /* Bl */
 161  159          { ARGSFL_NONE, NULL }, /* El */
 162  160          { ARGSFL_NONE, NULL }, /* It */
 163  161          { ARGSFL_DELIM, NULL }, /* Ad */ 
 164  162          { ARGSFL_DELIM, args_An }, /* An */
 165  163          { ARGSFL_DELIM, NULL }, /* Ar */
 166      -        { ARGSFL_NONE, NULL }, /* Cd */
      164 +        { ARGSFL_DELIM, NULL }, /* Cd */
 167  165          { ARGSFL_DELIM, NULL }, /* Cm */
 168  166          { ARGSFL_DELIM, NULL }, /* Dv */ 
 169  167          { ARGSFL_DELIM, NULL }, /* Er */ 
 170  168          { ARGSFL_DELIM, NULL }, /* Ev */ 
 171  169          { ARGSFL_NONE, args_Ex }, /* Ex */
 172  170          { ARGSFL_DELIM, NULL }, /* Fa */ 
 173  171          { ARGSFL_NONE, NULL }, /* Fd */ 
 174  172          { ARGSFL_DELIM, NULL }, /* Fl */
 175  173          { ARGSFL_DELIM, NULL }, /* Fn */ 
 176  174          { ARGSFL_DELIM, NULL }, /* Ft */ 
 177  175          { ARGSFL_DELIM, NULL }, /* Ic */ 
 178      -        { ARGSFL_NONE, NULL }, /* In */ 
      176 +        { ARGSFL_DELIM, NULL }, /* In */ 
 179  177          { ARGSFL_DELIM, NULL }, /* Li */
 180  178          { ARGSFL_NONE, NULL }, /* Nd */ 
 181  179          { ARGSFL_DELIM, NULL }, /* Nm */ 
 182  180          { ARGSFL_DELIM, NULL }, /* Op */
 183  181          { ARGSFL_NONE, NULL }, /* Ot */
 184  182          { ARGSFL_DELIM, NULL }, /* Pa */
 185  183          { ARGSFL_NONE, args_Ex }, /* Rv */
 186  184          { ARGSFL_DELIM, NULL }, /* St */ 
 187  185          { ARGSFL_DELIM, NULL }, /* Va */
 188  186          { ARGSFL_DELIM, NULL }, /* Vt */ 
↓ open down ↓ 47 lines elided ↑ open up ↑
 236  234          { ARGSFL_NONE, NULL }, /* So */
 237  235          { ARGSFL_DELIM, NULL }, /* Sq */
 238  236          { ARGSFL_NONE, NULL }, /* Sm */
 239  237          { ARGSFL_DELIM, NULL }, /* Sx */
 240  238          { ARGSFL_DELIM, NULL }, /* Sy */
 241  239          { ARGSFL_DELIM, NULL }, /* Tn */
 242  240          { ARGSFL_DELIM, NULL }, /* Ux */
 243  241          { ARGSFL_DELIM, NULL }, /* Xc */
 244  242          { ARGSFL_NONE, NULL }, /* Xo */
 245  243          { ARGSFL_NONE, NULL }, /* Fo */ 
 246      -        { ARGSFL_NONE, NULL }, /* Fc */ 
      244 +        { ARGSFL_DELIM, NULL }, /* Fc */ 
 247  245          { ARGSFL_NONE, NULL }, /* Oo */
 248  246          { ARGSFL_DELIM, NULL }, /* Oc */
 249  247          { ARGSFL_NONE, args_Bk }, /* Bk */
 250  248          { ARGSFL_NONE, NULL }, /* Ek */
 251  249          { ARGSFL_NONE, NULL }, /* Bt */
 252  250          { ARGSFL_NONE, NULL }, /* Hf */
 253  251          { ARGSFL_NONE, NULL }, /* Fr */
 254  252          { ARGSFL_NONE, NULL }, /* Ud */
 255      -        { ARGSFL_NONE, NULL }, /* Lb */
      253 +        { ARGSFL_DELIM, NULL }, /* Lb */
 256  254          { ARGSFL_NONE, NULL }, /* Lp */
 257  255          { ARGSFL_DELIM, NULL }, /* Lk */
 258  256          { ARGSFL_DELIM, NULL }, /* Mt */
 259  257          { ARGSFL_DELIM, NULL }, /* Brq */
 260  258          { ARGSFL_NONE, NULL }, /* Bro */
 261  259          { ARGSFL_DELIM, NULL }, /* Brc */
 262  260          { ARGSFL_NONE, NULL }, /* %C */
 263  261          { ARGSFL_NONE, NULL }, /* Es */
 264  262          { ARGSFL_NONE, NULL }, /* En */
 265      -        { ARGSFL_NONE, NULL }, /* Dx */
      263 +        { ARGSFL_DELIM, NULL }, /* Dx */
 266  264          { ARGSFL_NONE, NULL }, /* %Q */
 267  265          { ARGSFL_NONE, NULL }, /* br */
 268  266          { ARGSFL_NONE, NULL }, /* sp */
 269  267          { ARGSFL_NONE, NULL }, /* %U */
 270  268          { ARGSFL_NONE, NULL }, /* Ta */
 271  269  };
 272  270  
 273  271  
 274  272  /*
 275  273   * Parse an argument from line text.  This comes in the form of -key
 276  274   * [value0...], which may either have a single mandatory value, at least
 277  275   * one mandatory value, an optional single value, or no value.
 278  276   */
 279  277  enum margverr
 280      -mdoc_argv(struct mdoc *m, int line, enum mdoct tok,
      278 +mdoc_argv(struct mdoc *mdoc, int line, enum mdoct tok,
 281  279                  struct mdoc_arg **v, int *pos, char *buf)
 282  280  {
 283  281          char             *p, sv;
 284  282          struct mdoc_argv tmp;
 285  283          struct mdoc_arg  *arg;
 286  284          const enum mdocargt *ap;
 287  285  
 288  286          if ('\0' == buf[*pos])
 289  287                  return(ARGV_EOLN);
 290  288          else if (NULL == (ap = mdocargs[tok].argvs))
↓ open down ↓ 46 lines elided ↑ open up ↑
 337  335                  return(ARGV_WORD);
 338  336          }
 339  337  
 340  338          /* Read to the next word (the argument). */
 341  339  
 342  340          while (buf[*pos] && ' ' == buf[*pos])
 343  341                  (*pos)++;
 344  342  
 345  343          switch (argvflags[tmp.arg]) {
 346  344          case (ARGV_SINGLE):
 347      -                if ( ! argv_single(m, line, &tmp, pos, buf))
      345 +                if ( ! argv_single(mdoc, line, &tmp, pos, buf))
 348  346                          return(ARGV_ERROR);
 349  347                  break;
 350  348          case (ARGV_MULTI):
 351      -                if ( ! argv_multi(m, line, &tmp, pos, buf))
      349 +                if ( ! argv_multi(mdoc, line, &tmp, pos, buf))
 352  350                          return(ARGV_ERROR);
 353  351                  break;
 354      -        case (ARGV_OPT_SINGLE):
 355      -                if ( ! argv_opt_single(m, line, &tmp, pos, buf))
 356      -                        return(ARGV_ERROR);
 357      -                break;
 358  352          case (ARGV_NONE):
 359  353                  break;
 360  354          }
 361  355  
 362  356          if (NULL == (arg = *v))
 363  357                  arg = *v = mandoc_calloc(1, sizeof(struct mdoc_arg));
 364  358  
 365  359          arg->argc++;
 366  360          arg->argv = mandoc_realloc
 367  361                  (arg->argv, arg->argc * sizeof(struct mdoc_argv));
↓ open down ↓ 38 lines elided ↑ open up ↑
 406  400                  for (j = (int)arg->sz - 1; j >= 0; j--) 
 407  401                          free(arg->value[j]);
 408  402                  free(arg->value);
 409  403          }
 410  404  
 411  405          for (--p->argc; iarg < (int)p->argc; iarg++)
 412  406                  p->argv[iarg] = p->argv[iarg+1];
 413  407  }
 414  408  
 415  409  enum margserr
 416      -mdoc_zargs(struct mdoc *m, int line, int *pos, char *buf, char **v)
      410 +mdoc_zargs(struct mdoc *mdoc, int line, int *pos, char *buf, char **v)
 417  411  {
 418  412  
 419      -        return(args(m, line, pos, buf, ARGSFL_NONE, v));
      413 +        return(args(mdoc, line, pos, buf, ARGSFL_NONE, v));
 420  414  }
 421  415  
 422  416  enum margserr
 423      -mdoc_args(struct mdoc *m, int line, int *pos, 
      417 +mdoc_args(struct mdoc *mdoc, int line, int *pos, 
 424  418                  char *buf, enum mdoct tok, char **v)
 425  419  {
 426  420          enum argsflag     fl;
 427  421          struct mdoc_node *n;
 428  422  
 429  423          fl = mdocargs[tok].flags;
 430  424  
 431  425          if (MDOC_It != tok)
 432      -                return(args(m, line, pos, buf, fl, v));
      426 +                return(args(mdoc, line, pos, buf, fl, v));
 433  427  
 434  428          /*
 435  429           * We know that we're in an `It', so it's reasonable to expect
 436  430           * us to be sitting in a `Bl'.  Someday this may not be the case
 437  431           * (if we allow random `It's sitting out there), so provide a
 438  432           * safe fall-back into the default behaviour.
 439  433           */
 440  434  
 441      -        for (n = m->last; n; n = n->parent)
      435 +        for (n = mdoc->last; n; n = n->parent)
 442  436                  if (MDOC_Bl == n->tok)
 443  437                          if (LIST_column == n->norm->Bl.type) {
 444  438                                  fl = ARGSFL_TABSEP;
 445  439                                  break;
 446  440                          }
 447  441  
 448      -        return(args(m, line, pos, buf, fl, v));
      442 +        return(args(mdoc, line, pos, buf, fl, v));
 449  443  }
 450  444  
 451  445  static enum margserr
 452      -args(struct mdoc *m, int line, int *pos, 
      446 +args(struct mdoc *mdoc, int line, int *pos, 
 453  447                  char *buf, enum argsflag fl, char **v)
 454  448  {
 455  449          char            *p, *pp;
      450 +        int              pairs;
 456  451          enum margserr    rc;
 457  452  
 458  453          if ('\0' == buf[*pos]) {
 459      -                if (MDOC_PPHRASE & m->flags)
      454 +                if (MDOC_PPHRASE & mdoc->flags)
 460  455                          return(ARGS_EOLN);
 461  456                  /*
 462  457                   * If we're not in a partial phrase and the flag for
 463  458                   * being a phrase literal is still set, the punctuation
 464  459                   * is unterminated.
 465  460                   */
 466      -                if (MDOC_PHRASELIT & m->flags)
 467      -                        mdoc_pmsg(m, line, *pos, MANDOCERR_BADQUOTE);
      461 +                if (MDOC_PHRASELIT & mdoc->flags)
      462 +                        mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE);
 468  463  
 469      -                m->flags &= ~MDOC_PHRASELIT;
      464 +                mdoc->flags &= ~MDOC_PHRASELIT;
 470  465                  return(ARGS_EOLN);
 471  466          }
 472  467  
 473  468          *v = &buf[*pos];
 474  469  
 475  470          if (ARGSFL_DELIM == fl)
 476  471                  if (args_checkpunct(buf, *pos))
 477  472                          return(ARGS_PUNCT);
 478  473  
 479  474          /*
↓ open down ↓ 2 lines elided ↑ open up ↑
 482  477           * `Ta' macros to separate phrases.  Phrases are parsed again
 483  478           * for arguments at a later phase.
 484  479           */
 485  480  
 486  481          if (ARGSFL_TABSEP == fl) {
 487  482                  /* Scan ahead to tab (can't be escaped). */
 488  483                  p = strchr(*v, '\t');
 489  484                  pp = NULL;
 490  485  
 491  486                  /* Scan ahead to unescaped `Ta'. */
 492      -                if ( ! (MDOC_PHRASELIT & m->flags)) 
      487 +                if ( ! (MDOC_PHRASELIT & mdoc->flags)) 
 493  488                          for (pp = *v; ; pp++) {
 494  489                                  if (NULL == (pp = strstr(pp, "Ta")))
 495  490                                          break;
 496  491                                  if (pp > *v && ' ' != *(pp - 1))
 497  492                                          continue;
 498  493                                  if (' ' == *(pp + 2) || '\0' == *(pp + 2))
 499  494                                          break;
 500  495                          }
 501  496  
 502  497                  /* By default, assume a phrase. */
↓ open down ↓ 13 lines elided ↑ open up ↑
 516  511                  } else if (pp && ! p) {
 517  512                          p = pp;
 518  513                          *pos += 2;
 519  514                  } else {
 520  515                          rc = ARGS_PEND;
 521  516                          p = strchr(*v, 0);
 522  517                  }
 523  518  
 524  519                  /* Whitespace check for eoln case... */
 525  520                  if ('\0' == *p && ' ' == *(p - 1))
 526      -                        mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE);
      521 +                        mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE);
 527  522  
 528  523                  *pos += (int)(p - *v);
 529  524  
 530  525                  /* Strip delimiter's preceding whitespace. */
 531  526                  pp = p - 1;
 532  527                  while (pp > *v && ' ' == *pp) {
 533  528                          if (pp > *v && '\\' == *(pp - 1))
 534  529                                  break;
 535  530                          pp--;
 536  531                  }
 537  532                  *(pp + 1) = 0;
 538  533  
 539  534                  /* Strip delimiter's proceeding whitespace. */
 540  535                  for (pp = &buf[*pos]; ' ' == *pp; pp++, (*pos)++)
 541  536                          /* Skip ahead. */ ;
 542  537  
 543  538                  return(rc);
 544      -        } 
      539 +        }
 545  540  
 546      -        /* 
      541 +        /*
 547  542           * Process a quoted literal.  A quote begins with a double-quote
 548  543           * and ends with a double-quote NOT preceded by a double-quote.
      544 +         * NUL-terminate the literal in place.
      545 +         * Collapse pairs of quotes inside quoted literals.
 549  546           * Whitespace is NOT involved in literal termination.
 550  547           */
 551  548  
 552      -        if (MDOC_PHRASELIT & m->flags || '\"' == buf[*pos]) {
 553      -                if ( ! (MDOC_PHRASELIT & m->flags))
      549 +        if (MDOC_PHRASELIT & mdoc->flags || '\"' == buf[*pos]) {
      550 +                if ( ! (MDOC_PHRASELIT & mdoc->flags))
 554  551                          *v = &buf[++(*pos)];
 555  552  
 556      -                if (MDOC_PPHRASE & m->flags)
 557      -                        m->flags |= MDOC_PHRASELIT;
      553 +                if (MDOC_PPHRASE & mdoc->flags)
      554 +                        mdoc->flags |= MDOC_PHRASELIT;
 558  555  
      556 +                pairs = 0;
 559  557                  for ( ; buf[*pos]; (*pos)++) {
      558 +                        /* Move following text left after quoted quotes. */
      559 +                        if (pairs)
      560 +                                buf[*pos - pairs] = buf[*pos];
 560  561                          if ('\"' != buf[*pos])
 561  562                                  continue;
      563 +                        /* Unquoted quotes end quoted args. */
 562  564                          if ('\"' != buf[*pos + 1])
 563  565                                  break;
      566 +                        /* Quoted quotes collapse. */
      567 +                        pairs++;
 564  568                          (*pos)++;
 565  569                  }
      570 +                if (pairs)
      571 +                        buf[*pos - pairs] = '\0';
 566  572  
 567  573                  if ('\0' == buf[*pos]) {
 568      -                        if (MDOC_PPHRASE & m->flags)
      574 +                        if (MDOC_PPHRASE & mdoc->flags)
 569  575                                  return(ARGS_QWORD);
 570      -                        mdoc_pmsg(m, line, *pos, MANDOCERR_BADQUOTE);
      576 +                        mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE);
 571  577                          return(ARGS_QWORD);
 572  578                  }
 573  579  
 574      -                m->flags &= ~MDOC_PHRASELIT;
      580 +                mdoc->flags &= ~MDOC_PHRASELIT;
 575  581                  buf[(*pos)++] = '\0';
 576  582  
 577  583                  if ('\0' == buf[*pos])
 578  584                          return(ARGS_QWORD);
 579  585  
 580  586                  while (' ' == buf[*pos])
 581  587                          (*pos)++;
 582  588  
 583  589                  if ('\0' == buf[*pos])
 584      -                        mdoc_pmsg(m, line, *pos, MANDOCERR_EOLNSPACE);
      590 +                        mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE);
 585  591  
 586  592                  return(ARGS_QWORD);
 587  593          }
 588  594  
 589  595          p = &buf[*pos];
 590      -        *v = mandoc_getarg(m->parse, &p, line, pos);
      596 +        *v = mandoc_getarg(mdoc->parse, &p, line, pos);
 591  597  
 592  598          return(ARGS_WORD);
 593  599  }
 594  600  
 595  601  /* 
 596  602   * Check if the string consists only of space-separated closing
 597  603   * delimiters.  This is a bit of a dance: the first must be a close
 598  604   * delimiter, but it may be followed by middle delimiters.  Arbitrary
 599  605   * whitespace may separate these tokens.
 600  606   */
↓ open down ↓ 35 lines elided ↑ open up ↑
 636  642                          return(0);
 637  643  
 638  644                  while (' ' == buf[i])
 639  645                          i++;
 640  646          }
 641  647  
 642  648          return('\0' == buf[i]);
 643  649  }
 644  650  
 645  651  static int
 646      -argv_multi(struct mdoc *m, int line, 
      652 +argv_multi(struct mdoc *mdoc, int line, 
 647  653                  struct mdoc_argv *v, int *pos, char *buf)
 648  654  {
 649  655          enum margserr    ac;
 650  656          char            *p;
 651  657  
 652  658          for (v->sz = 0; ; v->sz++) {
 653  659                  if ('-' == buf[*pos])
 654  660                          break;
 655      -                ac = args(m, line, pos, buf, ARGSFL_NONE, &p);
      661 +                ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
 656  662                  if (ARGS_ERROR == ac)
 657  663                          return(0);
 658  664                  else if (ARGS_EOLN == ac)
 659  665                          break;
 660  666  
 661  667                  if (0 == v->sz % MULTI_STEP)
 662  668                          v->value = mandoc_realloc(v->value, 
 663  669                                  (v->sz + MULTI_STEP) * sizeof(char *));
 664  670  
 665  671                  v->value[(int)v->sz] = mandoc_strdup(p);
 666  672          }
 667  673  
 668  674          return(1);
 669  675  }
 670  676  
 671  677  static int
 672      -argv_opt_single(struct mdoc *m, int line, 
      678 +argv_single(struct mdoc *mdoc, int line, 
 673  679                  struct mdoc_argv *v, int *pos, char *buf)
 674  680  {
 675  681          enum margserr    ac;
 676  682          char            *p;
 677  683  
 678      -        if ('-' == buf[*pos])
 679      -                return(1);
 680      -
 681      -        ac = args(m, line, pos, buf, ARGSFL_NONE, &p);
      684 +        ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p);
 682  685          if (ARGS_ERROR == ac)
 683  686                  return(0);
 684  687          if (ARGS_EOLN == ac)
 685  688                  return(1);
 686  689  
 687  690          v->sz = 1;
 688      -        v->value = mandoc_malloc(sizeof(char *));
 689      -        v->value[0] = mandoc_strdup(p);
 690      -
 691      -        return(1);
 692      -}
 693      -
 694      -static int
 695      -argv_single(struct mdoc *m, int line, 
 696      -                struct mdoc_argv *v, int *pos, char *buf)
 697      -{
 698      -        int              ppos;
 699      -        enum margserr    ac;
 700      -        char            *p;
 701      -
 702      -        ppos = *pos;
 703      -
 704      -        ac = args(m, line, pos, buf, ARGSFL_NONE, &p);
 705      -        if (ARGS_EOLN == ac) {
 706      -                mdoc_pmsg(m, line, ppos, MANDOCERR_SYNTARGVCOUNT);
 707      -                return(0);
 708      -        } else if (ARGS_ERROR == ac)
 709      -                return(0);
 710      -
 711      -        v->sz = 1;
 712  691          v->value = mandoc_malloc(sizeof(char *));
 713  692          v->value[0] = mandoc_strdup(p);
 714  693  
 715  694          return(1);
 716  695  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX