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

Diff for /mandoc/mdoc_man.c between version 1.21 and 1.25

version 1.21, 2012/07/08 15:48:13 version 1.25, 2012/07/09 09:31:48
Line 56  static void   post_pf(DECL_ARGS);
Line 56  static void   post_pf(DECL_ARGS);
 static  void      post_sect(DECL_ARGS);  static  void      post_sect(DECL_ARGS);
 static  void      post_sp(DECL_ARGS);  static  void      post_sp(DECL_ARGS);
 static  void      post_vt(DECL_ARGS);  static  void      post_vt(DECL_ARGS);
   static  int       pre_an(DECL_ARGS);
 static  int       pre_ap(DECL_ARGS);  static  int       pre_ap(DECL_ARGS);
 static  int       pre_bd(DECL_ARGS);  static  int       pre_bd(DECL_ARGS);
 static  int       pre_bk(DECL_ARGS);  static  int       pre_bk(DECL_ARGS);
Line 66  static int   pre_enc(DECL_ARGS);
Line 67  static int   pre_enc(DECL_ARGS);
 static  int       pre_fa(DECL_ARGS);  static  int       pre_fa(DECL_ARGS);
 static  int       pre_fn(DECL_ARGS);  static  int       pre_fn(DECL_ARGS);
 static  int       pre_fo(DECL_ARGS);  static  int       pre_fo(DECL_ARGS);
   static  int       pre_ft(DECL_ARGS);
 static  int       pre_in(DECL_ARGS);  static  int       pre_in(DECL_ARGS);
 static  int       pre_it(DECL_ARGS);  static  int       pre_it(DECL_ARGS);
   static  int       pre_lk(DECL_ARGS);
 static  int       pre_nm(DECL_ARGS);  static  int       pre_nm(DECL_ARGS);
   static  int       pre_no(DECL_ARGS);
 static  int       pre_ns(DECL_ARGS);  static  int       pre_ns(DECL_ARGS);
 static  int       pre_pp(DECL_ARGS);  static  int       pre_pp(DECL_ARGS);
 static  int       pre_sm(DECL_ARGS);  static  int       pre_sm(DECL_ARGS);
 static  int       pre_sp(DECL_ARGS);  static  int       pre_sp(DECL_ARGS);
 static  int       pre_sect(DECL_ARGS);  static  int       pre_sect(DECL_ARGS);
   static  void      pre_syn(const struct mdoc_node *);
 static  int       pre_vt(DECL_ARGS);  static  int       pre_vt(DECL_ARGS);
 static  int       pre_ux(DECL_ARGS);  static  int       pre_ux(DECL_ARGS);
 static  int       pre_xr(DECL_ARGS);  static  int       pre_xr(DECL_ARGS);
Line 97  static const struct manact manacts[MDOC_MAX + 1] = {
Line 102  static const struct manact manacts[MDOC_MAX + 1] = {
         { NULL, NULL, NULL, NULL, NULL }, /* El */          { NULL, NULL, NULL, NULL, NULL }, /* El */
         { NULL, pre_it, NULL, NULL, NULL }, /* _It */          { NULL, pre_it, NULL, NULL, NULL }, /* _It */
         { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ad */          { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ad */
         { NULL, NULL, NULL, NULL, NULL }, /* _An */          { NULL, pre_an, NULL, NULL, NULL }, /* An */
         { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ar */          { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ar */
         { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Cd */          { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Cd */
         { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Cm */          { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Cm */
Line 111  static const struct manact manacts[MDOC_MAX + 1] = {
Line 116  static const struct manact manacts[MDOC_MAX + 1] = {
         { NULL, NULL, NULL, NULL, NULL }, /* _Fd */          { NULL, NULL, NULL, NULL, NULL }, /* _Fd */
         { NULL, pre_enc, post_enc, "\\fB-", "\\fP" }, /* Fl */          { NULL, pre_enc, post_enc, "\\fB-", "\\fP" }, /* Fl */
         { NULL, pre_fn, post_fn, NULL, NULL }, /* Fn */          { NULL, pre_fn, post_fn, NULL, NULL }, /* Fn */
         { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Ft */          { NULL, pre_ft, post_enc, NULL, "\\fP" }, /* Ft */
         { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Ic */          { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Ic */
         { NULL, pre_in, post_in, NULL, NULL }, /* In */          { NULL, pre_in, post_in, NULL, NULL }, /* In */
         { NULL, pre_enc, post_enc, "\\fR", "\\fP" }, /* Li */          { NULL, pre_enc, post_enc, "\\fR", "\\fP" }, /* Li */
Line 160  static const struct manact manacts[MDOC_MAX + 1] = {
Line 165  static const struct manact manacts[MDOC_MAX + 1] = {
         { NULL, NULL, NULL, NULL, NULL }, /* _Eo */          { NULL, NULL, NULL, NULL, NULL }, /* _Eo */
         { NULL, pre_ux, NULL, "FreeBSD", NULL }, /* Fx */          { NULL, pre_ux, NULL, "FreeBSD", NULL }, /* Fx */
         { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Ms */          { NULL, pre_enc, post_enc, "\\fB", "\\fP" }, /* Ms */
         { NULL, NULL, NULL, NULL, NULL }, /* No */          { NULL, pre_no, NULL, NULL, NULL }, /* No */
         { NULL, pre_ns, NULL, NULL, NULL }, /* Ns */          { NULL, pre_ns, NULL, NULL, NULL }, /* Ns */
         { NULL, pre_ux, NULL, "NetBSD", NULL }, /* Nx */          { NULL, pre_ux, NULL, "NetBSD", NULL }, /* Nx */
         { NULL, pre_ux, NULL, "OpenBSD", NULL }, /* Ox */          { NULL, pre_ux, NULL, "OpenBSD", NULL }, /* Ox */
Line 196  static const struct manact manacts[MDOC_MAX + 1] = {
Line 201  static const struct manact manacts[MDOC_MAX + 1] = {
         { NULL, pre_ux, NULL, "currently under development.", NULL }, /* Ud */          { NULL, pre_ux, NULL, "currently under development.", NULL }, /* Ud */
         { NULL, NULL, post_lb, NULL, NULL }, /* Lb */          { NULL, NULL, post_lb, NULL, NULL }, /* Lb */
         { NULL, pre_pp, NULL, NULL, NULL }, /* Lp */          { NULL, pre_pp, NULL, NULL, NULL }, /* Lp */
         { NULL, NULL, NULL, NULL, NULL }, /* _Lk */          { NULL, pre_lk, NULL, NULL, NULL }, /* Lk */
         { NULL, NULL, NULL, NULL, NULL }, /* _Mt */          { NULL, pre_enc, post_enc, "\\fI", "\\fP" }, /* Mt */
         { cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */          { cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */
         { cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */          { cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */
         { NULL, NULL, NULL, NULL, NULL }, /* Brc */          { NULL, NULL, NULL, NULL, NULL }, /* Brc */
Line 215  static const struct manact manacts[MDOC_MAX + 1] = {
Line 220  static const struct manact manacts[MDOC_MAX + 1] = {
   
 static  int             outflags;  static  int             outflags;
 #define MMAN_spc        (1 << 0)  #define MMAN_spc        (1 << 0)
 #define MMAN_nl         (1 << 1)  #define MMAN_spc_force  (1 << 1)
 #define MMAN_br         (1 << 2)  #define MMAN_nl         (1 << 2)
 #define MMAN_sp         (1 << 3)  #define MMAN_br         (1 << 3)
 #define MMAN_Sm         (1 << 4)  #define MMAN_sp         (1 << 4)
 #define MMAN_Bk         (1 << 5)  #define MMAN_Sm         (1 << 5)
   #define MMAN_Bk         (1 << 6)
   #define MMAN_An_split   (1 << 7)
   #define MMAN_An_nosplit (1 << 8)
   
 static void  static void
 print_word(const char *s)  print_word(const char *s)
Line 238  print_word(const char *s)
Line 246  print_word(const char *s)
                 outflags &= ~(MMAN_sp|MMAN_br|MMAN_nl|MMAN_spc);                  outflags &= ~(MMAN_sp|MMAN_br|MMAN_nl|MMAN_spc);
         } else if (MMAN_spc & outflags && '\0' != s[0])          } else if (MMAN_spc & outflags && '\0' != s[0])
                 /*                  /*
                  * If we need a space, only print it before                   * If we need a space, only print it if
                  * (1) a nonzero length word;                   * (1) it is forced by `No' or
                  * (2) a word that is non-punctuation; and                   * (2) what follows is not terminating punctuation or
                  * (3) if punctuation, non-terminating puncutation.                   * (3) what follows is longer than one character.
                  */                   */
                 if (NULL == strchr(".,:;)]?!", s[0]) || '\0' != s[1]) {                  if (MMAN_spc_force & outflags ||
                       NULL == strchr(".,:;)]?!", s[0]) || '\0' != s[1]) {
                         if (MMAN_Bk & outflags) {                          if (MMAN_Bk & outflags) {
                                 putchar('\\');                                  putchar('\\');
                                 putchar('~');                                  putchar('~');
Line 260  print_word(const char *s)
Line 269  print_word(const char *s)
                 outflags |= MMAN_spc;                  outflags |= MMAN_spc;
         else          else
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
           outflags &= ~MMAN_spc_force;
   
         for ( ; *s; s++) {          for ( ; *s; s++) {
                 switch (*s) {                  switch (*s) {
Line 481  post_sect(DECL_ARGS)
Line 491  post_sect(DECL_ARGS)
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("\"");          print_word("\"");
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
           if (MDOC_Sh == n->tok && SEC_AUTHORS == n->sec)
                   outflags &= ~(MMAN_An_split | MMAN_An_nosplit);
 }  }
   
   /* See mdoc_term.c, synopsis_pre() for comments. */
   static void
   pre_syn(const struct mdoc_node *n)
   {
   
           if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
                   return;
   
           if (n->prev->tok == n->tok &&
                           MDOC_Ft != n->tok &&
                           MDOC_Fo != n->tok &&
                           MDOC_Fn != n->tok) {
                   outflags |= MMAN_br;
                   return;
           }
   
           switch (n->prev->tok) {
           case (MDOC_Fd):
                   /* FALLTHROUGH */
           case (MDOC_Fn):
                   /* FALLTHROUGH */
           case (MDOC_Fo):
                   /* FALLTHROUGH */
           case (MDOC_In):
                   /* FALLTHROUGH */
           case (MDOC_Vt):
                   outflags |= MMAN_sp;
                   break;
           case (MDOC_Ft):
                   if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
                           outflags |= MMAN_sp;
                           break;
                   }
                   /* FALLTHROUGH */
           default:
                   outflags |= MMAN_br;
                   break;
           }
   }
   
 static int  static int
   pre_an(DECL_ARGS)
   {
   
           switch (n->norm->An.auth) {
           case (AUTH_split):
                   outflags &= ~MMAN_An_nosplit;
                   outflags |= MMAN_An_split;
                   return(0);
           case (AUTH_nosplit):
                   outflags &= ~MMAN_An_split;
                   outflags |= MMAN_An_nosplit;
                   return(0);
           default:
                   if (MMAN_An_split & outflags)
                           outflags |= MMAN_br;
                   else if (SEC_AUTHORS == n->sec &&
                       ! (MMAN_An_nosplit & outflags))
                           outflags |= MMAN_An_split;
                   return(1);
           }
   }
   
   static int
 pre_ap(DECL_ARGS)  pre_ap(DECL_ARGS)
 {  {
   
Line 626  static int
Line 701  static int
 pre_fn(DECL_ARGS)  pre_fn(DECL_ARGS)
 {  {
   
           pre_syn(n);
   
         n = n->child;          n = n->child;
         if (NULL == n)          if (NULL == n)
                 return(0);                  return(0);
   
         if (MDOC_SYNPRETTY & n->flags)  
                 outflags |= MMAN_br;  
         print_word("\\fB");          print_word("\\fB");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_node(m, n);          print_node(m, n);
Line 657  pre_fo(DECL_ARGS)
Line 732  pre_fo(DECL_ARGS)
 {  {
   
         switch (n->type) {          switch (n->type) {
           case (MDOC_BLOCK):
                   pre_syn(n);
                   break;
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 if (MDOC_SYNPRETTY & n->flags)  
                         outflags |= MMAN_br;  
                 print_word("\\fB");                  print_word("\\fB");
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
                 break;                  break;
Line 692  post_fo(DECL_ARGS)
Line 768  post_fo(DECL_ARGS)
 }  }
   
 static int  static int
   pre_ft(DECL_ARGS)
   {
   
           pre_syn(n);
           print_word("\\fI");
           outflags &= ~MMAN_spc;
           return(1);
   }
   
   static int
 pre_in(DECL_ARGS)  pre_in(DECL_ARGS)
 {  {
   
         if (MDOC_SYNPRETTY & n->flags) {          if (MDOC_SYNPRETTY & n->flags) {
                 outflags |= MMAN_br;                  pre_syn(n);
                 print_word("\\fB#include <");                  print_word("\\fB#include <");
         } else          } else
                 print_word("<\\fI");                  print_word("<\\fI");
Line 750  post_lb(DECL_ARGS)
Line 836  post_lb(DECL_ARGS)
 }  }
   
 static int  static int
   pre_lk(DECL_ARGS)
   {
           const struct mdoc_node *link, *descr;
   
           if (NULL == (link = n->child))
                   return(0);
   
           if (NULL != (descr = link->next)) {
                   print_word("\\fI");
                   outflags &= ~MMAN_spc;
                   while (NULL != descr) {
                           print_word(descr->string);
                           descr = descr->next;
                   }
                   print_word(":");
                   outflags &= ~MMAN_spc;
                   print_word("\\fP");
           }
   
           print_word("\\fB");
           outflags &= ~MMAN_spc;
           print_word(link->string);
           outflags &= ~MMAN_spc;
           print_word("\\fP");
           return(0);
   }
   
   static int
 pre_nm(DECL_ARGS)  pre_nm(DECL_ARGS)
 {  {
   
           if (MDOC_BLOCK == n->type)
                   pre_syn(n);
         if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)          if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
                 return(1);                  return(1);
         if (MDOC_SYNPRETTY & n->flags)          if (NULL == n->child && NULL == m->name)
                 outflags |= MMAN_br;                  return(0);
         print_word("\\fB");          print_word("\\fB");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         if (NULL == n->child)          if (NULL == n->child)
Line 775  post_nm(DECL_ARGS)
Line 891  post_nm(DECL_ARGS)
 }  }
   
 static int  static int
   pre_no(DECL_ARGS)
   {
   
           outflags |= MMAN_spc_force;
           return(1);
   }
   
   static int
 pre_ns(DECL_ARGS)  pre_ns(DECL_ARGS)
 {  {
   
Line 837  pre_vt(DECL_ARGS)
Line 961  pre_vt(DECL_ARGS)
         if (MDOC_SYNPRETTY & n->flags) {          if (MDOC_SYNPRETTY & n->flags) {
                 switch (n->type) {                  switch (n->type) {
                 case (MDOC_BLOCK):                  case (MDOC_BLOCK):
                           pre_syn(n);
                         return(1);                          return(1);
                 case (MDOC_BODY):                  case (MDOC_BODY):
                         break;                          break;
                 default:                  default:
                         return(0);                          return(0);
                 }                  }
                 outflags |= MMAN_br;  
         }          }
         print_word("\\fI");          print_word("\\fI");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
Line 859  post_vt(DECL_ARGS)
Line 983  post_vt(DECL_ARGS)
   
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("\\fP");          print_word("\\fP");
         if (MDOC_SYNPRETTY & n->flags)  
                 outflags |= MMAN_br;  
 }  }
   
 static int  static int

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.25

CVSweb