[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.112 and 1.135

version 1.112, 2010/03/29 19:28:04 version 1.135, 2010/05/31 10:28:04
Line 22 
Line 22 
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
   #include <stdint.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
   #include "mandoc.h"
 #include "out.h"  #include "out.h"
 #include "term.h"  #include "term.h"
 #include "mdoc.h"  #include "mdoc.h"
Line 58  static int   arg_hasattr(int, const struct mdoc_node *
Line 60  static int   arg_hasattr(int, const struct mdoc_node *
 static  int       arg_getattrs(const int *, int *, size_t,  static  int       arg_getattrs(const int *, int *, size_t,
                         const struct mdoc_node *);                          const struct mdoc_node *);
 static  int       arg_getattr(int, const struct mdoc_node *);  static  int       arg_getattr(int, const struct mdoc_node *);
 static  int       arg_listtype(const struct mdoc_node *);  static  int       arg_disptype(const struct mdoc_node *);
 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 *);
Line 93  static void   termp_sq_post(DECL_ARGS);
Line 95  static void   termp_sq_post(DECL_ARGS);
 static  void      termp_ss_post(DECL_ARGS);  static  void      termp_ss_post(DECL_ARGS);
 static  void      termp_vt_post(DECL_ARGS);  static  void      termp_vt_post(DECL_ARGS);
   
 static  int       termp__t_pre(DECL_ARGS);  
 static  int       termp_an_pre(DECL_ARGS);  static  int       termp_an_pre(DECL_ARGS);
 static  int       termp_ap_pre(DECL_ARGS);  static  int       termp_ap_pre(DECL_ARGS);
 static  int       termp_aq_pre(DECL_ARGS);  static  int       termp_aq_pre(DECL_ARGS);
 static  int       termp_bd_pre(DECL_ARGS);  static  int       termp_bd_pre(DECL_ARGS);
 static  int       termp_bf_pre(DECL_ARGS);  static  int       termp_bf_pre(DECL_ARGS);
   static  int       termp_bl_pre(DECL_ARGS);
 static  int       termp_bold_pre(DECL_ARGS);  static  int       termp_bold_pre(DECL_ARGS);
 static  int       termp_bq_pre(DECL_ARGS);  static  int       termp_bq_pre(DECL_ARGS);
 static  int       termp_brq_pre(DECL_ARGS);  static  int       termp_brq_pre(DECL_ARGS);
Line 148  static const struct termact termacts[MDOC_MAX] = {
Line 150  static const struct termact termacts[MDOC_MAX] = {
         { termp_d1_pre, termp_d1_post }, /* Dl */          { termp_d1_pre, termp_d1_post }, /* Dl */
         { termp_bd_pre, termp_bd_post }, /* Bd */          { termp_bd_pre, termp_bd_post }, /* Bd */
         { NULL, NULL }, /* Ed */          { NULL, NULL }, /* Ed */
         { NULL, 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 */
         { NULL, NULL }, /* Ad */          { NULL, NULL }, /* Ad */
Line 187  static const struct termact termacts[MDOC_MAX] = {
Line 189  static const struct termact termacts[MDOC_MAX] = {
         { NULL, termp____post }, /* %O */          { NULL, termp____post }, /* %O */
         { NULL, termp____post }, /* %P */          { NULL, termp____post }, /* %P */
         { NULL, termp____post }, /* %R */          { NULL, termp____post }, /* %R */
         { termp__t_pre, termp____post }, /* %T */          { termp_under_pre, termp____post }, /* %T */
         { NULL, termp____post }, /* %V */          { NULL, termp____post }, /* %V */
         { NULL, NULL }, /* Ac */          { NULL, NULL }, /* Ac */
         { termp_aq_pre, termp_aq_post }, /* Ao */          { termp_aq_pre, termp_aq_post }, /* Ao */
Line 258  static const struct termact termacts[MDOC_MAX] = {
Line 260  static const struct termact termacts[MDOC_MAX] = {
         { termp_sp_pre, NULL }, /* br */          { termp_sp_pre, NULL }, /* br */
         { termp_sp_pre, NULL }, /* sp */          { termp_sp_pre, NULL }, /* sp */
         { termp_under_pre, termp____post }, /* %U */          { termp_under_pre, termp____post }, /* %U */
           { NULL, NULL }, /* Ta */
 };  };
   
   
Line 271  terminal_mdoc(void *arg, const struct mdoc *mdoc)
Line 274  terminal_mdoc(void *arg, const struct mdoc *mdoc)
         p = (struct termp *)arg;          p = (struct termp *)arg;
   
         p->overstep = 0;          p->overstep = 0;
         p->maxrmargin = 78;          p->maxrmargin = p->defrmargin;
           p->tabwidth = 5;
   
         if (NULL == p->symtab)          if (NULL == p->symtab)
                 switch (p->enc) {                  switch (p->enc) {
Line 335  print_mdoc_node(DECL_ARGS)
Line 339  print_mdoc_node(DECL_ARGS)
                 if (termacts[n->tok].post)                  if (termacts[n->tok].post)
                         (*termacts[n->tok].post)(p, &npair, m, n);                          (*termacts[n->tok].post)(p, &npair, m, n);
   
           if (MDOC_EOS & n->flags)
                   p->flags |= TERMP_SENTENCE;
   
         p->offset = offset;          p->offset = offset;
         p->rmargin = rmargin;          p->rmargin = rmargin;
 }  }
Line 420  print_mdoc_head(DECL_ARGS)
Line 427  print_mdoc_head(DECL_ARGS)
                 strlcat(buf, ")", BUFSIZ);                  strlcat(buf, ")", BUFSIZ);
         }          }
   
         snprintf(title, BUFSIZ, "%s(%d)", m->title, m->msec);          snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
   
         p->offset = 0;          p->offset = 0;
         p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;          p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
Line 478  a2width(const struct mdoc_argv *arg, int pos)
Line 485  a2width(const struct mdoc_argv *arg, int pos)
   
   
 static int  static int
 arg_listtype(const struct mdoc_node *n)  arg_disptype(const struct mdoc_node *n)
 {  {
         int              i, len;          int              i, len;
   
Line 486  arg_listtype(const struct mdoc_node *n)
Line 493  arg_listtype(const struct mdoc_node *n)
   
         len = (int)(n->args ? n->args->argc : 0);          len = (int)(n->args ? n->args->argc : 0);
   
         for (i = 0; i < len; i++)          for (i = 0; i < len; i++)
                 switch (n->args->argv[i].arg) {                  switch (n->args->argv[i].arg) {
                 case (MDOC_Bullet):                  case (MDOC_Centred):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Dash):                  case (MDOC_Ragged):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Enum):                  case (MDOC_Filled):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Hyphen):                  case (MDOC_Unfilled):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Tag):                  case (MDOC_Literal):
                         /* FALLTHROUGH */  
                 case (MDOC_Inset):  
                         /* FALLTHROUGH */  
                 case (MDOC_Diag):  
                         /* FALLTHROUGH */  
                 case (MDOC_Item):  
                         /* FALLTHROUGH */  
                 case (MDOC_Column):  
                         /* FALLTHROUGH */  
                 case (MDOC_Hang):  
                         /* FALLTHROUGH */  
                 case (MDOC_Ohang):  
                         return(n->args->argv[i].arg);                          return(n->args->argv[i].arg);
                 default:                  default:
                         break;                          break;
Line 620  print_bvspace(struct termp *p, 
Line 615  print_bvspace(struct termp *p, 
   
         /* A `-column' does not assert vspace within the list. */          /* A `-column' does not assert vspace within the list. */
   
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))          if (MDOC_Bl == bl->tok && LIST_column == bl->data.list)
                 if (n->prev && MDOC_It == n->prev->tok)                  if (n->prev && MDOC_It == n->prev->tok)
                         return;                          return;
   
         /* A `-diag' without body does not vspace. */          /* A `-diag' without body does not vspace. */
   
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl))          if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
                 if (n->prev && MDOC_It == n->prev->tok) {                  if (n->prev && MDOC_It == n->prev->tok) {
                         assert(n->prev->body);                          assert(n->prev->body);
                         if (NULL == n->prev->body->child)                          if (NULL == n->prev->body->child)
Line 670  termp_it_pre(DECL_ARGS)
Line 665  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, type, keys[3], vals[3];          int                     i, keys[3], vals[3];
         size_t                  width, offset, ncols, dcol;          size_t                  width, offset, ncols, dcol;
           enum mdoc_list          type;
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
                 print_bvspace(p, n->parent->parent, n);                  print_bvspace(p, n->parent->parent, n);
Line 690  termp_it_pre(DECL_ARGS)
Line 686  termp_it_pre(DECL_ARGS)
   
         arg_getattrs(keys, vals, 3, bl);          arg_getattrs(keys, vals, 3, bl);
   
         type = arg_listtype(bl);          type = bl->data.list;
         assert(-1 != type);  
   
         /*          /*
          * First calculate width and offset.  This is pretty easy unless           * First calculate width and offset.  This is pretty easy unless
Line 705  termp_it_pre(DECL_ARGS)
Line 700  termp_it_pre(DECL_ARGS)
                 offset = a2offs(&bl->args->argv[vals[1]]);                  offset = a2offs(&bl->args->argv[vals[1]]);
   
         switch (type) {          switch (type) {
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_HEAD == n->type)
                         break;                          break;
                 /*                  /*
                  * Imitate groff's column handling:                   * Imitate groff's column handling:
Line 721  termp_it_pre(DECL_ARGS)
Line 716  termp_it_pre(DECL_ARGS)
                 /* LINTED */                  /* LINTED */
                 dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1;                  dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1;
   
                   /*
                    * Calculate the offset by applying all prior MDOC_BODY,
                    * so we stop at the MDOC_HEAD (NULL == nn->prev).
                    */
   
                 for (i = 0, nn = n->prev;                  for (i = 0, nn = n->prev;
                                 nn && i < (int)ncols;                                  nn->prev && i < (int)ncols;
                                 nn = nn->prev, i++)                                  nn = nn->prev, i++)
                         offset += dcol + a2width                          offset += dcol + a2width
                                 (&bl->args->argv[vals[2]], i);                                  (&bl->args->argv[vals[2]], i);
Line 763  termp_it_pre(DECL_ARGS)
Line 763  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 if (width < 4)                  if (width < 4)
                         width = 4;                          width = 4;
                 break;                  break;
         case (MDOC_Enum):          case (LIST_enum):
                 if (width < 5)                  if (width < 5)
                         width = 5;                          width = 5;
                 break;                  break;
         case (MDOC_Hang):          case (LIST_hang):
                 if (0 == width)                  if (0 == width)
                         width = 8;                          width = 8;
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Tag):          case (LIST_tag):
                 if (0 == width)                  if (0 == width)
                         width = 10;                          width = 10;
                 break;                  break;
Line 797  termp_it_pre(DECL_ARGS)
Line 797  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (MDOC_Diag):          case (LIST_diag):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ \\ ");                          term_word(p, "\\ \\ ");
                 break;                  break;
         case (MDOC_Inset):          case (LIST_inset):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_word(p, "\\ ");                          term_word(p, "\\ ");
                 break;                  break;
Line 812  termp_it_pre(DECL_ARGS)
Line 812  termp_it_pre(DECL_ARGS)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
         case (MDOC_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 828  termp_it_pre(DECL_ARGS)
Line 828  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 else                  else
                         p->flags |= TERMP_NOLPAD;                          p->flags |= TERMP_NOLPAD;
                 break;                  break;
         case (MDOC_Hang):          case (LIST_hang):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 else                  else
Line 863  termp_it_pre(DECL_ARGS)
Line 863  termp_it_pre(DECL_ARGS)
                 } else                  } else
                         p->flags |= TERMP_HANG;                          p->flags |= TERMP_HANG;
                 break;                  break;
         case (MDOC_Tag):          case (LIST_tag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;                          p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;
                 else                  else
Line 874  termp_it_pre(DECL_ARGS)
Line 874  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 (MDOC_Column):          case (LIST_column):
                 if (MDOC_HEAD == n->type) {                  if (MDOC_HEAD == n->type)
                         assert(n->next);                          break;
                         if (MDOC_BODY == n->next->type)  
                                 p->flags &= ~TERMP_NOBREAK;                  if (NULL == n->next)
                         else                          p->flags &= ~TERMP_NOBREAK;
                                 p->flags |= TERMP_NOBREAK;                  else
                         if (n->prev)                          p->flags |= TERMP_NOBREAK;
                                 p->flags |= TERMP_NOLPAD;  
                 }                  assert(n->prev);
                   if (MDOC_BODY == n->prev->type)
                           p->flags |= TERMP_NOLPAD;
   
                 break;                  break;
         case (MDOC_Diag):          case (LIST_diag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK;
                 break;                  break;
Line 902  termp_it_pre(DECL_ARGS)
Line 905  termp_it_pre(DECL_ARGS)
         p->offset += offset;          p->offset += offset;
   
         switch (type) {          switch (type) {
         case (MDOC_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
Line 913  termp_it_pre(DECL_ARGS)
Line 916  termp_it_pre(DECL_ARGS)
                                  MDOC_Bd == n->next->child->tok))                                   MDOC_Bd == n->next->child->tok))
                         break;                          break;
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_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;
                 else                  else
                         p->offset += width;                          p->offset += width;
                 break;                  break;
         case (MDOC_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.
                  */                   */
                 if (MDOC_HEAD == n->type &&                  if (MDOC_HEAD == n->type)
                                 MDOC_BODY == n->next->type &&                          break;
                                 p->rmargin < p->maxrmargin)                  if (NULL == n->next && p->rmargin < p->maxrmargin)
                         p->rmargin = p->maxrmargin;                          p->rmargin = p->maxrmargin;
                 break;                  break;
         default:          default:
Line 951  termp_it_pre(DECL_ARGS)
Line 954  termp_it_pre(DECL_ARGS)
   
         if (MDOC_HEAD == n->type)          if (MDOC_HEAD == n->type)
                 switch (type) {                  switch (type) {
                 case (MDOC_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 (MDOC_Dash):                  case (LIST_dash):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_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 (MDOC_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);
Line 978  termp_it_pre(DECL_ARGS)
Line 981  termp_it_pre(DECL_ARGS)
          */           */
   
         switch (type) {          switch (type) {
         case (MDOC_Bullet):          case (LIST_bullet):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Enum):          case (LIST_enum):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
         default:          default:
Line 1006  termp_it_pre(DECL_ARGS)
Line 1009  termp_it_pre(DECL_ARGS)
 static void  static void
 termp_it_post(DECL_ARGS)  termp_it_post(DECL_ARGS)
 {  {
         int                type;          enum mdoc_list     type;
   
         if (MDOC_BLOCK == n->type)          if (MDOC_BLOCK == n->type)
                 return;                  return;
   
         type = arg_listtype(n->parent->parent->parent);          type = n->parent->parent->parent->data.list;
         assert(-1 != type);  
   
         switch (type) {          switch (type) {
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Diag):          case (LIST_diag):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Inset):          case (LIST_inset):
                 if (MDOC_BODY == n->type)                  if (MDOC_BODY == n->type)
                         term_flushln(p);                          term_newln(p);
                 break;                  break;
         case (MDOC_Column):          case (LIST_column):
                 if (MDOC_HEAD == n->type)                  if (MDOC_BODY == n->type)
                         term_flushln(p);                          term_flushln(p);
                 break;                  break;
         default:          default:
                 term_flushln(p);                  term_newln(p);
                 break;                  break;
         }          }
   
Line 1051  static int
Line 1053  static int
 termp_nm_pre(DECL_ARGS)  termp_nm_pre(DECL_ARGS)
 {  {
   
         if (SEC_SYNOPSIS == n->sec)          if (NULL == n->child && NULL == m->name)
                   return(1);
   
           if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
                 term_newln(p);                  term_newln(p);
   
         term_fontpush(p, TERMFONT_BOLD);          term_fontpush(p, TERMFONT_BOLD);
   
         if (NULL == n->child)          if (NULL == n->child)
                 term_word(p, m->name);                  term_word(p, m->name);
   
         return(1);          return(1);
 }  }
   
Line 1070  termp_fl_pre(DECL_ARGS)
Line 1076  termp_fl_pre(DECL_ARGS)
         term_fontpush(p, TERMFONT_BOLD);          term_fontpush(p, TERMFONT_BOLD);
         term_word(p, "\\-");          term_word(p, "\\-");
   
         /* A blank `Fl' should incur a subsequent space. */  
   
         if (n->child)          if (n->child)
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
           else if (n->next && n->next->line == n->line)
                   p->flags |= TERMP_NOSPACE;
   
         return(1);          return(1);
 }  }
Line 1126  termp_an_post(DECL_ARGS)
Line 1132  termp_an_post(DECL_ARGS)
                 return;                  return;
         }          }
   
         if (arg_getattr(MDOC_Split, n) > -1) {          if (arg_hasattr(MDOC_Split, n)) {
                 p->flags &= ~TERMP_NOSPLIT;                  p->flags &= ~TERMP_NOSPLIT;
                 p->flags |= TERMP_SPLIT;                  p->flags |= TERMP_SPLIT;
         } else {          } else {
Line 1182  termp_rv_pre(DECL_ARGS)
Line 1188  termp_rv_pre(DECL_ARGS)
                         term_word(p, "()");                          term_word(p, "()");
         }          }
   
         if (n->child->next)          if (n->child && n->child->next)
                 term_word(p, "functions return");                  term_word(p, "functions return");
         else          else
                 term_word(p, "function returns");                  term_word(p, "function returns");
Line 1195  termp_rv_pre(DECL_ARGS)
Line 1201  termp_rv_pre(DECL_ARGS)
         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;
   
         return(0);          return(0);
 }  }
Line 1221  termp_ex_pre(DECL_ARGS)
Line 1228  termp_ex_pre(DECL_ARGS)
                         p->flags &= ~TERMP_NOSPACE;                          p->flags &= ~TERMP_NOSPACE;
         }          }
   
         if (n->child->next)          if (n->child && n->child->next)
                 term_word(p, "utilities exit");                  term_word(p, "utilities exit");
         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;
   
         return(0);          return(0);
 }  }
Line 1250  termp_nd_pre(DECL_ARGS)
Line 1258  termp_nd_pre(DECL_ARGS)
   
   
 /* ARGSUSED */  /* ARGSUSED */
   static int
   termp_bl_pre(DECL_ARGS)
   {
   
           return(MDOC_HEAD != n->type);
   }
   
   
   /* ARGSUSED */
 static void  static void
 termp_bl_post(DECL_ARGS)  termp_bl_post(DECL_ARGS)
 {  {
Line 1277  termp_xr_pre(DECL_ARGS)
Line 1294  termp_xr_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *nn;          const struct mdoc_node *nn;
   
         assert(n->child && MDOC_TEXT == n->child->type);          if (NULL == n->child)
                   return(0);
   
           assert(MDOC_TEXT == n->child->type);
         nn = n->child;          nn = n->child;
   
         term_word(p, nn->string);          term_word(p, nn->string);
Line 1338  static void
Line 1358  static void
 termp_fd_post(DECL_ARGS)  termp_fd_post(DECL_ARGS)
 {  {
   
         if (n->sec != SEC_SYNOPSIS)          if (n->sec != SEC_SYNOPSIS || ! (MDOC_LINE & n->flags))
                 return;                  return;
   
         term_newln(p);          term_newln(p);
Line 1416  termp_bt_pre(DECL_ARGS)
Line 1436  termp_bt_pre(DECL_ARGS)
 {  {
   
         term_word(p, "is currently in beta test.");          term_word(p, "is currently in beta test.");
           p->flags |= TERMP_SENTENCE;
         return(0);          return(0);
 }  }
   
Line 1425  static void
Line 1446  static void
 termp_lb_post(DECL_ARGS)  termp_lb_post(DECL_ARGS)
 {  {
   
         if (SEC_LIBRARY == n->sec)          if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
                 term_newln(p);                  term_newln(p);
 }  }
   
Line 1436  termp_ud_pre(DECL_ARGS)
Line 1457  termp_ud_pre(DECL_ARGS)
 {  {
   
         term_word(p, "currently under development.");          term_word(p, "currently under development.");
           p->flags |= TERMP_SENTENCE;
         return(0);          return(0);
 }  }
   
Line 1494  static int
Line 1516  static int
 termp_ft_pre(DECL_ARGS)  termp_ft_pre(DECL_ARGS)
 {  {
   
         if (SEC_SYNOPSIS == n->sec)          if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
                 if (n->prev && MDOC_Fo == n->prev->tok)                  if (n->prev && MDOC_Fo == n->prev->tok)
                         term_vspace(p);                          term_vspace(p);
   
Line 1508  static void
Line 1530  static void
 termp_ft_post(DECL_ARGS)  termp_ft_post(DECL_ARGS)
 {  {
   
         if (SEC_SYNOPSIS == n->sec)          if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
                 term_newln(p);                  term_newln(p);
 }  }
   
Line 1549  static void
Line 1571  static void
 termp_fn_post(DECL_ARGS)  termp_fn_post(DECL_ARGS)
 {  {
   
         if (n->sec == SEC_SYNOPSIS && n->next)          if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags)
                 term_vspace(p);                  term_vspace(p);
 }  }
   
Line 1585  termp_fa_pre(DECL_ARGS)
Line 1607  termp_fa_pre(DECL_ARGS)
 static int  static int
 termp_bd_pre(DECL_ARGS)  termp_bd_pre(DECL_ARGS)
 {  {
           size_t                   tabwidth;
         int                      i, type;          int                      i, type;
           size_t                   rm, rmax;
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
                 print_bvspace(p, n, n);                  print_bvspace(p, n, n);
                 return(1);                  return(1);
         } else if (MDOC_BODY != n->type)          } else if (MDOC_HEAD == n->type)
                 return(1);                  return(0);
   
         nn = n->parent;          nn = n->parent;
   
         for (type = -1, i = 0; i < (int)nn->args->argc; i++) {          type = arg_disptype(nn);
                 switch (nn->args->argv[i].arg) {          assert(-1 != type);
                 case (MDOC_Centred):  
                         /* FALLTHROUGH */  
                 case (MDOC_Ragged):  
                         /* FALLTHROUGH */  
                 case (MDOC_Filled):  
                         /* FALLTHROUGH */  
                 case (MDOC_Unfilled):  
                         /* FALLTHROUGH */  
                 case (MDOC_Literal):  
                         type = nn->args->argv[i].arg;  
                         break;  
                 case (MDOC_Offset):  
                         p->offset += a2offs(&nn->args->argv[i]);  
                         break;  
                 default:  
                         break;  
                 }  
         }  
   
           if (-1 != (i = arg_getattr(MDOC_Offset, nn)))
                   p->offset += a2offs(&nn->args->argv[i]);
   
         /*          /*
          * If -ragged or -filled are specified, the block does nothing           * If -ragged or -filled are specified, the block does nothing
          * but change the indentation.  If -unfilled or -literal are           * but change the indentation.  If -unfilled or -literal are
Line 1625  termp_bd_pre(DECL_ARGS)
Line 1634  termp_bd_pre(DECL_ARGS)
          * lines are allowed.           * lines are allowed.
          */           */
   
         assert(type > -1);  
         if (MDOC_Literal != type && MDOC_Unfilled != type)          if (MDOC_Literal != type && MDOC_Unfilled != type)
                 return(1);                  return(1);
   
           tabwidth = p->tabwidth;
           p->tabwidth = 8;
           rm = p->rmargin;
           rmax = p->maxrmargin;
           p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 print_mdoc_node(p, pair, m, nn);                  print_mdoc_node(p, pair, m, nn);
                 if (NULL == nn->next)                  if (NULL == nn->prev ||
                         continue;                      nn->prev->line < nn->line ||
                 if (nn->prev && nn->prev->line < nn->line)                      NULL == nn->next)
                         term_flushln(p);                          term_flushln(p);
                 else if (NULL == nn->prev)  
                         term_flushln(p);  
         }          }
           p->tabwidth = tabwidth;
   
           p->rmargin = rm;
           p->maxrmargin = rmax;
         return(0);          return(0);
 }  }
   
Line 1648  termp_bd_pre(DECL_ARGS)
Line 1663  termp_bd_pre(DECL_ARGS)
 static void  static void
 termp_bd_post(DECL_ARGS)  termp_bd_post(DECL_ARGS)
 {  {
           int              type;
           size_t           rm, rmax;
   
         if (MDOC_BODY != n->type)          if (MDOC_BODY != n->type)
                 return;                  return;
   
           type = arg_disptype(n->parent);
           assert(-1 != type);
   
           rm = p->rmargin;
           rmax = p->maxrmargin;
   
           if (MDOC_Literal == type || MDOC_Unfilled == type)
                   p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_flushln(p);          term_newln(p);
   
           p->rmargin = rm;
           p->maxrmargin = rmax;
 }  }
   
   
Line 1842  termp_in_post(DECL_ARGS)
Line 1872  termp_in_post(DECL_ARGS)
         term_word(p, ">");          term_word(p, ">");
         term_fontpop(p);          term_fontpop(p);
   
         if (SEC_SYNOPSIS != n->sec)          if (SEC_SYNOPSIS != n->sec && ! (MDOC_LINE & n->flags))
                 return;                  return;
   
         term_newln(p);          term_newln(p);
Line 2067  termp____post(DECL_ARGS)
Line 2097  termp____post(DECL_ARGS)
         /* TODO: %U. */          /* TODO: %U. */
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         switch (n->tok) {  
         case (MDOC__T):  
                 term_word(p, "\\(rq");  
                 p->flags |= TERMP_NOSPACE;  
                 break;  
         default:  
                 break;  
         }  
         term_word(p, n->next ? "," : ".");          term_word(p, n->next ? "," : ".");
 }  }
   
Line 2122  termp_under_pre(DECL_ARGS)
Line 2144  termp_under_pre(DECL_ARGS)
 {  {
   
         term_fontpush(p, TERMFONT_UNDER);          term_fontpush(p, TERMFONT_UNDER);
         return(1);  
 }  
   
   
 /* ARGSUSED */  
 static int  
 termp__t_pre(DECL_ARGS)  
 {  
   
         term_word(p, "\\(lq");  
         p->flags |= TERMP_NOSPACE;  
         return(1);          return(1);
 }  }

Legend:
Removed from v.1.112  
changed lines
  Added in v.1.135

CVSweb