[BACK]Return to mdoc_man.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/mdoc_man.c between version 1.34 and 1.35

version 1.34, 2012/07/13 14:15:50 version 1.35, 2012/07/13 20:42:59
Line 250 
Line 250 
 #define MMAN_An_split   (1 << 8)  /* author mode is "split" */  #define MMAN_An_split   (1 << 8)  /* author mode is "split" */
 #define MMAN_An_nosplit (1 << 9)  /* author mode is "nosplit" */  #define MMAN_An_nosplit (1 << 9)  /* author mode is "nosplit" */
   
   static  int             TPremain;  /* characters before tag is full */
   
 static  struct {  static  struct {
         char    *head;          char    *head;
         char    *tail;          char    *tail;
Line 266 
Line 268 
                                 fontqueue.size);                                  fontqueue.size);
         }          }
         *fontqueue.tail = newfont;          *fontqueue.tail = newfont;
         print_word("\\f");          print_word("");
           printf("\\f");
         putchar(newfont);          putchar(newfont);
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
 }  }
Line 278 
Line 281 
         if (fontqueue.tail > fontqueue.head)          if (fontqueue.tail > fontqueue.head)
                 fontqueue.tail--;                  fontqueue.tail--;
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("\\f");          print_word("");
           printf("\\f");
         putchar(*fontqueue.tail);          putchar(*fontqueue.tail);
 }  }
   
Line 301 
Line 305 
                 else if (MMAN_nl & outflags)                  else if (MMAN_nl & outflags)
                         putchar('\n');                          putchar('\n');
                 outflags &= ~(MMAN_PP|MMAN_sp|MMAN_br|MMAN_nl|MMAN_spc);                  outflags &= ~(MMAN_PP|MMAN_sp|MMAN_br|MMAN_nl|MMAN_spc);
         } else if (MMAN_spc & outflags && '\0' != s[0])                  if (1 == TPremain)
                           printf(".br\n");
                   TPremain = 0;
           } else if (MMAN_spc & outflags) {
                 /*                  /*
                  * If we need a space, only print it if                   * If we need a space, only print it if
                  * (1) it is forced by `No' or                   * (1) it is forced by `No' or
                  * (2) what follows is not terminating punctuation or                   * (2) what follows is not terminating punctuation or
                  * (3) what follows is longer than one character.                   * (3) what follows is longer than one character.
                  */                   */
                 if (MMAN_spc_force & outflags ||                  if (MMAN_spc_force & outflags || '\0' == s[0] ||
                     NULL == strchr(".,:;)]?!", s[0]) || '\0' != s[1]) {                      NULL == strchr(".,:;)]?!", s[0]) || '\0' != s[1]) {
                         if (MMAN_Bk & outflags) {                          if (MMAN_Bk & outflags) {
                                 putchar('\\');                                  putchar('\\');
                                 putchar('~');                                  putchar('~');
                         } else                          } else
                                 putchar(' ');                                  putchar(' ');
                           if (TPremain)
                                   TPremain--;
                 }                  }
           }
   
         /*          /*
          * Reassign needing space if we're not following opening           * Reassign needing space if we're not following opening
          * punctuation.           * punctuation.
          */           */
         if (MMAN_Sm & outflags &&          if (MMAN_Sm & outflags && ('\0' == s[0] ||
             (('(' != s[0] && '[' != s[0]) || '\0' != s[1]))              (('(' != s[0] && '[' != s[0]) || '\0' != s[1])))
                 outflags |= MMAN_spc;                  outflags |= MMAN_spc;
         else          else
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
Line 340 
Line 350 
                         putchar((unsigned char)*s);                          putchar((unsigned char)*s);
                         break;                          break;
                 }                  }
                   if (TPremain)
                           TPremain--;
         }          }
 }  }
   
Line 396 
Line 408 
         char              buf[24];          char              buf[24];
         struct roffsu     su;          struct roffsu     su;
         size_t            sz, chsz;          size_t            sz, chsz;
           int               numeric, remain;
   
         /* XXX Rough estimation, might have multiple parts. */          numeric = 1;
         chsz = (NULL != child && MDOC_TEXT == child->type) ?          remain = 0;
                         strlen(child->string) : 0;  
   
         if (NULL == v)          if (NULL == v)
                 sz = defsz;                  sz = defsz;
         else if (a2roffsu(v, &su, SCALE_MAX)) {          else if (a2roffsu(v, &su, SCALE_MAX)) {
                 if (SCALE_EN == su.unit)                  if (SCALE_EN == su.unit)
                         sz = su.scale;                          sz = su.scale;
                 else {                  else {
                         if (chsz)                          sz = 0;
                                 print_block(".HP", 0);                          numeric = 0;
                         else  
                                 print_block(".TP", 0);  
                         print_word(v);  
                         return;  
                 }                  }
         } else          } else
                 sz = strlen(v);                  sz = strlen(v);
   
         if (chsz > sz)          /* XXX Rough estimation, might have multiple parts. */
           chsz = (NULL != child && MDOC_TEXT == child->type) ?
                           strlen(child->string) : 0;
   
           if (defsz && chsz > sz)
                 print_block(".HP", 0);                  print_block(".HP", 0);
         else          else {
                 print_block(".TP", 0);                  print_block(".TP", 0);
         snprintf(buf, sizeof(buf), "%ldn", sz + 2);                  remain = sz + 2;
         print_word(buf);          }
           if (numeric) {
                   snprintf(buf, sizeof(buf), "%ldn", sz + 2);
                   print_word(buf);
           } else
                   print_word(v);
           TPremain = remain;
 }  }
   
 void  void
Line 495 
Line 512 
                  */                   */
                 if (MMAN_nl & outflags && ('.' == *n->string ||                  if (MMAN_nl & outflags && ('.' == *n->string ||
                                         '\'' == *n->string)) {                                          '\'' == *n->string)) {
                         print_word("\\&");                          print_word("");
                           printf("\\&");
                         outflags &= ~MMAN_spc;                          outflags &= ~MMAN_spc;
                 }                  }
                 print_word(n->string);                  print_word(n->string);
Line 595 
Line 613 
   
         if (n->parent && MDOC_Rs == n->parent->tok &&          if (n->parent && MDOC_Rs == n->parent->tok &&
                         n->parent->norm->Rs.quote_T) {                          n->parent->norm->Rs.quote_T) {
                 print_word("\"");                  print_word("");
                   putchar('\"');
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
         } else          } else
                 font_push('I');                  font_push('I');
Line 609 
Line 628 
         if (n->parent && MDOC_Rs == n->parent->tok &&          if (n->parent && MDOC_Rs == n->parent->tok &&
                         n->parent->norm->Rs.quote_T) {                          n->parent->norm->Rs.quote_T) {
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
                 print_word("\"");                  print_word("");
                   putchar('\"');
         } else          } else
                 font_pop();                  font_pop();
         post_percent(m, n);          post_percent(m, n);
Line 626 
Line 646 
                 return(1);                  return(1);
         outflags |= MMAN_sp;          outflags |= MMAN_sp;
         print_block(manacts[n->tok].prefix, 0);          print_block(manacts[n->tok].prefix, 0);
         print_word("\"");          print_word("");
           putchar('\"');
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(1);          return(1);
 }  }
Line 641 
Line 662 
         if (MDOC_HEAD != n->type)          if (MDOC_HEAD != n->type)
                 return;                  return;
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("\"");          print_word("");
           putchar('\"');
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
         if (MDOC_Sh == n->tok && SEC_AUTHORS == n->sec)          if (MDOC_Sh == n->tok && SEC_AUTHORS == n->sec)
                 outflags &= ~(MMAN_An_split | MMAN_An_nosplit);                  outflags &= ~(MMAN_An_split | MMAN_An_nosplit);
Line 1113 
Line 1135 
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (LIST_hyphen):                  case (LIST_hyphen):
                         print_width(bln->norm->Bl.width, NULL, 0);                          print_width(bln->norm->Bl.width, NULL, 0);
                           TPremain = 0;
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         font_push('B');                          font_push('B');
                         if (LIST_bullet == bln->norm->Bl.type)                          if (LIST_bullet == bln->norm->Bl.type)
Line 1123 
Line 1146 
                         break;                          break;
                 case (LIST_enum):                  case (LIST_enum):
                         print_width(bln->norm->Bl.width, NULL, 0);                          print_width(bln->norm->Bl.width, NULL, 0);
                           TPremain = 0;
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         print_count(&bln->norm->Bl.count);                          print_count(&bln->norm->Bl.count);
                         break;                          break;
                 case (LIST_hang):                  case (LIST_hang):
                         print_width(bln->norm->Bl.width, n->child, 6);                          print_width(bln->norm->Bl.width, n->child, 6);
                           TPremain = 0;
                         break;                          break;
                 case (LIST_tag):                  case (LIST_tag):
                         print_width(bln->norm->Bl.width, NULL, 8);                          print_width(bln->norm->Bl.width, n->child, 0);
                         break;                          putchar('\n');
                           outflags &= ~MMAN_spc;
                           return(1);
                 default:                  default:
                         return(1);                          return(1);
                 }                  }

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35