[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.72 and 1.85

version 1.72, 2009/09/20 11:05:22 version 1.85, 2009/09/26 17:35:49
Line 106  static void   termp_sq_post(DECL_ARGS);
Line 106  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);
Line 113  static int   termp_bd_pre(DECL_ARGS);
Line 114  static int   termp_bd_pre(DECL_ARGS);
 static  int       termp_bf_pre(DECL_ARGS);  static  int       termp_bf_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_br_pre(DECL_ARGS);  
 static  int       termp_brq_pre(DECL_ARGS);  static  int       termp_brq_pre(DECL_ARGS);
 static  int       termp_bt_pre(DECL_ARGS);  static  int       termp_bt_pre(DECL_ARGS);
 static  int       termp_cd_pre(DECL_ARGS);  static  int       termp_cd_pre(DECL_ARGS);
Line 133  static int   termp_nm_pre(DECL_ARGS);
Line 133  static int   termp_nm_pre(DECL_ARGS);
 static  int       termp_ns_pre(DECL_ARGS);  static  int       termp_ns_pre(DECL_ARGS);
 static  int       termp_op_pre(DECL_ARGS);  static  int       termp_op_pre(DECL_ARGS);
 static  int       termp_pf_pre(DECL_ARGS);  static  int       termp_pf_pre(DECL_ARGS);
 static  int       termp_pp_pre(DECL_ARGS);  
 static  int       termp_pq_pre(DECL_ARGS);  static  int       termp_pq_pre(DECL_ARGS);
 static  int       termp_qq_pre(DECL_ARGS);  static  int       termp_qq_pre(DECL_ARGS);
 static  int       termp_rs_pre(DECL_ARGS);  static  int       termp_rs_pre(DECL_ARGS);
Line 155  static const struct termact termacts[MDOC_MAX] = {
Line 154  static const struct termact termacts[MDOC_MAX] = {
         { 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_pp_pre, NULL }, /* Pp */          { termp_sp_pre, NULL }, /* Pp */
         { termp_d1_pre, termp_d1_post }, /* D1 */          { termp_d1_pre, termp_d1_post }, /* D1 */
         { 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 */
Line 191  static const struct termact termacts[MDOC_MAX] = {
Line 190  static const struct termact termacts[MDOC_MAX] = {
         { termp_under_pre, termp_vt_post }, /* Vt */          { termp_under_pre, termp_vt_post }, /* Vt */
         { termp_xr_pre, NULL }, /* Xr */          { termp_xr_pre, NULL }, /* Xr */
         { NULL, termp____post }, /* %A */          { NULL, termp____post }, /* %A */
         { NULL, termp____post }, /* %B */          { termp_under_pre, termp____post }, /* %B */
         { NULL, termp____post }, /* %D */          { NULL, termp____post }, /* %D */
         { NULL, termp____post }, /* %I */          { termp_under_pre, termp____post }, /* %I */
         { termp_under_pre, termp____post }, /* %J */          { termp_under_pre, termp____post }, /* %J */
         { NULL, termp____post }, /* %N */          { NULL, termp____post }, /* %N */
         { 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_under_pre, termp____post }, /* %T */          { termp__t_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 220  static const struct termact termacts[MDOC_MAX] = {
Line 219  static const struct termact termacts[MDOC_MAX] = {
         { termp_under_pre, NULL }, /* Em */          { termp_under_pre, NULL }, /* Em */
         { NULL, NULL }, /* Eo */          { NULL, NULL }, /* Eo */
         { termp_xx_pre, NULL }, /* Fx */          { termp_xx_pre, NULL }, /* Fx */
         { termp_bold_pre, NULL }, /* Ms */          { termp_bold_pre, NULL }, /* Ms */ /* FIXME: convert to symbol? */
         { NULL, NULL }, /* No */          { NULL, NULL }, /* No */
         { termp_ns_pre, NULL }, /* Ns */          { termp_ns_pre, NULL }, /* Ns */
         { termp_xx_pre, NULL }, /* Nx */          { termp_xx_pre, NULL }, /* Nx */
Line 256  static const struct termact termacts[MDOC_MAX] = {
Line 255  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_pp_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_brq_pre, termp_brq_post }, /* Brq */          { termp_brq_pre, termp_brq_post }, /* Brq */
         { termp_brq_pre, termp_brq_post }, /* Bro */          { termp_brq_pre, termp_brq_post }, /* Bro */
         { NULL, NULL }, /* Brc */          { NULL, NULL }, /* Brc */
         { NULL, NULL }, /* %C */          { NULL, termp____post }, /* %C */
         { NULL, NULL }, /* Es */          { NULL, NULL }, /* Es */ /* TODO */
         { NULL, NULL }, /* En */          { NULL, NULL }, /* En */ /* TODO */
         { termp_xx_pre, NULL }, /* Dx */          { termp_xx_pre, NULL }, /* Dx */
         { NULL, NULL }, /* %Q */          { NULL, termp____post }, /* %Q */
         { termp_br_pre, NULL }, /* br */          { termp_sp_pre, NULL }, /* br */
         { termp_sp_pre, NULL }, /* sp */          { termp_sp_pre, NULL }, /* sp */
 };  };
   
Line 424  print_foot(DECL_ARGS)
Line 423  print_foot(DECL_ARGS)
 }  }
   
   
   /* FIXME: put in utility library. */
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
 print_head(DECL_ARGS)  print_head(DECL_ARGS)
Line 520  arg_width(const struct mdoc_argv *arg, int pos)
Line 520  arg_width(const struct mdoc_argv *arg, int pos)
 }  }
   
   
   /* FIXME: put in utility file for front-ends. */
 static int  static int
 arg_listtype(const struct mdoc_node *n)  arg_listtype(const struct mdoc_node *n)
 {  {
Line 638  fmt_block_vspace(struct termp *p, 
Line 639  fmt_block_vspace(struct termp *p, 
         const struct mdoc_node *n;          const struct mdoc_node *n;
   
         term_newln(p);          term_newln(p);
           if (arg_hasattr(MDOC_Compact, bl))
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Compact, bl))  
                 return;                  return;
         assert(node);  
   
         /*          /* Do not vspace directly after Ss/Sh. */
          * Search through our prior nodes.  If we follow a `Ss' or `Sh',  
          * then don't vspace.  
          */  
   
         for (n = node; n; n = n->parent) {          for (n = node; n; n = n->parent) {
                 if (MDOC_BLOCK != n->type)                  if (MDOC_BLOCK != n->type)
Line 660  fmt_block_vspace(struct termp *p, 
Line 656  fmt_block_vspace(struct termp *p, 
                 break;                  break;
         }          }
   
         /*          /* A `-column' does not assert vspace within the list. */
          * XXX - not documented: a `-column' does not ever assert vspace  
          * within the list.  
          */  
   
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))          if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))
                 if (node->prev && MDOC_It == node->prev->tok)                  if (node->prev && MDOC_It == node->prev->tok)
                         return;                          return;
   
         /*          /* A `-diag' without body does not vspace. */
          * XXX - not documented: a `-diag' without a body does not  
          * assert a vspace prior to the next element.  
          */  
         if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl))          if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl))
                 if (node->prev && MDOC_It == node->prev->tok) {                  if (node->prev && MDOC_It == node->prev->tok) {
                         assert(node->prev->body);                          assert(node->prev->body);
Line 761  termp_it_pre(DECL_ARGS)
Line 752  termp_it_pre(DECL_ARGS)
                  * the 0 will be adjusted to default 10 or, if in the                   * the 0 will be adjusted to default 10 or, if in the
                  * last column case, set to stretch to the margin).                   * last column case, set to stretch to the margin).
                  */                   */
                 for (i = 0, n = node->prev; n && n &&                  for (i = 0, n = node->prev; n &&
                                 i < (int)bl->args[vals[2]].argv->sz;                                  i < (int)bl->args->argv[vals[2]].sz;
                                 n = n->prev, i++)                                  n = n->prev, i++)
                         offset += arg_width                          offset += arg_width
                                 (&bl->args->argv[vals[2]], i);                                  (&bl->args->argv[vals[2]], i);
   
                 /* Whether exceeds maximum column. */                  /* Whether exceeds maximum column. */
                 if (i < (int)bl->args[vals[2]].argv->sz)                  if (i < (int)bl->args->argv[vals[2]].sz)
                         width = arg_width(&bl->args->argv[vals[2]], i);                          width = arg_width(&bl->args->argv[vals[2]], i);
                 else                  else
                         width = 0;                          width = 0;
Line 1099  termp_an_pre(DECL_ARGS)
Line 1090  termp_an_pre(DECL_ARGS)
                 return(1);                  return(1);
   
         /*          /*
          * XXX: this is poorly documented.  If not in the AUTHORS           * If not in the AUTHORS section, `An -split' will cause
          * section, `An -split' will cause newlines to occur before the           * newlines to occur before the author name.  If in the AUTHORS
          * author name.  If in the AUTHORS section, by default, the           * section, by default, the first `An' invocation is nosplit,
          * first `An' invocation is nosplit, then all subsequent ones,           * then all subsequent ones, regardless of whether interspersed
          * regardless of whether interspersed with other macros/text,           * with other macros/text, are split.  -split, in this case,
          * are split.  -split, in this case, will override the condition           * will override the condition of the implied first -nosplit.
          * of the implied first -nosplit.  
          */           */
   
         if (node->sec == SEC_AUTHORS) {          if (node->sec == SEC_AUTHORS) {
Line 1161  termp_ns_pre(DECL_ARGS)
Line 1151  termp_ns_pre(DECL_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 termp_pp_pre(DECL_ARGS)  
 {  
   
         term_vspace(p);  
         return(1);  
 }  
   
   
 /* ARGSUSED */  
 static int  
 termp_rs_pre(DECL_ARGS)  termp_rs_pre(DECL_ARGS)
 {  {
   
           if (SEC_SEE_ALSO != node->sec)
                   return(1);
         if (MDOC_BLOCK == node->type && node->prev)          if (MDOC_BLOCK == node->type && node->prev)
                 term_vspace(p);                  term_vspace(p);
         return(1);          return(1);
Line 1359  termp_fd_post(DECL_ARGS)
Line 1341  termp_fd_post(DECL_ARGS)
 static int  static int
 termp_sh_pre(DECL_ARGS)  termp_sh_pre(DECL_ARGS)
 {  {
         /*  
          * XXX: undocumented: using two `Sh' macros in sequence has no          /* No vspace between consecutive `Sh' calls. */
          * vspace between calls, only a newline.  
          */  
         switch (node->type) {          switch (node->type) {
         case (MDOC_BLOCK):          case (MDOC_BLOCK):
                 if (node->prev && MDOC_Sh == node->prev->tok)                  if (node->prev && MDOC_Sh == node->prev->tok)
Line 1425  termp_bt_pre(DECL_ARGS)
Line 1406  termp_bt_pre(DECL_ARGS)
 {  {
   
         term_word(p, "is currently in beta test.");          term_word(p, "is currently in beta test.");
         return(1);          return(0);
 }  }
   
   
Line 1434  static void
Line 1415  static void
 termp_lb_post(DECL_ARGS)  termp_lb_post(DECL_ARGS)
 {  {
   
         term_newln(p);          if (SEC_LIBRARY == node->sec)
                   term_newln(p);
 }  }
   
   
Line 1526  termp_fn_pre(DECL_ARGS)
Line 1508  termp_fn_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *n;          const struct mdoc_node *n;
   
         assert(node->child && MDOC_TEXT == node->child->type);  
   
         /* FIXME: can be "type funcname" "type varname"... */  
   
         p->bold++;          p->bold++;
         term_word(p, node->child->string);          term_word(p, node->child->string);
         p->bold--;          p->bold--;
Line 1594  termp_fa_pre(DECL_ARGS)
Line 1572  termp_fa_pre(DECL_ARGS)
 static int  static int
 termp_bd_pre(DECL_ARGS)  termp_bd_pre(DECL_ARGS)
 {  {
         int              i, type;          int                      i, type;
           const struct mdoc_node  *nn;
   
         /*  
          * This is fairly tricky due primarily to crappy documentation.  
          * If -ragged or -filled are specified, the block does nothing  
          * but change the indentation.  
          *  
          * If, on the other hand, -unfilled or -literal are specified,  
          * then the game changes.  Text is printed exactly as entered in  
          * the display: if a macro line, a newline is appended to the  
          * line.  Blank lines are allowed.  
          */  
   
         if (MDOC_BLOCK == node->type) {          if (MDOC_BLOCK == node->type) {
                 fmt_block_vspace(p, node, node);                  fmt_block_vspace(p, node, node);
                 return(1);                  return(1);
         } else if (MDOC_BODY != node->type)          } else if (MDOC_BODY != node->type)
                 return(1);                  return(1);
   
         assert(node->parent->args);          nn = node->parent;
   
         for (type = -1, i = 0; -1 == type &&          for (type = -1, i = 0; i < (int)nn->args->argc; i++) {
                         i < (int)node->parent->args->argc; i++) {                  switch (nn->args->argv[i].arg) {
                 switch (node->parent->args->argv[i].arg) {  
                 case (MDOC_Ragged):                  case (MDOC_Ragged):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Filled):                  case (MDOC_Filled):
Line 1625  termp_bd_pre(DECL_ARGS)
Line 1592  termp_bd_pre(DECL_ARGS)
                 case (MDOC_Unfilled):                  case (MDOC_Unfilled):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Literal):                  case (MDOC_Literal):
                         type = node->parent->args->argv[i].arg;                          type = nn->args->argv[i].arg;
                         break;                          break;
                   case (MDOC_Offset):
                           p->offset += arg_offset(&nn->args->argv[i]);
                           break;
                 default:                  default:
                         break;                          break;
                 }                  }
         }          }
   
           /*
            * If -ragged or -filled are specified, the block does nothing
            * but change the indentation.  If -unfilled or -literal are
            * specified, text is printed exactly as entered in the display:
            * for macro lines, a newline is appended to the line.  Blank
            * lines are allowed.
            */
   
         assert(type > -1);          assert(type > -1);
           if (MDOC_Literal != type && MDOC_Unfilled != type)
         i = arg_getattr(MDOC_Offset, node->parent);  
         if (-1 != i)  
                 p->offset += arg_offset(&node->parent->args->argv[i]);  
   
         switch (type) {  
         case (MDOC_Literal):  
                 /* FALLTHROUGH */  
         case (MDOC_Unfilled):  
                 break;  
         default:  
                 return(1);                  return(1);
         }  
   
         for (node = node->child; node; node = node->next) {          for (nn = node->child; nn; nn = nn->next) {
                 p->flags |= TERMP_NOSPACE;                  print_node(p, pair, meta, nn);
                 print_node(p, pair, meta, node);                  if (NULL == nn->next)
                 if (node->next)                          continue;
                   if (nn->prev && nn->prev->line < nn->line)
                         term_flushln(p);                          term_flushln(p);
         }          }
   
Line 1852  termp_in_post(DECL_ARGS)
Line 1820  termp_in_post(DECL_ARGS)
 {  {
   
         p->bold++;          p->bold++;
           p->flags |= TERMP_NOSPACE;
         term_word(p, ">");          term_word(p, ">");
         p->bold--;          p->bold--;
   
Line 1876  termp_sp_pre(DECL_ARGS)
Line 1845  termp_sp_pre(DECL_ARGS)
 {  {
         int              i, len;          int              i, len;
   
         if (NULL == node->child) {          switch (node->tok) {
                 term_vspace(p);          case (MDOC_sp):
                 return(0);                  len = node->child ? atoi(node->child->string) : 1;
                   break;
           case (MDOC_br):
                   len = 0;
                   break;
           default:
                   len = 1;
                   break;
         }          }
   
         len = atoi(node->child->string);  
         if (0 == len)          if (0 == len)
                 term_newln(p);                  term_newln(p);
         for (i = 0; i < len; i++)          for (i = 0; i < len; i++)
Line 1893  termp_sp_pre(DECL_ARGS)
Line 1868  termp_sp_pre(DECL_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 termp_br_pre(DECL_ARGS)  
 {  
   
         term_newln(p);  
         return(1);  
 }  
   
   
 /* ARGSUSED */  
 static int  
 termp_brq_pre(DECL_ARGS)  termp_brq_pre(DECL_ARGS)
 {  {
   
Line 2079  termp____post(DECL_ARGS)
Line 2044  termp____post(DECL_ARGS)
 {  {
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
           switch (node->tok) {
           case (MDOC__T):
                   term_word(p, "\\(rq");
                   p->flags |= TERMP_NOSPACE;
                   break;
           default:
                   break;
           }
         term_word(p, node->next ? "," : ".");          term_word(p, node->next ? "," : ".");
 }  }
   
Line 2118  termp_under_pre(DECL_ARGS)
Line 2091  termp_under_pre(DECL_ARGS)
 {  {
   
         p->under++;          p->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.72  
changed lines
  Added in v.1.85

CVSweb