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

Diff for /mandoc/mdoc_term.c between version 1.263 and 1.264

version 1.263, 2014/04/08 07:13:12 version 1.264, 2014/04/20 16:46:05
Line 42  struct termpair {
Line 42  struct termpair {
   
 #define DECL_ARGS struct termp *p, \  #define DECL_ARGS struct termp *p, \
                   struct termpair *pair, \                    struct termpair *pair, \
                   const struct mdoc_meta *meta, \                    const struct mdoc_meta *meta, \
                   struct mdoc_node *n                    struct mdoc_node *n
   
 struct  termact {  struct  termact {
Line 57  static size_t   a2offs(const struct termp *, const cha
Line 57  static size_t   a2offs(const struct termp *, const cha
 static  void      print_bvspace(struct termp *,  static  void      print_bvspace(struct termp *,
                         const struct mdoc_node *,                          const struct mdoc_node *,
                         const struct mdoc_node *);                          const struct mdoc_node *);
 static  void      print_mdoc_node(DECL_ARGS);  static  void      print_mdoc_node(DECL_ARGS);
 static  void      print_mdoc_nodelist(DECL_ARGS);  static  void      print_mdoc_nodelist(DECL_ARGS);
 static  void      print_mdoc_head(struct termp *, const void *);  static  void      print_mdoc_head(struct termp *, const void *);
 static  void      print_mdoc_foot(struct termp *, const void *);  static  void      print_mdoc_foot(struct termp *, const void *);
 static  void      synopsis_pre(struct termp *,  static  void      synopsis_pre(struct termp *,
                         const struct mdoc_node *);                          const struct mdoc_node *);
   
 static  void      termp____post(DECL_ARGS);  static  void      termp____post(DECL_ARGS);
Line 128  static const struct termact termacts[MDOC_MAX] = {
Line 128  static const struct termact termacts[MDOC_MAX] = {
         { NULL, NULL }, /* Dt */          { NULL, NULL }, /* Dt */
         { NULL, NULL }, /* Os */          { NULL, NULL }, /* Os */
         { termp_sh_pre, termp_sh_post }, /* Sh */          { termp_sh_pre, termp_sh_post }, /* Sh */
         { termp_ss_pre, termp_ss_post }, /* Ss */          { termp_ss_pre, termp_ss_post }, /* Ss */
         { termp_sp_pre, NULL }, /* Pp */          { termp_sp_pre, NULL }, /* Pp */
         { termp_d1_pre, termp_bl_post }, /* D1 */          { termp_d1_pre, termp_bl_post }, /* D1 */
         { termp_d1_pre, termp_bl_post }, /* Dl */          { termp_d1_pre, termp_bl_post }, /* Dl */
         { termp_bd_pre, termp_bd_post }, /* Bd */          { termp_bd_pre, termp_bd_post }, /* Bd */
Line 137  static const struct termact termacts[MDOC_MAX] = {
Line 137  static const struct termact termacts[MDOC_MAX] = {
         { termp_bl_pre, termp_bl_post }, /* Bl */          { termp_bl_pre, termp_bl_post }, /* Bl */
         { NULL, NULL }, /* El */          { NULL, NULL }, /* El */
         { termp_it_pre, termp_it_post }, /* It */          { termp_it_pre, termp_it_post }, /* It */
         { termp_under_pre, NULL }, /* Ad */          { termp_under_pre, NULL }, /* Ad */
         { termp_an_pre, termp_an_post }, /* An */          { termp_an_pre, termp_an_post }, /* An */
         { termp_under_pre, NULL }, /* Ar */          { termp_under_pre, NULL }, /* Ar */
         { termp_cd_pre, NULL }, /* Cd */          { termp_cd_pre, NULL }, /* Cd */
         { termp_bold_pre, NULL }, /* Cm */          { termp_bold_pre, NULL }, /* Cm */
         { NULL, NULL }, /* Dv */          { NULL, NULL }, /* Dv */
         { NULL, NULL }, /* Er */          { NULL, NULL }, /* Er */
         { NULL, NULL }, /* Ev */          { NULL, NULL }, /* Ev */
         { termp_ex_pre, NULL }, /* Ex */          { termp_ex_pre, NULL }, /* Ex */
         { termp_fa_pre, NULL }, /* Fa */          { termp_fa_pre, NULL }, /* Fa */
         { termp_fd_pre, termp_fd_post }, /* Fd */          { termp_fd_pre, termp_fd_post }, /* Fd */
         { termp_fl_pre, NULL }, /* Fl */          { termp_fl_pre, NULL }, /* Fl */
         { termp_fn_pre, NULL }, /* Fn */          { termp_fn_pre, NULL }, /* Fn */
         { termp_ft_pre, NULL }, /* Ft */          { termp_ft_pre, NULL }, /* Ft */
         { termp_bold_pre, NULL }, /* Ic */          { termp_bold_pre, NULL }, /* Ic */
         { termp_in_pre, termp_in_post }, /* In */          { termp_in_pre, termp_in_post }, /* In */
         { termp_li_pre, NULL }, /* Li */          { termp_li_pre, NULL }, /* Li */
         { termp_nd_pre, NULL }, /* Nd */          { termp_nd_pre, NULL }, /* Nd */
         { termp_nm_pre, termp_nm_post }, /* Nm */          { termp_nm_pre, termp_nm_post }, /* Nm */
         { termp_quote_pre, termp_quote_post }, /* Op */          { termp_quote_pre, termp_quote_post }, /* Op */
         { NULL, NULL }, /* Ot */          { NULL, NULL }, /* Ot */
         { termp_under_pre, NULL }, /* Pa */          { termp_under_pre, NULL }, /* Pa */
         { termp_rv_pre, NULL }, /* Rv */          { termp_rv_pre, NULL }, /* Rv */
         { NULL, NULL }, /* St */          { NULL, NULL }, /* St */
         { termp_under_pre, NULL }, /* Va */          { termp_under_pre, NULL }, /* Va */
         { termp_vt_pre, NULL }, /* Vt */          { termp_vt_pre, NULL }, /* Vt */
         { termp_xr_pre, NULL }, /* Xr */          { termp_xr_pre, NULL }, /* Xr */
Line 180  static const struct termact termacts[MDOC_MAX] = {
Line 180  static const struct termact termacts[MDOC_MAX] = {
         { termp_quote_pre, termp_quote_post }, /* Aq */          { termp_quote_pre, termp_quote_post }, /* Aq */
         { NULL, NULL }, /* At */          { NULL, NULL }, /* At */
         { NULL, NULL }, /* Bc */          { NULL, NULL }, /* Bc */
         { termp_bf_pre, NULL }, /* Bf */          { termp_bf_pre, NULL }, /* Bf */
         { termp_quote_pre, termp_quote_post }, /* Bo */          { termp_quote_pre, termp_quote_post }, /* Bo */
         { termp_quote_pre, termp_quote_post }, /* Bq */          { termp_quote_pre, termp_quote_post }, /* Bq */
         { termp_xx_pre, NULL }, /* Bsx */          { termp_xx_pre, NULL }, /* Bsx */
Line 191  static const struct termact termacts[MDOC_MAX] = {
Line 191  static const struct termact termacts[MDOC_MAX] = {
         { termp_quote_pre, termp_quote_post }, /* Dq */          { termp_quote_pre, termp_quote_post }, /* Dq */
         { NULL, NULL }, /* Ec */ /* FIXME: no space */          { NULL, NULL }, /* Ec */ /* FIXME: no space */
         { NULL, NULL }, /* Ef */          { NULL, NULL }, /* Ef */
         { termp_under_pre, NULL }, /* Em */          { termp_under_pre, NULL }, /* Em */
         { termp_quote_pre, termp_quote_post }, /* Eo */          { termp_quote_pre, termp_quote_post }, /* Eo */
         { termp_xx_pre, NULL }, /* Fx */          { termp_xx_pre, NULL }, /* Fx */
         { termp_bold_pre, NULL }, /* Ms */          { termp_bold_pre, NULL }, /* Ms */
Line 219  static const struct termact termacts[MDOC_MAX] = {
Line 219  static const struct termact termacts[MDOC_MAX] = {
         { termp_xx_pre, NULL }, /* Ux */          { termp_xx_pre, NULL }, /* Ux */
         { NULL, NULL }, /* Xc */          { NULL, NULL }, /* Xc */
         { NULL, NULL }, /* Xo */          { NULL, NULL }, /* Xo */
         { termp_fo_pre, termp_fo_post }, /* Fo */          { termp_fo_pre, termp_fo_post }, /* Fo */
         { NULL, NULL }, /* Fc */          { NULL, NULL }, /* Fc */
         { termp_quote_pre, termp_quote_post }, /* Oo */          { termp_quote_pre, termp_quote_post }, /* Oo */
         { NULL, NULL }, /* Oc */          { NULL, NULL }, /* Oc */
         { termp_bk_pre, termp_bk_post }, /* Bk */          { termp_bk_pre, termp_bk_post }, /* Bk */
Line 230  static const struct termact termacts[MDOC_MAX] = {
Line 230  static const struct termact termacts[MDOC_MAX] = {
         { NULL, NULL }, /* Fr */          { NULL, NULL }, /* Fr */
         { termp_ud_pre, NULL }, /* Ud */          { termp_ud_pre, NULL }, /* Ud */
         { NULL, termp_lb_post }, /* Lb */          { NULL, termp_lb_post }, /* Lb */
         { termp_sp_pre, NULL }, /* Lp */          { termp_sp_pre, NULL }, /* Lp */
         { termp_lk_pre, NULL }, /* Lk */          { termp_lk_pre, NULL }, /* Lk */
         { termp_under_pre, NULL }, /* Mt */          { termp_under_pre, NULL }, /* Mt */
         { termp_quote_pre, termp_quote_post }, /* Brq */          { termp_quote_pre, termp_quote_post }, /* Brq */
         { termp_quote_pre, termp_quote_post }, /* Bro */          { termp_quote_pre, termp_quote_post }, /* Bro */
         { NULL, NULL }, /* Brc */          { NULL, NULL }, /* Brc */
         { NULL, termp____post }, /* %C */          { NULL, termp____post }, /* %C */
         { NULL, NULL }, /* Es */ /* TODO */          { NULL, NULL }, /* Es */ /* TODO */
         { NULL, NULL }, /* En */ /* TODO */          { NULL, NULL }, /* En */ /* TODO */
         { termp_xx_pre, NULL }, /* Dx */          { termp_xx_pre, NULL }, /* Dx */
         { NULL, termp____post }, /* %Q */          { NULL, termp____post }, /* %Q */
         { termp_sp_pre, NULL }, /* br */          { termp_sp_pre, NULL }, /* br */
         { termp_sp_pre, NULL }, /* sp */          { termp_sp_pre, NULL }, /* sp */
         { NULL, termp____post }, /* %U */          { NULL, termp____post }, /* %U */
         { NULL, NULL }, /* Ta */          { NULL, NULL }, /* Ta */
         { termp_ll_pre, NULL }, /* ll */          { termp_ll_pre, NULL }, /* ll */
 };  };
   
Line 279  terminal_mdoc(void *arg, const struct mdoc *mdoc)
Line 279  terminal_mdoc(void *arg, const struct mdoc *mdoc)
         term_end(p);          term_end(p);
 }  }
   
   
 static void  static void
 print_mdoc_nodelist(DECL_ARGS)  print_mdoc_nodelist(DECL_ARGS)
 {  {
Line 289  print_mdoc_nodelist(DECL_ARGS)
Line 288  print_mdoc_nodelist(DECL_ARGS)
                 print_mdoc_nodelist(p, pair, meta, n->next);                  print_mdoc_nodelist(p, pair, meta, n->next);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 print_mdoc_node(DECL_ARGS)  print_mdoc_node(DECL_ARGS)
 {  {
Line 325  print_mdoc_node(DECL_ARGS)
Line 322  print_mdoc_node(DECL_ARGS)
          */           */
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_TEXT):          case MDOC_TEXT:
                 if (' ' == *n->string && MDOC_LINE & n->flags)                  if (' ' == *n->string && MDOC_LINE & n->flags)
                         term_newln(p);                          term_newln(p);
                 if (MDOC_DELIMC & n->flags)                  if (MDOC_DELIMC & n->flags)
Line 334  print_mdoc_node(DECL_ARGS)
Line 331  print_mdoc_node(DECL_ARGS)
                 if (MDOC_DELIMO & n->flags)                  if (MDOC_DELIMO & n->flags)
                         p->flags |= TERMP_NOSPACE;                          p->flags |= TERMP_NOSPACE;
                 break;                  break;
         case (MDOC_EQN):          case MDOC_EQN:
                 term_eqn(p, n->eqn);                  term_eqn(p, n->eqn);
                 break;                  break;
         case (MDOC_TBL):          case MDOC_TBL:
                 term_tbl(p, n->span);                  term_tbl(p, n->span);
                 break;                  break;
         default:          default:
Line 354  print_mdoc_node(DECL_ARGS)
Line 351  print_mdoc_node(DECL_ARGS)
             (ENDBODY_NOT == n->end ? n : n->pending)->prev_font);              (ENDBODY_NOT == n->end ? n : n->pending)->prev_font);
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_TEXT):          case MDOC_TEXT:
                 break;                  break;
         case (MDOC_TBL):          case MDOC_TBL:
                 break;                  break;
         case (MDOC_EQN):          case MDOC_EQN:
                 break;                  break;
         default:          default:
                 if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)                  if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
Line 392  print_mdoc_node(DECL_ARGS)
Line 389  print_mdoc_node(DECL_ARGS)
         }          }
 }  }
   
   
 static void  static void
 print_mdoc_foot(struct termp *p, const void *arg)  print_mdoc_foot(struct termp *p, const void *arg)
 {  {
Line 402  print_mdoc_foot(struct termp *p, const void *arg)
Line 398  print_mdoc_foot(struct termp *p, const void *arg)
   
         term_fontrepl(p, TERMFONT_NONE);          term_fontrepl(p, TERMFONT_NONE);
   
         /*          /*
          * Output the footer in new-groff style, that is, three columns           * Output the footer in new-groff style, that is, three columns
          * with the middle being the manual date and flanking columns           * with the middle being the manual date and flanking columns
          * being the operating system:           * being the operating system:
Line 413  print_mdoc_foot(struct termp *p, const void *arg)
Line 409  print_mdoc_foot(struct termp *p, const void *arg)
         term_vspace(p);          term_vspace(p);
   
         p->offset = 0;          p->offset = 0;
         p->rmargin = (p->maxrmargin -          p->rmargin = (p->maxrmargin -
                         term_strlen(p, meta->date) + term_len(p, 1)) / 2;              term_strlen(p, meta->date) + term_len(p, 1)) / 2;
         p->trailspace = 1;          p->trailspace = 1;
         p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;          p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
   
Line 442  print_mdoc_foot(struct termp *p, const void *arg)
Line 438  print_mdoc_foot(struct termp *p, const void *arg)
         p->flags = 0;          p->flags = 0;
 }  }
   
   
 static void  static void
 print_mdoc_head(struct termp *p, const void *arg)  print_mdoc_head(struct termp *p, const void *arg)
 {  {
Line 515  print_mdoc_head(struct termp *p, const void *arg)
Line 510  print_mdoc_head(struct termp *p, const void *arg)
         p->rmargin = p->maxrmargin;          p->rmargin = p->maxrmargin;
 }  }
   
   
 static size_t  static size_t
 a2height(const struct termp *p, const char *v)  a2height(const struct termp *p, const char *v)
 {  {
Line 529  a2height(const struct termp *p, const char *v)
Line 523  a2height(const struct termp *p, const char *v)
         return(term_vspan(p, &su));          return(term_vspan(p, &su));
 }  }
   
   
 static size_t  static size_t
 a2width(const struct termp *p, const char *v)  a2width(const struct termp *p, const char *v)
 {  {
Line 542  a2width(const struct termp *p, const char *v)
Line 535  a2width(const struct termp *p, const char *v)
         return(term_hspan(p, &su));          return(term_hspan(p, &su));
 }  }
   
   
 static size_t  static size_t
 a2offs(const struct termp *p, const char *v)  a2offs(const struct termp *p, const char *v)
 {  {
Line 562  a2offs(const struct termp *p, const char *v)
Line 554  a2offs(const struct termp *p, const char *v)
         return(term_hspan(p, &su));          return(term_hspan(p, &su));
 }  }
   
   
 /*  /*
  * Determine how much space to print out before block elements of `It'   * Determine how much space to print out before block elements of `It'
  * (and thus `Bl') and `Bd'.  And then go ahead and print that space,   * (and thus `Bl') and `Bd'.  And then go ahead and print that space,
  * too.   * too.
  */   */
 static void  static void
 print_bvspace(struct termp *p,  print_bvspace(struct termp *p,
                 const struct mdoc_node *bl,          const struct mdoc_node *bl,
                 const struct mdoc_node *n)          const struct mdoc_node *n)
 {  {
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
Line 617  print_bvspace(struct termp *p, 
Line 608  print_bvspace(struct termp *p, 
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ll_pre(DECL_ARGS)  termp_ll_pre(DECL_ARGS)
 {  {
Line 626  termp_ll_pre(DECL_ARGS)
Line 616  termp_ll_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_it_pre(DECL_ARGS)  termp_it_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *bl, *nn;          const struct mdoc_node *bl, *nn;
         char                    buf[7];          char                    buf[7];
         int                     i;          int                     i;
         size_t                  width, offset, ncols, dcol;          size_t                  width, offset, ncols, dcol;
         enum mdoc_list          type;          enum mdoc_list          type;
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
Line 645  termp_it_pre(DECL_ARGS)
Line 633  termp_it_pre(DECL_ARGS)
         bl = n->parent->parent->parent;          bl = n->parent->parent->parent;
         type = bl->norm->Bl.type;          type = bl->norm->Bl.type;
   
         /*          /*
          * First calculate width and offset.  This is pretty easy unless           * First calculate width and offset.  This is pretty easy unless
          * we're a -column list, in which case all prior columns must           * we're a -column list, in which case all prior columns must
          * be accounted for.           * be accounted for.
Line 657  termp_it_pre(DECL_ARGS)
Line 645  termp_it_pre(DECL_ARGS)
                 offset = a2offs(p, bl->norm->Bl.offs);                  offset = a2offs(p, bl->norm->Bl.offs);
   
         switch (type) {          switch (type) {
         case (LIST_column):          case LIST_column:
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         break;                          break;
   
Line 671  termp_it_pre(DECL_ARGS)
Line 659  termp_it_pre(DECL_ARGS)
                  * - For more than 5 columns, add only one column.                   * - For more than 5 columns, add only one column.
                  */                   */
                 ncols = bl->norm->Bl.ncols;                  ncols = bl->norm->Bl.ncols;
                   dcol = ncols < 5 ? term_len(p, 4) :
                       ncols == 5 ? term_len(p, 3) : term_len(p, 1);
   
                 /* LINTED */  
                 dcol = ncols < 5 ? term_len(p, 4) :  
                         ncols == 5 ? term_len(p, 3) : term_len(p, 1);  
   
                 /*                  /*
                  * Calculate the offset by applying all prior MDOC_BODY,                   * Calculate the offset by applying all prior MDOC_BODY,
                  * so we stop at the MDOC_HEAD (NULL == nn->prev).                   * so we stop at the MDOC_HEAD (NULL == nn->prev).
                  */                   */
   
                 for (i = 0, nn = n->prev;                  for (i = 0, nn = n->prev;
                                 nn->prev && i < (int)ncols;                      nn->prev && i < (int)ncols;
                                 nn = nn->prev, i++)                      nn = nn->prev, i++)
                         offset += dcol + a2width                          offset += dcol + a2width(p,
                                 (p, bl->norm->Bl.cols[i]);                              bl->norm->Bl.cols[i]);
   
                 /*                  /*
                  * When exceeding the declared number of columns, leave                   * When exceeding the declared number of columns, leave
Line 706  termp_it_pre(DECL_ARGS)
Line 692  termp_it_pre(DECL_ARGS)
                 if (NULL == bl->norm->Bl.width)                  if (NULL == bl->norm->Bl.width)
                         break;                          break;
   
                 /*                  /*
                  * Note: buffer the width by 2, which is groff's magic                   * Note: buffer the width by 2, which is groff's magic
                  * number for buffering single arguments.  See the above                   * number for buffering single arguments.  See the above
                  * handling for column for how this changes.                   * handling for column for how this changes.
Line 716  termp_it_pre(DECL_ARGS)
Line 702  termp_it_pre(DECL_ARGS)
                 break;                  break;
         }          }
   
         /*          /*
          * List-type can override the width in the case of fixed-head           * List-type can override the width in the case of fixed-head
          * values (bullet, dash/hyphen, enum).  Tags need a non-zero           * values (bullet, dash/hyphen, enum).  Tags need a non-zero
          * offset.           * offset.
          */           */
   
         switch (type) {          switch (type) {
         case (LIST_bullet):          case LIST_bullet:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_dash):          case LIST_dash:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_hyphen):          case LIST_hyphen:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_enum):          case LIST_enum:
                 if (width < term_len(p, 2))                  if (width < term_len(p, 2))
                         width = term_len(p, 2);                          width = term_len(p, 2);
                 break;                  break;
         case (LIST_hang):          case LIST_hang:
                 if (0 == width)                  if (0 == width)
                         width = term_len(p, 8);                          width = term_len(p, 8);
                 break;                  break;
         case (LIST_column):          case LIST_column:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_tag):          case LIST_tag:
                 if (0 == width)                  if (0 == width)
                         width = term_len(p, 10);                          width = term_len(p, 10);
                 break;                  break;
Line 747  termp_it_pre(DECL_ARGS)
Line 733  termp_it_pre(DECL_ARGS)
                 break;                  break;
         }          }
   
         /*          /*
          * Whitespace control.  Inset bodies need an initial space,           * Whitespace control.  Inset bodies need an initial space,
          * while diagonal bodies need two.           * while diagonal bodies need two.
          */           */
Line 755  termp_it_pre(DECL_ARGS)
Line 741  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (LIST_diag):          case LIST_diag:
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ \\ ");                          term_word(p, "\\ \\ ");
                 break;                  break;
         case (LIST_inset):          case LIST_inset:
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ ");                          term_word(p, "\\ ");
                 break;                  break;
         default:          default:
Line 770  termp_it_pre(DECL_ARGS)
Line 756  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (LIST_diag):          case LIST_diag:
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                 break;                  break;
Line 786  termp_it_pre(DECL_ARGS)
Line 772  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (LIST_enum):          case LIST_enum:
                 /*                  /*
                  * Weird special case.                   * Weird special case.
                  * Very narrow enum lists actually hang.                   * Very narrow enum lists actually hang.
Line 794  termp_it_pre(DECL_ARGS)
Line 780  termp_it_pre(DECL_ARGS)
                 if (width == term_len(p, 2))                  if (width == term_len(p, 2))
                         p->flags |= TERMP_HANG;                          p->flags |= TERMP_HANG;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_bullet):          case LIST_bullet:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_dash):          case LIST_dash:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_hyphen):          case LIST_hyphen:
                 if (MDOC_HEAD != n->type)                  if (MDOC_HEAD != n->type)
                         break;                          break;
                 p->flags |= TERMP_NOBREAK;                  p->flags |= TERMP_NOBREAK;
                 p->trailspace = 1;                  p->trailspace = 1;
                 break;                  break;
         case (LIST_hang):          case LIST_hang:
                 if (MDOC_HEAD != n->type)                  if (MDOC_HEAD != n->type)
                         break;                          break;
   
Line 814  termp_it_pre(DECL_ARGS)
Line 800  termp_it_pre(DECL_ARGS)
                  * the "overstep" effect in term_flushln() and treat                   * the "overstep" effect in term_flushln() and treat
                  * this as a `-ohang' list instead.                   * this as a `-ohang' list instead.
                  */                   */
                 if (n->next->child &&                  if (n->next->child &&
                                 (MDOC_Bl == n->next->child->tok ||                      (MDOC_Bl == n->next->child->tok ||
                                  MDOC_Bd == n->next->child->tok))                       MDOC_Bd == n->next->child->tok))
                         break;                          break;
   
                 p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;                  p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
                 p->trailspace = 1;                  p->trailspace = 1;
                 break;                  break;
         case (LIST_tag):          case LIST_tag:
                 if (MDOC_HEAD != n->type)                  if (MDOC_HEAD != n->type)
                         break;                          break;
   
Line 832  termp_it_pre(DECL_ARGS)
Line 818  termp_it_pre(DECL_ARGS)
                 if (NULL == n->next || NULL == n->next->child)                  if (NULL == n->next || NULL == n->next->child)
                         p->flags |= TERMP_DANGLE;                          p->flags |= TERMP_DANGLE;
                 break;                  break;
         case (LIST_column):          case LIST_column:
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         break;                          break;
   
Line 845  termp_it_pre(DECL_ARGS)
Line 831  termp_it_pre(DECL_ARGS)
                 }                  }
   
                 break;                  break;
         case (LIST_diag):          case LIST_diag:
                 if (MDOC_HEAD != n->type)                  if (MDOC_HEAD != n->type)
                         break;                          break;
                 p->flags |= TERMP_NOBREAK | TERMP_BRIND;                  p->flags |= TERMP_NOBREAK | TERMP_BRIND;
Line 855  termp_it_pre(DECL_ARGS)
Line 841  termp_it_pre(DECL_ARGS)
                 break;                  break;
         }          }
   
         /*          /*
          * Margin control.  Set-head-width lists have their right           * Margin control.  Set-head-width lists have their right
          * margins shortened.  The body for these lists has the offset           * margins shortened.  The body for these lists has the offset
          * necessarily lengthened.  Everybody gets the offset.           * necessarily lengthened.  Everybody gets the offset.
Line 864  termp_it_pre(DECL_ARGS)
Line 850  termp_it_pre(DECL_ARGS)
         p->offset += offset;          p->offset += offset;
   
         switch (type) {          switch (type) {
         case (LIST_hang):          case LIST_hang:
                 /*                  /*
                  * Same stipulation as above, regarding `-hang'.  We                   * Same stipulation as above, regarding `-hang'.  We
                  * don't want to recalculate rmargin and offsets when                   * don't want to recalculate rmargin and offsets when
                  * using `Bd' or `Bl' within `-hang' overstep lists.                   * using `Bd' or `Bl' within `-hang' overstep lists.
                  */                   */
                 if (MDOC_HEAD == n->type && n->next->child &&                  if (MDOC_HEAD == n->type && n->next->child &&
                                 (MDOC_Bl == n->next->child->tok ||                      (MDOC_Bl == n->next->child->tok ||
                                  MDOC_Bd == n->next->child->tok))                       MDOC_Bd == n->next->child->tok))
                         break;                          break;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_bullet):          case LIST_bullet:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_dash):          case LIST_dash:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_enum):          case LIST_enum:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_hyphen):          case LIST_hyphen:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_tag):          case LIST_tag:
                 assert(width);                  assert(width);
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->rmargin = p->offset + width;                          p->rmargin = p->offset + width;
Line 893  termp_it_pre(DECL_ARGS)
Line 879  termp_it_pre(DECL_ARGS)
                                 p->rmargin = p->offset;                                  p->rmargin = p->offset;
                 }                  }
                 break;                  break;
         case (LIST_column):          case LIST_column:
                 assert(width);                  assert(width);
                 p->rmargin = p->offset + width;                  p->rmargin = p->offset + width;
                 /*                  /*
                  * XXX - this behaviour is not documented: the                   * XXX - this behaviour is not documented: the
                  * right-most column is filled to the right margin.                   * right-most column is filled to the right margin.
                  */                   */
Line 909  termp_it_pre(DECL_ARGS)
Line 895  termp_it_pre(DECL_ARGS)
                 break;                  break;
         }          }
   
         /*          /*
          * The dash, hyphen, bullet and enum lists all have a special           * The dash, hyphen, bullet and enum lists all have a special
          * HEAD character (temporarily bold, in some cases).           * HEAD character (temporarily bold, in some cases).
          */           */
   
         if (MDOC_HEAD == n->type)          if (MDOC_HEAD == n->type)
                 switch (type) {                  switch (type) {
                 case (LIST_bullet):                  case LIST_bullet:
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\[bu]");                          term_word(p, "\\[bu]");
                         term_fontpop(p);                          term_fontpop(p);
                         break;                          break;
                 case (LIST_dash):                  case LIST_dash:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (LIST_hyphen):                  case LIST_hyphen:
                         term_fontpush(p, TERMFONT_BOLD);                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\(hy");                          term_word(p, "\\(hy");
                         term_fontpop(p);                          term_fontpop(p);
                         break;                          break;
                 case (LIST_enum):                  case LIST_enum:
                         (pair->ppair->ppair->count)++;                          (pair->ppair->ppair->count)++;
                         snprintf(buf, sizeof(buf), "%d.",                          snprintf(buf, sizeof(buf), "%d.",
                                         pair->ppair->ppair->count);                              pair->ppair->ppair->count);
                         term_word(p, buf);                          term_word(p, buf);
                         break;                          break;
                 default:                  default:
                         break;                          break;
                 }                  }
   
         /*          /*
          * If we're not going to process our children, indicate so here.           * If we're not going to process our children, indicate so here.
          */           */
   
         switch (type) {          switch (type) {
         case (LIST_bullet):          case LIST_bullet:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_item):          case LIST_item:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_dash):          case LIST_dash:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_hyphen):          case LIST_hyphen:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_enum):          case LIST_enum:
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
         case (LIST_column):          case LIST_column:
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
Line 966  termp_it_pre(DECL_ARGS)
Line 952  termp_it_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_it_post(DECL_ARGS)  termp_it_post(DECL_ARGS)
 {  {
Line 979  termp_it_post(DECL_ARGS)
Line 963  termp_it_post(DECL_ARGS)
         type = n->parent->parent->parent->norm->Bl.type;          type = n->parent->parent->parent->norm->Bl.type;
   
         switch (type) {          switch (type) {
         case (LIST_item):          case LIST_item:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_diag):          case LIST_diag:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (LIST_inset):          case LIST_inset:
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_newln(p);                          term_newln(p);
                 break;                  break;
         case (LIST_column):          case LIST_column:
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_flushln(p);                          term_flushln(p);
                 break;                  break;
Line 996  termp_it_post(DECL_ARGS)
Line 980  termp_it_post(DECL_ARGS)
                 break;                  break;
         }          }
   
         /*          /*
          * Now that our output is flushed, we can reset our tags.  Since           * Now that our output is flushed, we can reset our tags.  Since
          * only `It' sets these flags, we're free to assume that nobody           * only `It' sets these flags, we're free to assume that nobody
          * has munged them in the meanwhile.           * has munged them in the meanwhile.
Line 1007  termp_it_post(DECL_ARGS)
Line 991  termp_it_post(DECL_ARGS)
         p->trailspace = 0;          p->trailspace = 0;
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_nm_pre(DECL_ARGS)  termp_nm_pre(DECL_ARGS)
 {  {
Line 1061  termp_nm_pre(DECL_ARGS)
Line 1043  termp_nm_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_nm_post(DECL_ARGS)  termp_nm_post(DECL_ARGS)
 {  {
Line 1077  termp_nm_post(DECL_ARGS)
Line 1057  termp_nm_post(DECL_ARGS)
                 term_flushln(p);                  term_flushln(p);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fl_pre(DECL_ARGS)  termp_fl_pre(DECL_ARGS)
 {  {
Line 1094  termp_fl_pre(DECL_ARGS)
Line 1072  termp_fl_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp__a_pre(DECL_ARGS)  termp__a_pre(DECL_ARGS)
 {  {
Line 1107  termp__a_pre(DECL_ARGS)
Line 1083  termp__a_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_an_pre(DECL_ARGS)  termp_an_pre(DECL_ARGS)
 {  {
Line 1124  termp_an_pre(DECL_ARGS)
Line 1098  termp_an_pre(DECL_ARGS)
          * with other macros/text, are split.  -split, in this case,           * with other macros/text, are split.  -split, in this case,
          * will override the condition of the implied first -nosplit.           * will override the condition of the implied first -nosplit.
          */           */
   
         if (n->sec == SEC_AUTHORS) {          if (n->sec == SEC_AUTHORS) {
                 if ( ! (TERMP_ANPREC & p->flags)) {                  if ( ! (TERMP_ANPREC & p->flags)) {
                         if (TERMP_SPLIT & p->flags)                          if (TERMP_SPLIT & p->flags)
Line 1143  termp_an_pre(DECL_ARGS)
Line 1117  termp_an_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_an_post(DECL_ARGS)  termp_an_post(DECL_ARGS)
 {  {
Line 1165  termp_an_post(DECL_ARGS)
Line 1137  termp_an_post(DECL_ARGS)
   
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ns_pre(DECL_ARGS)  termp_ns_pre(DECL_ARGS)
 {  {
Line 1176  termp_ns_pre(DECL_ARGS)
Line 1146  termp_ns_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_rs_pre(DECL_ARGS)  termp_rs_pre(DECL_ARGS)
 {  {
Line 1189  termp_rs_pre(DECL_ARGS)
Line 1157  termp_rs_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_rv_pre(DECL_ARGS)  termp_rv_pre(DECL_ARGS)
 {  {
Line 1222  termp_rv_pre(DECL_ARGS)
Line 1188  termp_rv_pre(DECL_ARGS)
         else          else
                 term_word(p, "function returns");                  term_word(p, "function returns");
   
         term_word(p, "the value 0 if successful; otherwise the value "          term_word(p, "the value 0 if successful; otherwise the "
                         "-1 is returned and the global variable");              "value -1 is returned and the global variable");
   
         term_fontpush(p, TERMFONT_UNDER);          term_fontpush(p, TERMFONT_UNDER);
         term_word(p, "errno");          term_word(p, "errno");
         term_fontpop(p);          term_fontpop(p);
   
         term_word(p, "is set to indicate the error.");          term_word(p, "is set to indicate the error.");
         p->flags |= TERMP_SENTENCE;          p->flags |= TERMP_SENTENCE;
   
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ex_pre(DECL_ARGS)  termp_ex_pre(DECL_ARGS)
 {  {
Line 1265  termp_ex_pre(DECL_ARGS)
Line 1229  termp_ex_pre(DECL_ARGS)
         else          else
                 term_word(p, "utility exits");                  term_word(p, "utility exits");
   
         term_word(p, "0 on success, and >0 if an error occurs.");          term_word(p, "0 on success, and >0 if an error occurs.");
   
         p->flags |= TERMP_SENTENCE;          p->flags |= TERMP_SENTENCE;
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_nd_pre(DECL_ARGS)  termp_nd_pre(DECL_ARGS)
 {  {
Line 1288  termp_nd_pre(DECL_ARGS)
Line 1250  termp_nd_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bl_pre(DECL_ARGS)  termp_bl_pre(DECL_ARGS)
 {  {
Line 1297  termp_bl_pre(DECL_ARGS)
Line 1257  termp_bl_pre(DECL_ARGS)
         return(MDOC_HEAD != n->type);          return(MDOC_HEAD != n->type);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_bl_post(DECL_ARGS)  termp_bl_post(DECL_ARGS)
 {  {
Line 1307  termp_bl_post(DECL_ARGS)
Line 1265  termp_bl_post(DECL_ARGS)
                 term_newln(p);                  term_newln(p);
 }  }
   
 /* ARGSUSED */  
 static int  static int
 termp_xr_pre(DECL_ARGS)  termp_xr_pre(DECL_ARGS)
 {  {
Line 1318  termp_xr_pre(DECL_ARGS)
Line 1275  termp_xr_pre(DECL_ARGS)
         assert(MDOC_TEXT == n->type);          assert(MDOC_TEXT == n->type);
         term_word(p, n->string);          term_word(p, n->string);
   
         if (NULL == (n = n->next))          if (NULL == (n = n->next))
                 return(0);                  return(0);
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
Line 1342  termp_xr_pre(DECL_ARGS)
Line 1299  termp_xr_pre(DECL_ARGS)
 static void  static void
 synopsis_pre(struct termp *p, const struct mdoc_node *n)  synopsis_pre(struct termp *p, const struct mdoc_node *n)
 {  {
         /*          /*
          * Obviously, if we're not in a SYNOPSIS or no prior macros           * Obviously, if we're not in a SYNOPSIS or no prior macros
          * exist, do nothing.           * exist, do nothing.
          */           */
Line 1354  synopsis_pre(struct termp *p, const struct mdoc_node *
Line 1311  synopsis_pre(struct termp *p, const struct mdoc_node *
          * newline and return.  UNLESS we're `Fo', `Fn', `Fn', in which           * newline and return.  UNLESS we're `Fo', `Fn', `Fn', in which
          * case we soldier on.           * case we soldier on.
          */           */
         if (n->prev->tok == n->tok &&          if (n->prev->tok == n->tok &&
                         MDOC_Ft != n->tok &&              MDOC_Ft != n->tok &&
                         MDOC_Fo != n->tok &&              MDOC_Fo != n->tok &&
                         MDOC_Fn != n->tok) {              MDOC_Fn != n->tok) {
                 term_newln(p);                  term_newln(p);
                 return;                  return;
         }          }
Line 1368  synopsis_pre(struct termp *p, const struct mdoc_node *
Line 1325  synopsis_pre(struct termp *p, const struct mdoc_node *
          * vertical space, else only newline and move on.           * vertical space, else only newline and move on.
          */           */
         switch (n->prev->tok) {          switch (n->prev->tok) {
         case (MDOC_Fd):          case MDOC_Fd:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Fn):          case MDOC_Fn:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Fo):          case MDOC_Fo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_In):          case MDOC_In:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Vt):          case MDOC_Vt:
                 term_vspace(p);                  term_vspace(p);
                 break;                  break;
         case (MDOC_Ft):          case MDOC_Ft:
                 if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {                  if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
                         term_vspace(p);                          term_vspace(p);
                         break;                          break;
Line 1391  synopsis_pre(struct termp *p, const struct mdoc_node *
Line 1348  synopsis_pre(struct termp *p, const struct mdoc_node *
         }          }
 }  }
   
   
 static int  static int
 termp_vt_pre(DECL_ARGS)  termp_vt_pre(DECL_ARGS)
 {  {
Line 1408  termp_vt_pre(DECL_ARGS)
Line 1364  termp_vt_pre(DECL_ARGS)
         return(termp_under_pre(p, pair, meta, n));          return(termp_under_pre(p, pair, meta, n));
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bold_pre(DECL_ARGS)  termp_bold_pre(DECL_ARGS)
 {  {
Line 1418  termp_bold_pre(DECL_ARGS)
Line 1372  termp_bold_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fd_pre(DECL_ARGS)  termp_fd_pre(DECL_ARGS)
 {  {
Line 1428  termp_fd_pre(DECL_ARGS)
Line 1380  termp_fd_pre(DECL_ARGS)
         return(termp_bold_pre(p, pair, meta, n));          return(termp_bold_pre(p, pair, meta, n));
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_fd_post(DECL_ARGS)  termp_fd_post(DECL_ARGS)
 {  {
Line 1437  termp_fd_post(DECL_ARGS)
Line 1387  termp_fd_post(DECL_ARGS)
         term_newln(p);          term_newln(p);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_sh_pre(DECL_ARGS)  termp_sh_pre(DECL_ARGS)
 {  {
Line 1446  termp_sh_pre(DECL_ARGS)
Line 1394  termp_sh_pre(DECL_ARGS)
         /* No vspace between consecutive `Sh' calls. */          /* No vspace between consecutive `Sh' calls. */
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_BLOCK):          case MDOC_BLOCK:
                 if (n->prev && MDOC_Sh == n->prev->tok)                  if (n->prev && MDOC_Sh == n->prev->tok)
                         if (NULL == n->prev->body->child)                          if (NULL == n->prev->body->child)
                                 break;                                  break;
                 term_vspace(p);                  term_vspace(p);
                 break;                  break;
         case (MDOC_HEAD):          case MDOC_HEAD:
                 term_fontpush(p, TERMFONT_BOLD);                  term_fontpush(p, TERMFONT_BOLD);
                 break;                  break;
         case (MDOC_BODY):          case MDOC_BODY:
                 p->offset = term_len(p, p->defindent);                  p->offset = term_len(p, p->defindent);
                 if (SEC_AUTHORS == n->sec)                  if (SEC_AUTHORS == n->sec)
                         p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);                          p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
Line 1466  termp_sh_pre(DECL_ARGS)
Line 1414  termp_sh_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_sh_post(DECL_ARGS)  termp_sh_post(DECL_ARGS)
 {  {
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_HEAD):          case MDOC_HEAD:
                 term_newln(p);                  term_newln(p);
                 break;                  break;
         case (MDOC_BODY):          case MDOC_BODY:
                 term_newln(p);                  term_newln(p);
                 p->offset = 0;                  p->offset = 0;
                 break;                  break;
Line 1485  termp_sh_post(DECL_ARGS)
Line 1431  termp_sh_post(DECL_ARGS)
         }          }
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bt_pre(DECL_ARGS)  termp_bt_pre(DECL_ARGS)
 {  {
Line 1496  termp_bt_pre(DECL_ARGS)
Line 1440  termp_bt_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_lb_post(DECL_ARGS)  termp_lb_post(DECL_ARGS)
 {  {
Line 1506  termp_lb_post(DECL_ARGS)
Line 1448  termp_lb_post(DECL_ARGS)
                 term_newln(p);                  term_newln(p);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ud_pre(DECL_ARGS)  termp_ud_pre(DECL_ARGS)
 {  {
Line 1517  termp_ud_pre(DECL_ARGS)
Line 1457  termp_ud_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_d1_pre(DECL_ARGS)  termp_d1_pre(DECL_ARGS)
 {  {
Line 1530  termp_d1_pre(DECL_ARGS)
Line 1468  termp_d1_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ft_pre(DECL_ARGS)  termp_ft_pre(DECL_ARGS)
 {  {
Line 1542  termp_ft_pre(DECL_ARGS)
Line 1478  termp_ft_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fn_pre(DECL_ARGS)  termp_fn_pre(DECL_ARGS)
 {  {
Line 1605  termp_fn_pre(DECL_ARGS)
Line 1539  termp_fn_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fa_pre(DECL_ARGS)  termp_fa_pre(DECL_ARGS)
 {  {
Line 1632  termp_fa_pre(DECL_ARGS)
Line 1564  termp_fa_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bd_pre(DECL_ARGS)  termp_bd_pre(DECL_ARGS)
 {  {
Line 1656  termp_bd_pre(DECL_ARGS)
Line 1586  termp_bd_pre(DECL_ARGS)
          * for macro lines, a newline is appended to the line.  Blank           * for macro lines, a newline is appended to the line.  Blank
          * lines are allowed.           * lines are allowed.
          */           */
   
         if (DISP_literal != n->norm->Bd.type &&          if (DISP_literal != n->norm->Bd.type &&
                         DISP_unfilled != n->norm->Bd.type)              DISP_unfilled != n->norm->Bd.type)
                 return(1);                  return(1);
   
         tabwidth = p->tabwidth;          tabwidth = p->tabwidth;
Line 1678  termp_bd_pre(DECL_ARGS)
Line 1608  termp_bd_pre(DECL_ARGS)
                  * anyway, so don't sweat it.                   * anyway, so don't sweat it.
                  */                   */
                 switch (nn->tok) {                  switch (nn->tok) {
                 case (MDOC_Sm):                  case MDOC_Sm:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_br):                  case MDOC_br:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_sp):                  case MDOC_sp:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Bl):                  case MDOC_Bl:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_D1):                  case MDOC_D1:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Dl):                  case MDOC_Dl:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Lp):                  case MDOC_Lp:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Pp):                  case MDOC_Pp:
                         continue;                          continue;
                 default:                  default:
                         break;                          break;
Line 1709  termp_bd_pre(DECL_ARGS)
Line 1639  termp_bd_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_bd_post(DECL_ARGS)  termp_bd_post(DECL_ARGS)
 {  {
         size_t           rm, rmax;          size_t           rm, rmax;
   
         if (MDOC_BODY != n->type)          if (MDOC_BODY != n->type)
                 return;                  return;
   
         rm = p->rmargin;          rm = p->rmargin;
         rmax = p->maxrmargin;          rmax = p->maxrmargin;
   
         if (DISP_literal == n->norm->Bd.type ||          if (DISP_literal == n->norm->Bd.type ||
                         DISP_unfilled == n->norm->Bd.type)              DISP_unfilled == n->norm->Bd.type)
                 p->rmargin = p->maxrmargin = TERM_MAXMARGIN;                  p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
Line 1733  termp_bd_post(DECL_ARGS)
Line 1661  termp_bd_post(DECL_ARGS)
         p->maxrmargin = rmax;          p->maxrmargin = rmax;
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bx_pre(DECL_ARGS)  termp_bx_pre(DECL_ARGS)
 {  {
Line 1758  termp_bx_pre(DECL_ARGS)
Line 1684  termp_bx_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_xx_pre(DECL_ARGS)  termp_xx_pre(DECL_ARGS)
 {  {
Line 1768  termp_xx_pre(DECL_ARGS)
Line 1692  termp_xx_pre(DECL_ARGS)
   
         pp = NULL;          pp = NULL;
         switch (n->tok) {          switch (n->tok) {
         case (MDOC_Bsx):          case MDOC_Bsx:
                 pp = "BSD/OS";                  pp = "BSD/OS";
                 break;                  break;
         case (MDOC_Dx):          case MDOC_Dx:
                 pp = "DragonFly";                  pp = "DragonFly";
                 break;                  break;
         case (MDOC_Fx):          case MDOC_Fx:
                 pp = "FreeBSD";                  pp = "FreeBSD";
                 break;                  break;
         case (MDOC_Nx):          case MDOC_Nx:
                 pp = "NetBSD";                  pp = "NetBSD";
                 break;                  break;
         case (MDOC_Ox):          case MDOC_Ox:
                 pp = "OpenBSD";                  pp = "OpenBSD";
                 break;                  break;
         case (MDOC_Ux):          case MDOC_Ux:
                 pp = "UNIX";                  pp = "UNIX";
                 break;                  break;
         default:          default:
Line 1801  termp_xx_pre(DECL_ARGS)
Line 1725  termp_xx_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_pf_post(DECL_ARGS)  termp_pf_post(DECL_ARGS)
 {  {
Line 1810  termp_pf_post(DECL_ARGS)
Line 1732  termp_pf_post(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ss_pre(DECL_ARGS)  termp_ss_pre(DECL_ARGS)
 {  {
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_BLOCK):          case MDOC_BLOCK:
                 term_newln(p);                  term_newln(p);
                 if (n->prev)                  if (n->prev)
                         term_vspace(p);                          term_vspace(p);
                 break;                  break;
         case (MDOC_HEAD):          case MDOC_HEAD:
                 term_fontpush(p, TERMFONT_BOLD);                  term_fontpush(p, TERMFONT_BOLD);
                 p->offset = term_len(p, (p->defindent+1)/2);                  p->offset = term_len(p, (p->defindent+1)/2);
                 break;                  break;
Line 1833  termp_ss_pre(DECL_ARGS)
Line 1753  termp_ss_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_ss_post(DECL_ARGS)  termp_ss_post(DECL_ARGS)
 {  {
Line 1843  termp_ss_post(DECL_ARGS)
Line 1761  termp_ss_post(DECL_ARGS)
                 term_newln(p);                  term_newln(p);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_cd_pre(DECL_ARGS)  termp_cd_pre(DECL_ARGS)
 {  {
Line 1854  termp_cd_pre(DECL_ARGS)
Line 1770  termp_cd_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_in_pre(DECL_ARGS)  termp_in_pre(DECL_ARGS)
 {  {
Line 1875  termp_in_pre(DECL_ARGS)
Line 1789  termp_in_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_in_post(DECL_ARGS)  termp_in_post(DECL_ARGS)
 {  {
Line 1891  termp_in_post(DECL_ARGS)
Line 1803  termp_in_post(DECL_ARGS)
                 term_fontpop(p);                  term_fontpop(p);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_sp_pre(DECL_ARGS)  termp_sp_pre(DECL_ARGS)
 {  {
         size_t           i, len;          size_t           i, len;
   
         switch (n->tok) {          switch (n->tok) {
         case (MDOC_sp):          case MDOC_sp:
                 len = n->child ? a2height(p, n->child->string) : 1;                  len = n->child ? a2height(p, n->child->string) : 1;
                 break;                  break;
         case (MDOC_br):          case MDOC_br:
                 len = 0;                  len = 0;
                 break;                  break;
         default:          default:
Line 1918  termp_sp_pre(DECL_ARGS)
Line 1828  termp_sp_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_quote_pre(DECL_ARGS)  termp_quote_pre(DECL_ARGS)
 {  {
Line 1928  termp_quote_pre(DECL_ARGS)
Line 1836  termp_quote_pre(DECL_ARGS)
                 return(1);                  return(1);
   
         switch (n->tok) {          switch (n->tok) {
         case (MDOC_Ao):          case MDOC_Ao:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Aq):          case MDOC_Aq:
                 term_word(p, "<");                  term_word(p, "<");
                 break;                  break;
         case (MDOC_Bro):          case MDOC_Bro:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Brq):          case MDOC_Brq:
                 term_word(p, "{");                  term_word(p, "{");
                 break;                  break;
         case (MDOC_Oo):          case MDOC_Oo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Op):          case MDOC_Op:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bo):          case MDOC_Bo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bq):          case MDOC_Bq:
                 term_word(p, "[");                  term_word(p, "[");
                 break;                  break;
         case (MDOC_Do):          case MDOC_Do:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dq):          case MDOC_Dq:
                 term_word(p, "\\(lq");                  term_word(p, "\\(lq");
                 break;                  break;
         case (MDOC_Eo):          case MDOC_Eo:
                 break;                  break;
         case (MDOC_Po):          case MDOC_Po:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Pq):          case MDOC_Pq:
                 term_word(p, "(");                  term_word(p, "(");
                 break;                  break;
         case (MDOC__T):          case MDOC__T:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Qo):          case MDOC_Qo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Qq):          case MDOC_Qq:
                 term_word(p, "\"");                  term_word(p, "\"");
                 break;                  break;
         case (MDOC_Ql):          case MDOC_Ql:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_So):          case MDOC_So:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Sq):          case MDOC_Sq:
                 term_word(p, "\\(oq");                  term_word(p, "\\(oq");
                 break;                  break;
         default:          default:
Line 1982  termp_quote_pre(DECL_ARGS)
Line 1890  termp_quote_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_quote_post(DECL_ARGS)  termp_quote_post(DECL_ARGS)
 {  {
Line 1994  termp_quote_post(DECL_ARGS)
Line 1900  termp_quote_post(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (n->tok) {          switch (n->tok) {
         case (MDOC_Ao):          case MDOC_Ao:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Aq):          case MDOC_Aq:
                 term_word(p, ">");                  term_word(p, ">");
                 break;                  break;
         case (MDOC_Bro):          case MDOC_Bro:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Brq):          case MDOC_Brq:
                 term_word(p, "}");                  term_word(p, "}");
                 break;                  break;
         case (MDOC_Oo):          case MDOC_Oo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Op):          case MDOC_Op:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bo):          case MDOC_Bo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bq):          case MDOC_Bq:
                 term_word(p, "]");                  term_word(p, "]");
                 break;                  break;
         case (MDOC_Do):          case MDOC_Do:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dq):          case MDOC_Dq:
                 term_word(p, "\\(rq");                  term_word(p, "\\(rq");
                 break;                  break;
         case (MDOC_Eo):          case MDOC_Eo:
                 break;                  break;
         case (MDOC_Po):          case MDOC_Po:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Pq):          case MDOC_Pq:
                 term_word(p, ")");                  term_word(p, ")");
                 break;                  break;
         case (MDOC__T):          case MDOC__T:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Qo):          case MDOC_Qo:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Qq):          case MDOC_Qq:
                 term_word(p, "\"");                  term_word(p, "\"");
                 break;                  break;
         case (MDOC_Ql):          case MDOC_Ql:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_So):          case MDOC_So:
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Sq):          case MDOC_Sq:
                 term_word(p, "\\(cq");                  term_word(p, "\\(cq");
                 break;                  break;
         default:          default:
Line 2045  termp_quote_post(DECL_ARGS)
Line 1951  termp_quote_post(DECL_ARGS)
         }          }
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fo_pre(DECL_ARGS)  termp_fo_pre(DECL_ARGS)
 {  {
Line 2089  termp_fo_pre(DECL_ARGS)
Line 1993  termp_fo_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_fo_post(DECL_ARGS)  termp_fo_post(DECL_ARGS)
 {  {
   
         if (MDOC_BODY != n->type)          if (MDOC_BODY != n->type)
                 return;                  return;
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
Line 2108  termp_fo_post(DECL_ARGS)
Line 2010  termp_fo_post(DECL_ARGS)
         }          }
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bf_pre(DECL_ARGS)  termp_bf_pre(DECL_ARGS)
 {  {
Line 2119  termp_bf_pre(DECL_ARGS)
Line 2019  termp_bf_pre(DECL_ARGS)
         else if (MDOC_BODY != n->type)          else if (MDOC_BODY != n->type)
                 return(1);                  return(1);
   
         if (FONT_Em == n->norm->Bf.font)          if (FONT_Em == n->norm->Bf.font)
                 term_fontpush(p, TERMFONT_UNDER);                  term_fontpush(p, TERMFONT_UNDER);
         else if (FONT_Sy == n->norm->Bf.font)          else if (FONT_Sy == n->norm->Bf.font)
                 term_fontpush(p, TERMFONT_BOLD);                  term_fontpush(p, TERMFONT_BOLD);
         else          else
                 term_fontpush(p, TERMFONT_NONE);                  term_fontpush(p, TERMFONT_NONE);
   
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_sm_pre(DECL_ARGS)  termp_sm_pre(DECL_ARGS)
 {  {
Line 2146  termp_sm_pre(DECL_ARGS)
Line 2044  termp_sm_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_ap_pre(DECL_ARGS)  termp_ap_pre(DECL_ARGS)
 {  {
Line 2158  termp_ap_pre(DECL_ARGS)
Line 2054  termp_ap_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp____post(DECL_ARGS)  termp____post(DECL_ARGS)
 {  {
Line 2187  termp____post(DECL_ARGS)
Line 2081  termp____post(DECL_ARGS)
                 term_word(p, ",");                  term_word(p, ",");
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_li_pre(DECL_ARGS)  termp_li_pre(DECL_ARGS)
 {  {
Line 2197  termp_li_pre(DECL_ARGS)
Line 2089  termp_li_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_lk_pre(DECL_ARGS)  termp_lk_pre(DECL_ARGS)
 {  {
Line 2225  termp_lk_pre(DECL_ARGS)
Line 2115  termp_lk_pre(DECL_ARGS)
         return(0);          return(0);
 }  }
   
   
 /* ARGSUSED */  
 static int  static int
 termp_bk_pre(DECL_ARGS)  termp_bk_pre(DECL_ARGS)
 {  {
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_BLOCK):          case MDOC_BLOCK:
                 break;                  break;
         case (MDOC_HEAD):          case MDOC_HEAD:
                 return(0);                  return(0);
         case (MDOC_BODY):          case MDOC_BODY:
                 if (n->parent->args || 0 == n->prev->nchild)                  if (n->parent->args || 0 == n->prev->nchild)
                         p->flags |= TERMP_PREKEEP;                          p->flags |= TERMP_PREKEEP;
                 break;                  break;
Line 2248  termp_bk_pre(DECL_ARGS)
Line 2136  termp_bk_pre(DECL_ARGS)
         return(1);          return(1);
 }  }
   
   
 /* ARGSUSED */  
 static void  static void
 termp_bk_post(DECL_ARGS)  termp_bk_post(DECL_ARGS)
 {  {
Line 2258  termp_bk_post(DECL_ARGS)
Line 2144  termp_bk_post(DECL_ARGS)
                 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);                  p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
 }  }
   
 /* ARGSUSED */  
 static void  static void
 termp__t_post(DECL_ARGS)  termp__t_post(DECL_ARGS)
 {  {
Line 2268  termp__t_post(DECL_ARGS)
Line 2153  termp__t_post(DECL_ARGS)
          * us instead of underlining us (for disambiguation).           * us instead of underlining us (for disambiguation).
          */           */
         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)
                 termp_quote_post(p, pair, meta, n);                  termp_quote_post(p, pair, meta, n);
   
         termp____post(p, pair, meta, n);          termp____post(p, pair, meta, n);
 }  }
   
 /* ARGSUSED */  
 static int  static int
 termp__t_pre(DECL_ARGS)  termp__t_pre(DECL_ARGS)
 {  {
Line 2284  termp__t_pre(DECL_ARGS)
Line 2168  termp__t_pre(DECL_ARGS)
          * us instead of underlining us (for disambiguation).           * us instead of underlining us (for disambiguation).
          */           */
         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)
                 return(termp_quote_pre(p, pair, meta, n));                  return(termp_quote_pre(p, pair, meta, n));
   
         term_fontpush(p, TERMFONT_UNDER);          term_fontpush(p, TERMFONT_UNDER);
         return(1);          return(1);
 }  }
   
 /* ARGSUSED */  
 static int  static int
 termp_under_pre(DECL_ARGS)  termp_under_pre(DECL_ARGS)
 {  {

Legend:
Removed from v.1.263  
changed lines
  Added in v.1.264

CVSweb