[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.143 and 1.144

version 1.143, 2014/09/07 00:05:28 version 1.144, 2014/11/17 06:44:58
Line 147  const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
Line 147  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 627  dword(struct mdoc *mdoc, int line, int col, const char
Line 626  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 843  blk_exp_close(MACRO_PROT_ARGS)
Line 840  blk_exp_close(MACRO_PROT_ARGS)
 static int  static int
 in_line(MACRO_PROT_ARGS)  in_line(MACRO_PROT_ARGS)
 {  {
         int              la, scope, cnt, mayopen, 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 891  in_line(MACRO_PROT_ARGS)
                 return(0);                  return(0);
         }          }
   
           d = DELIM_NONE;
           firstarg = 1;
         mayopen = 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 = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
   
Line 949  in_line(MACRO_PROT_ARGS)
Line 969  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.                           * a new scope.
                          */                           */
                         if ((d == DELIM_CLOSE ||                          if ((d == DELIM_CLOSE ||
                              (d == DELIM_MIDDLE && tok == MDOC_Fl)) &&                               (d == DELIM_MIDDLE && tok == MDOC_Fl)) &&
                             (nc || tok == MDOC_Li) &&                              !cnt && !scope && nc && mayopen) {
                             !scope && !cnt && mayopen) {  
                                 if ( ! mdoc_elem_alloc(mdoc,                                  if ( ! mdoc_elem_alloc(mdoc,
                                     line, ppos, tok, arg))                                      line, ppos, tok, arg))
                                         return(0);                                          return(0);
                                 scope = 1;                                  scope = 1;
                                 cnt++;                                  cnt++;
                                 if (MDOC_Li == tok || MDOC_Nm == tok)                                  if (MDOC_Nm == tok)
                                         mayopen = 0;                                          mayopen = 0;
                         }                          }
                         /*                          /*
Line 984  in_line(MACRO_PROT_ARGS)
Line 1003  in_line(MACRO_PROT_ARGS)
                         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.
Line 1532  in_line_argn(MACRO_PROT_ARGS)
Line 1560  in_line_argn(MACRO_PROT_ARGS)
   
         switch (tok) {          switch (tok) {
         case MDOC_Ap:          case MDOC_Ap:
                 /* FALLTHROUGH */  
         case MDOC_No:  
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case MDOC_Ns:          case MDOC_Ns:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */

Legend:
Removed from v.1.143  
changed lines
  Added in v.1.144

CVSweb