[BACK]Return to mdoc_macro.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mdoc_macro.c between version 1.138 and 1.149

version 1.138, 2014/07/30 17:06:26 version 1.149, 2014/11/28 01:05:43
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #ifdef HAVE_CONFIG_H  
 #include "config.h"  #include "config.h"
 #endif  
   
   #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 62  static int  phrase(struct mdoc *, int, int, char *);
Line 62  static int  phrase(struct mdoc *, int, int, char *);
 static  enum mdoct      rew_alt(enum mdoct);  static  enum mdoct      rew_alt(enum mdoct);
 static  enum rew        rew_dohalt(enum mdoct, enum mdoc_type,  static  enum rew        rew_dohalt(enum mdoct, enum mdoc_type,
                                 const struct mdoc_node *);                                  const struct mdoc_node *);
 static  int             rew_elem(struct mdoc *, enum mdoct);  static  void            rew_elem(struct mdoc *, enum mdoct);
 static  int             rew_last(struct mdoc *,  static  void            rew_last(struct mdoc *, const struct mdoc_node *);
                                 const struct mdoc_node *);  
 static  int             rew_sub(enum mdoc_type, struct mdoc *,  static  int             rew_sub(enum mdoc_type, struct mdoc *,
                                 enum mdoct, int, int);                                  enum mdoct, int, int);
   
Line 147  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 146  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */          { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */
         { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */          { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */
           { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* No */
         { in_line_argn, MDOC_CALLABLE | MDOC_PARSED |          { in_line_argn, MDOC_CALLABLE | MDOC_PARSED |
                         MDOC_IGNDELIM | MDOC_JOIN }, /* No */  
         { in_line_argn, MDOC_CALLABLE | MDOC_PARSED |  
                         MDOC_IGNDELIM | MDOC_JOIN }, /* Ns */                          MDOC_IGNDELIM | MDOC_JOIN }, /* Ns */
         { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */          { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */
         { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ox */          { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ox */
Line 172  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 170  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED |          { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED |
                         MDOC_EXPLICIT | MDOC_JOIN }, /* So */                          MDOC_EXPLICIT | MDOC_JOIN }, /* So */
         { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sq */          { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sq */
         { in_line_eoln, 0 }, /* Sm */          { in_line_argn, 0 }, /* Sm */
         { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sx */          { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sx */
         { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sy */          { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sy */
         { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Tn */          { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Tn */
Line 210  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 208  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
         { in_line_eoln, 0 }, /* sp */          { in_line_eoln, 0 }, /* sp */
         { in_line_eoln, 0 }, /* %U */          { in_line_eoln, 0 }, /* %U */
         { phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */          { phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */
         { in_line_eoln, 0 }, /* ll */          { in_line_eoln, MDOC_PROLOGUE }, /* ll */
 };  };
   
 const   struct mdoc_macro * const mdoc_macros = __mdoc_macros;  const   struct mdoc_macro * const mdoc_macros = __mdoc_macros;
Line 239  mdoc_macroend(struct mdoc *mdoc)
Line 237  mdoc_macroend(struct mdoc *mdoc)
   
         /* Rewind to the first. */          /* Rewind to the first. */
   
         return(rew_last(mdoc, mdoc->first));          rew_last(mdoc, mdoc->first);
           return(1);
 }  }
   
 /*  /*
Line 269  lookup_raw(const char *p)
Line 268  lookup_raw(const char *p)
         return(MDOC_MAX);          return(MDOC_MAX);
 }  }
   
 static int  static void
 rew_last(struct mdoc *mdoc, const struct mdoc_node *to)  rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
 {  {
         struct mdoc_node *n, *np;          struct mdoc_node *n, *np;
   
         assert(to);          assert(to);
         mdoc->next = MDOC_NEXT_SIBLING;          mdoc->next = MDOC_NEXT_SIBLING;
   
   
         while (mdoc->last != to) {          while (mdoc->last != to) {
                 /*                  /*
                  * Save the parent here, because we may delete the                   * Save the parent here, because we may delete the
Line 286  rew_last(struct mdoc *mdoc, const struct mdoc_node *to
Line 283  rew_last(struct mdoc *mdoc, const struct mdoc_node *to
                  * out to be lost.                   * out to be lost.
                  */                   */
                 np = mdoc->last->parent;                  np = mdoc->last->parent;
                 if ( ! mdoc_valid_post(mdoc))                  mdoc_valid_post(mdoc);
                         return(0);  
                 n = mdoc->last;                  n = mdoc->last;
                 mdoc->last = np;                  mdoc->last = np;
                 assert(mdoc->last);                  assert(mdoc->last);
                 mdoc->last->last = n;                  mdoc->last->last = n;
         }          }
           mdoc_valid_post(mdoc);
         return(mdoc_valid_post(mdoc));  
 }  }
   
 /*  /*
Line 438  rew_dohalt(enum mdoct tok, enum mdoc_type type,
Line 433  rew_dohalt(enum mdoct tok, enum mdoc_type type,
          * Default block rewinding rules.           * Default block rewinding rules.
          * In particular, always skip block end markers,           * In particular, always skip block end markers,
          * and let all blocks rewind Nm children.           * and let all blocks rewind Nm children.
            * Do not warn again when closing a block,
            * since closing the body already warned.
          */           */
         if (ENDBODY_NOT != p->end || MDOC_Nm == p->tok ||          if (ENDBODY_NOT != p->end || MDOC_Nm == p->tok ||
             (MDOC_BLOCK == p->type &&              MDOC_BLOCK == type || (MDOC_BLOCK == p->type &&
             ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)))              ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)))
                 return(REWIND_MORE);                  return(REWIND_MORE);
   
Line 454  rew_dohalt(enum mdoct tok, enum mdoc_type type,
Line 451  rew_dohalt(enum mdoct tok, enum mdoc_type type,
             REWIND_FORCE : REWIND_LATER);              REWIND_FORCE : REWIND_LATER);
 }  }
   
 static int  static void
 rew_elem(struct mdoc *mdoc, enum mdoct tok)  rew_elem(struct mdoc *mdoc, enum mdoct tok)
 {  {
         struct mdoc_node *n;          struct mdoc_node *n;
Line 464  rew_elem(struct mdoc *mdoc, enum mdoct tok)
Line 461  rew_elem(struct mdoc *mdoc, enum mdoct tok)
                 n = n->parent;                  n = n->parent;
         assert(MDOC_ELEM == n->type);          assert(MDOC_ELEM == n->type);
         assert(tok == n->tok);          assert(tok == n->tok);
           rew_last(mdoc, n);
         return(rew_last(mdoc, n));  
 }  }
   
 /*  /*
Line 586  rew_sub(enum mdoc_type t, struct mdoc *mdoc,
Line 582  rew_sub(enum mdoc_type t, struct mdoc *mdoc,
         }          }
   
         assert(n);          assert(n);
         if ( ! rew_last(mdoc, n))          rew_last(mdoc, n);
                 return(0);  
   
         /*          /*
          * The current block extends an enclosing block.           * The current block extends an enclosing block.
          * Now that the current block ends, close the enclosing block, too.           * Now that the current block ends, close the enclosing block, too.
          */           */
         while (NULL != (n = n->pending)) {          while (NULL != (n = n->pending)) {
                 if ( ! rew_last(mdoc, n))                  rew_last(mdoc, n);
                         return(0);  
                 if (MDOC_HEAD == n->type &&                  if (MDOC_HEAD == n->type &&
                     ! mdoc_body_alloc(mdoc, n->line, n->pos, n->tok))                      ! mdoc_body_alloc(mdoc, n->line, n->pos, n->tok))
                         return(0);                          return(0);
Line 627  dword(struct mdoc *mdoc, int line, int col, const char
Line 621  dword(struct mdoc *mdoc, int line, int col, const char
         if ( ! mdoc_word_alloc(mdoc, line, col, p))          if ( ! mdoc_word_alloc(mdoc, line, col, p))
                 return(0);                  return(0);
   
         if (DELIM_OPEN == d)  
                 mdoc->last->flags |= MDOC_DELIMO;  
   
         /*          /*
          * Closing delimiters only suppress the preceding space           * If the word consists of a bare delimiter,
          * when they follow something, not when they start a new           * flag the new node accordingly,
          * block or element, and not when they follow `No'.           * unless doing so was vetoed by the invoking macro.
          *           * Always clear the veto, it is only valid for one word.
          * XXX  Explicitly special-casing MDOC_No here feels  
          *      like a layering violation.  Find a better way  
          *      and solve this in the code related to `No'!  
          */           */
   
         else if (DELIM_CLOSE == d && mdoc->last->prev &&          if (d == DELIM_OPEN)
             mdoc->last->prev->tok != MDOC_No &&                  mdoc->last->flags |= MDOC_DELIMO;
           else if (d == DELIM_CLOSE &&
               ! (mdoc->flags & MDOC_NODELIMC) &&
             mdoc->last->parent->tok != MDOC_Fd)              mdoc->last->parent->tok != MDOC_Fd)
                 mdoc->last->flags |= MDOC_DELIMC;                  mdoc->last->flags |= MDOC_DELIMC;
   
           mdoc->flags &= ~MDOC_NODELIMC;
   
         return(1);          return(1);
 }  }
   
Line 694  static int
Line 686  static int
 blk_exp_close(MACRO_PROT_ARGS)  blk_exp_close(MACRO_PROT_ARGS)
 {  {
         struct mdoc_node *body;         /* Our own body. */          struct mdoc_node *body;         /* Our own body. */
           struct mdoc_node *endbody;      /* Our own end marker. */
         struct mdoc_node *later;        /* A sub-block starting later. */          struct mdoc_node *later;        /* A sub-block starting later. */
         struct mdoc_node *n;            /* For searching backwards. */          struct mdoc_node *n;            /* For searching backwards. */
   
Line 720  blk_exp_close(MACRO_PROT_ARGS)
Line 713  blk_exp_close(MACRO_PROT_ARGS)
          * both of our own and of pending sub-blocks.           * both of our own and of pending sub-blocks.
          */           */
         atok = rew_alt(tok);          atok = rew_alt(tok);
         body = later = NULL;          body = endbody = later = NULL;
         for (n = mdoc->last; n; n = n->parent) {          for (n = mdoc->last; n; n = n->parent) {
                 if (MDOC_VALID & n->flags)                  if (MDOC_VALID & n->flags)
                         continue;                          continue;
Line 759  blk_exp_close(MACRO_PROT_ARGS)
Line 752  blk_exp_close(MACRO_PROT_ARGS)
                         if ( ! mdoc_endbody_alloc(mdoc, line, ppos,                          if ( ! mdoc_endbody_alloc(mdoc, line, ppos,
                             atok, body, ENDBODY_SPACE))                              atok, body, ENDBODY_SPACE))
                                 return(0);                                  return(0);
                           if (maxargs) {
                                   endbody = mdoc->last;
                                   mdoc->next = MDOC_NEXT_CHILD;
                           }
                         break;                          break;
                 }                  }
   
Line 788  blk_exp_close(MACRO_PROT_ARGS)
Line 785  blk_exp_close(MACRO_PROT_ARGS)
         if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))          if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))
                 return(0);                  return(0);
   
         if (NULL == later && maxargs > 0)          if (maxargs && endbody == NULL) {
                 if ( ! mdoc_tail_alloc(mdoc, line, ppos, rew_alt(tok)))                  if (n == NULL) {
                           /*
                            * Stray .Ec without previous .Eo:
                            * Break the output line, ignore any arguments.
                            */
                           if ( ! mdoc_elem_alloc(mdoc, line, ppos,
                               MDOC_br, NULL))
                                   return(0);
                           rew_elem(mdoc, MDOC_br);
                   } else if ( ! mdoc_tail_alloc(mdoc, line, ppos, atok))
                         return(0);                          return(0);
           }
   
         for (flushed = j = 0; ; j++) {          flushed = n == NULL;
           for (j = 0; ; j++) {
                 lastarg = *pos;                  lastarg = *pos;
   
                 if (j == maxargs && ! flushed) {                  if (j == maxargs && ! flushed) {
                         if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))                          if (endbody != NULL)
                                   rew_last(mdoc, endbody);
                           else if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
                                 return(0);                                  return(0);
                         flushed = 1;                          flushed = 1;
                 }                  }
Line 820  blk_exp_close(MACRO_PROT_ARGS)
Line 830  blk_exp_close(MACRO_PROT_ARGS)
                 }                  }
   
                 if ( ! flushed) {                  if ( ! flushed) {
                         if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))                          if (endbody != NULL)
                                   rew_last(mdoc, endbody);
                           else if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
                                 return(0);                                  return(0);
                         flushed = 1;                          flushed = 1;
                 }                  }
Line 832  blk_exp_close(MACRO_PROT_ARGS)
Line 844  blk_exp_close(MACRO_PROT_ARGS)
                 break;                  break;
         }          }
   
         if ( ! flushed && ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))          if ( ! flushed) {
                 return(0);                  if (endbody != NULL)
                           rew_last(mdoc, endbody);
                   else if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
                           return(0);
           }
   
         if ( ! nl)          if ( ! nl)
                 return(1);                  return(1);
Line 843  blk_exp_close(MACRO_PROT_ARGS)
Line 859  blk_exp_close(MACRO_PROT_ARGS)
 static int  static int
 in_line(MACRO_PROT_ARGS)  in_line(MACRO_PROT_ARGS)
 {  {
         int              la, scope, cnt, nc, nl;          int              la, scope, cnt, firstarg, mayopen, nc, nl;
         enum margverr    av;          enum margverr    av;
         enum mdoct       ntok;          enum mdoct       ntok;
         enum margserr    ac;          enum margserr    ac;
Line 894  in_line(MACRO_PROT_ARGS)
Line 910  in_line(MACRO_PROT_ARGS)
                 return(0);                  return(0);
         }          }
   
           d = DELIM_NONE;
           firstarg = 1;
           mayopen = 1;
         for (cnt = scope = 0;; ) {          for (cnt = scope = 0;; ) {
                 la = *pos;                  la = *pos;
                 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);                  ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
   
                 if (ARGS_ERROR == ac)                  if (ac == ARGS_ERROR)
                         return(0);                          return(0);
                 if (ARGS_EOLN == ac)  
                   /*
                    * At the end of a macro line,
                    * opening delimiters do not suppress spacing.
                    */
   
                   if (ac == ARGS_EOLN) {
                           if (d == DELIM_OPEN)
                                   mdoc->last->flags &= ~MDOC_DELIMO;
                         break;                          break;
                 if (ARGS_PUNCT == ac)                  }
   
                   /*
                    * The rest of the macro line is only punctuation,
                    * to be handled by append_delims().
                    * If there were no other arguments,
                    * do not allow the first one to suppress spacing,
                    * even if it turns out to be a closing one.
                    */
   
                   if (ac == ARGS_PUNCT) {
                           if (cnt == 0 && nc == 0)
                                   mdoc->flags |= MDOC_NODELIMC;
                         break;                          break;
                   }
   
                 ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);                  ntok = (ac == ARGS_QWORD || (tok == MDOC_Fn && !cnt)) ?
                       MDOC_MAX : lookup(tok, p);
   
                 /*                  /*
                  * In this case, we've located a submacro and must                   * In this case, we've located a submacro and must
Line 915  in_line(MACRO_PROT_ARGS)
Line 956  in_line(MACRO_PROT_ARGS)
                  */                   */
   
                 if (MDOC_MAX != ntok) {                  if (MDOC_MAX != ntok) {
                         if (scope && ! rew_elem(mdoc, tok))                          if (scope)
                                 return(0);                                  rew_elem(mdoc, tok);
                         if (nc && 0 == cnt) {                          if (nc && 0 == cnt) {
                                 if ( ! mdoc_elem_alloc(mdoc,                                  if ( ! mdoc_elem_alloc(mdoc,
                                     line, ppos, tok, arg))                                      line, ppos, tok, arg))
                                         return(0);                                          return(0);
                                 if ( ! rew_last(mdoc, mdoc->last))                                  rew_last(mdoc, mdoc->last);
                                         return(0);  
                         } else if ( ! nc && 0 == cnt) {                          } else if ( ! nc && 0 == cnt) {
                                 mdoc_argv_free(arg);                                  mdoc_argv_free(arg);
                                 mandoc_msg(MANDOCERR_MACRO_EMPTY,                                  mandoc_msg(MANDOCERR_MACRO_EMPTY,
Line 948  in_line(MACRO_PROT_ARGS)
Line 988  in_line(MACRO_PROT_ARGS)
                 if (DELIM_NONE != d) {                  if (DELIM_NONE != d) {
                         /*                          /*
                          * If we encounter closing punctuation, no word                           * If we encounter closing punctuation, no word
                          * has been omitted, no scope is open, and we're                           * has been emitted, no scope is open, and we're
                          * allowed to have an empty element, then start                           * allowed to have an empty element, then start
                          * a new scope.  `Ar', `Fl', and `Li', only do                           * a new scope.
                          * this once per invocation.  There may be more  
                          * of these (all of them?).  
                          */                           */
                         if (0 == cnt && (nc || MDOC_Li == tok) &&                          if ((d == DELIM_CLOSE ||
                             DELIM_CLOSE == d && ! scope) {                               (d == DELIM_MIDDLE && tok == MDOC_Fl)) &&
                               !cnt && !scope && nc && mayopen) {
                                 if ( ! mdoc_elem_alloc(mdoc,                                  if ( ! mdoc_elem_alloc(mdoc,
                                     line, ppos, tok, arg))                                      line, ppos, tok, arg))
                                         return(0);                                          return(0);
                                 if (MDOC_Ar == tok || MDOC_Li == tok ||  
                                     MDOC_Fl == tok)  
                                         cnt++;  
                                 scope = 1;                                  scope = 1;
                                   cnt++;
                                   if (MDOC_Nm == tok)
                                           mayopen = 0;
                         }                          }
                         /*                          /*
                          * Close out our scope, if one is open, before                           * Close out our scope, if one is open, before
                          * any punctuation.                           * any punctuation.
                          */                           */
                         if (scope && ! rew_elem(mdoc, tok))                          if (scope)
                                 return(0);                                  rew_elem(mdoc, tok);
                         scope = 0;                          scope = 0;
                 } else if ( ! scope) {                          if (tok == MDOC_Fn)
                                   mayopen = 0;
                   } else if (mayopen && !scope) {
                         if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg))                          if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg))
                                 return(0);                                  return(0);
                         scope = 1;                          scope = 1;
                           cnt++;
                 }                  }
   
                 if (DELIM_NONE == d)  
                         cnt++;  
   
                 if ( ! dword(mdoc, line, la, p, d,                  if ( ! dword(mdoc, line, la, p, d,
                     MDOC_JOIN & mdoc_macros[tok].flags))                      MDOC_JOIN & mdoc_macros[tok].flags))
                         return(0);                          return(0);
   
                 /*                  /*
                    * If the first argument is a closing delimiter,
                    * do not suppress spacing before it.
                    */
   
                   if (firstarg && d == DELIM_CLOSE && !nc)
                           mdoc->last->flags &= ~MDOC_DELIMC;
                   firstarg = 0;
   
                   /*
                  * `Fl' macros have their scope re-opened with each new                   * `Fl' macros have their scope re-opened with each new
                  * word so that the `-' can be added to each one without                   * word so that the `-' can be added to each one without
                  * having to parse out spaces.                   * having to parse out spaces.
                  */                   */
                 if (scope && MDOC_Fl == tok) {                  if (scope && MDOC_Fl == tok) {
                         if ( ! rew_elem(mdoc, tok))                          rew_elem(mdoc, tok);
                                 return(0);  
                         scope = 0;                          scope = 0;
                 }                  }
         }          }
   
         if (scope && ! rew_elem(mdoc, tok))          if (scope)
                 return(0);                  rew_elem(mdoc, tok);
   
         /*          /*
          * If no elements have been collected and we're allowed to have           * If no elements have been collected and we're allowed to have
Line 1008  in_line(MACRO_PROT_ARGS)
Line 1055  in_line(MACRO_PROT_ARGS)
         if (nc && 0 == cnt) {          if (nc && 0 == cnt) {
                 if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg))                  if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg))
                         return(0);                          return(0);
                 if ( ! rew_last(mdoc, mdoc->last))                  rew_last(mdoc, mdoc->last);
                         return(0);  
         } else if ( ! nc && 0 == cnt) {          } else if ( ! nc && 0 == cnt) {
                 mdoc_argv_free(arg);                  mdoc_argv_free(arg);
                 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,                  mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
Line 1041  blk_full(MACRO_PROT_ARGS)
Line 1087  blk_full(MACRO_PROT_ARGS)
   
         if (tok == MDOC_It) {          if (tok == MDOC_It) {
                 for (n = mdoc->last; n; n = n->parent)                  for (n = mdoc->last; n; n = n->parent)
                         if (n->tok == MDOC_Bl)                          if (n->tok == MDOC_Bl &&
                               ! (n->flags & MDOC_VALID))
                                 break;                                  break;
                 if (n == NULL) {                  if (n == NULL) {
                         mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse,                          mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse,
Line 1049  blk_full(MACRO_PROT_ARGS)
Line 1096  blk_full(MACRO_PROT_ARGS)
                         if ( ! mdoc_elem_alloc(mdoc, line, ppos,                          if ( ! mdoc_elem_alloc(mdoc, line, ppos,
                             MDOC_br, NULL))                              MDOC_br, NULL))
                                 return(0);                                  return(0);
                         return(rew_elem(mdoc, MDOC_br));                          rew_elem(mdoc, MDOC_br);
                           return(1);
                 }                  }
         }          }
   
Line 1533  in_line_argn(MACRO_PROT_ARGS)
Line 1581  in_line_argn(MACRO_PROT_ARGS)
         switch (tok) {          switch (tok) {
         case MDOC_Ap:          case MDOC_Ap:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_No:  
                 /* FALLTHROUGH */  
         case MDOC_Ns:          case MDOC_Ns:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_Ux:          case MDOC_Ux:
Line 1592  in_line_argn(MACRO_PROT_ARGS)
Line 1638  in_line_argn(MACRO_PROT_ARGS)
                                return(0);                                 return(0);
   
                 if (j == maxargs && ! flushed) {                  if (j == maxargs && ! flushed) {
                         if ( ! rew_elem(mdoc, tok))                          rew_elem(mdoc, tok);
                                 return(0);  
                         flushed = 1;                          flushed = 1;
                 }                  }
   
                 ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);                  ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
   
                 if (MDOC_MAX != ntok) {                  if (MDOC_MAX != ntok) {
                         if ( ! flushed && ! rew_elem(mdoc, tok))                          if ( ! flushed)
                                 return(0);                                  rew_elem(mdoc, tok);
                         flushed = 1;                          flushed = 1;
                         if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf))                          if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf))
                                 return(0);                                  return(0);
Line 1613  in_line_argn(MACRO_PROT_ARGS)
Line 1658  in_line_argn(MACRO_PROT_ARGS)
                     ARGS_QWORD != ac &&                      ARGS_QWORD != ac &&
                     ! flushed &&                      ! flushed &&
                     DELIM_NONE != mdoc_isdelim(p)) {                      DELIM_NONE != mdoc_isdelim(p)) {
                         if ( ! rew_elem(mdoc, tok))                          rew_elem(mdoc, tok);
                                 return(0);  
                         flushed = 1;                          flushed = 1;
                 }                  }
   
Line 1629  in_line_argn(MACRO_PROT_ARGS)
Line 1673  in_line_argn(MACRO_PROT_ARGS)
   
         /* Close out in a consistent state. */          /* Close out in a consistent state. */
   
         if ( ! flushed && ! rew_elem(mdoc, tok))          if ( ! flushed)
                 return(0);                  rew_elem(mdoc, tok);
         if ( ! nl)          if ( ! nl)
                 return(1);                  return(1);
         return(append_delims(mdoc, line, pos, buf));          return(append_delims(mdoc, line, pos, buf));
Line 1694  in_line_eoln(MACRO_PROT_ARGS)
Line 1738  in_line_eoln(MACRO_PROT_ARGS)
                                 return(0);                                  return(0);
                         continue;                          continue;
                 }                  }
                   rew_elem(mdoc, tok);
                 if ( ! rew_elem(mdoc, tok))  
                         return(0);  
                 return(mdoc_macro(mdoc, ntok, line, la, pos, buf));                  return(mdoc_macro(mdoc, ntok, line, la, pos, buf));
         }          }
   
         /* Close out (no delimiters). */          /* Close out (no delimiters). */
   
         return(rew_elem(mdoc, tok));          rew_elem(mdoc, tok);
           return(1);
 }  }
   
 static int  static int
Line 1785  phrase_ta(MACRO_PROT_ARGS)
Line 1828  phrase_ta(MACRO_PROT_ARGS)
                 n = n->parent;                  n = n->parent;
         if (NULL == n || LIST_column != n->norm->Bl.type) {          if (NULL == n || LIST_column != n->norm->Bl.type) {
                 mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse,                  mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse,
                     line, ppos, NULL);                      line, ppos, "Ta");
                 return(1);                  return(1);
         }          }
   

Legend:
Removed from v.1.138  
changed lines
  Added in v.1.149

CVSweb