[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.126 and 1.127

version 1.126, 2018/04/11 17:11:13 version 1.127, 2018/08/17 20:33:37
Line 36 
Line 36 
 typedef int     (*int_fp)(DECL_ARGS);  typedef int     (*int_fp)(DECL_ARGS);
 typedef void    (*void_fp)(DECL_ARGS);  typedef void    (*void_fp)(DECL_ARGS);
   
 struct  manact {  struct  mdoc_man_act {
         int_fp            cond; /* DON'T run actions */          int_fp            cond; /* DON'T run actions */
         int_fp            pre; /* pre-node action */          int_fp            pre; /* pre-node action */
         void_fp           post; /* post-node action */          void_fp           post; /* post-node action */
Line 124  static void   print_width(const struct mdoc_bl *,
Line 124  static void   print_width(const struct mdoc_bl *,
 static  void      print_count(int *);  static  void      print_count(int *);
 static  void      print_node(DECL_ARGS);  static  void      print_node(DECL_ARGS);
   
 static  const void_fp roff_manacts[ROFF_MAX] = {  static const void_fp roff_man_acts[ROFF_MAX] = {
         pre_br,         /* br */          pre_br,         /* br */
         pre_onearg,     /* ce */          pre_onearg,     /* ce */
         pre_ft,         /* ft */          pre_ft,         /* ft */
Line 137  static const void_fp roff_manacts[ROFF_MAX] = {
Line 137  static const void_fp roff_manacts[ROFF_MAX] = {
         pre_onearg,     /* ti */          pre_onearg,     /* ti */
 };  };
   
 static  const struct manact __manacts[MDOC_MAX - MDOC_Dd] = {  static const struct mdoc_man_act mdoc_man_acts[MDOC_MAX - MDOC_Dd] = {
         { NULL, NULL, NULL, NULL, NULL }, /* Dd */          { NULL, NULL, NULL, NULL, NULL }, /* Dd */
         { NULL, NULL, NULL, NULL, NULL }, /* Dt */          { NULL, NULL, NULL, NULL, NULL }, /* Dt */
         { NULL, NULL, NULL, NULL, NULL }, /* Os */          { NULL, NULL, NULL, NULL, NULL }, /* Os */
Line 259  static const struct manact __manacts[MDOC_MAX - MDOC_D
Line 259  static const struct manact __manacts[MDOC_MAX - MDOC_D
         { NULL, NULL, post_percent, NULL, NULL }, /* %U */          { NULL, NULL, post_percent, NULL, NULL }, /* %U */
         { NULL, NULL, NULL, NULL, NULL }, /* Ta */          { NULL, NULL, NULL, NULL, NULL }, /* Ta */
 };  };
 static  const struct manact *const manacts = __manacts - MDOC_Dd;  static const struct mdoc_man_act *mdoc_man_act(enum roff_tok);
   
 static  int             outflags;  static  int             outflags;
 #define MMAN_spc        (1 << 0)  /* blank character before next word */  #define MMAN_spc        (1 << 0)  /* blank character before next word */
Line 290  static struct {
Line 290  static struct {
 }       fontqueue;  }       fontqueue;
   
   
   static const struct mdoc_man_act *
   mdoc_man_act(enum roff_tok tok)
   {
           assert(tok >= MDOC_Dd && tok <= MDOC_MAX);
           return mdoc_man_acts + (tok - MDOC_Dd);
   }
   
 static int  static int
 man_strlen(const char *cp)  man_strlen(const char *cp)
 {  {
Line 640  man_mdoc(void *arg, const struct roff_man *mdoc)
Line 647  man_mdoc(void *arg, const struct roff_man *mdoc)
 static void  static void
 print_node(DECL_ARGS)  print_node(DECL_ARGS)
 {  {
         const struct manact     *act;          const struct mdoc_man_act       *act;
         struct roff_node        *sub;          struct roff_node                *sub;
         int                      cond, do_sub;          int                              cond, do_sub;
   
         if (n->flags & NODE_NOPRT)          if (n->flags & NODE_NOPRT)
                 return;                  return;
Line 680  print_node(DECL_ARGS)
Line 687  print_node(DECL_ARGS)
                 else if (outflags & MMAN_Sm)                  else if (outflags & MMAN_Sm)
                         outflags |= MMAN_spc;                          outflags |= MMAN_spc;
         } else if (n->tok < ROFF_MAX) {          } else if (n->tok < ROFF_MAX) {
                 (*roff_manacts[n->tok])(meta, n);                  (*roff_man_acts[n->tok])(meta, n);
                 return;                  return;
         } else {          } else {
                 assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);  
                 /*                  /*
                  * Conditionally run the pre-node action handler for a                   * Conditionally run the pre-node action handler for a
                  * node.                   * node.
                  */                   */
                 act = manacts + n->tok;                  act = mdoc_man_act(n->tok);
                 cond = act->cond == NULL || (*act->cond)(meta, n);                  cond = act->cond == NULL || (*act->cond)(meta, n);
                 if (cond && act->pre != NULL &&                  if (cond && act->pre != NULL &&
                     (n->end == ENDBODY_NOT || n->child != NULL))                      (n->end == ENDBODY_NOT || n->child != NULL))
Line 736  pre_enc(DECL_ARGS)
Line 742  pre_enc(DECL_ARGS)
 {  {
         const char      *prefix;          const char      *prefix;
   
         prefix = manacts[n->tok].prefix;          prefix = mdoc_man_act(n->tok)->prefix;
         if (NULL == prefix)          if (NULL == prefix)
                 return 1;                  return 1;
         print_word(prefix);          print_word(prefix);
Line 749  post_enc(DECL_ARGS)
Line 755  post_enc(DECL_ARGS)
 {  {
         const char *suffix;          const char *suffix;
   
         suffix = manacts[n->tok].suffix;          suffix = mdoc_man_act(n->tok)->suffix;
         if (NULL == suffix)          if (NULL == suffix)
                 return;                  return;
         outflags &= ~(MMAN_spc | MMAN_nl);          outflags &= ~(MMAN_spc | MMAN_nl);
Line 774  static void
Line 780  static void
 post_percent(DECL_ARGS)  post_percent(DECL_ARGS)
 {  {
   
         if (pre_em == manacts[n->tok].pre)          if (mdoc_man_act(n->tok)->pre == pre_em)
                 font_pop();                  font_pop();
         if (n->next) {          if (n->next) {
                 print_word(",");                  print_word(",");
Line 820  pre_sect(DECL_ARGS)
Line 826  pre_sect(DECL_ARGS)
   
         if (n->type == ROFFT_HEAD) {          if (n->type == ROFFT_HEAD) {
                 outflags |= MMAN_sp;                  outflags |= MMAN_sp;
                 print_block(manacts[n->tok].prefix, 0);                  print_block(mdoc_man_act(n->tok)->prefix, 0);
                 print_word("");                  print_word("");
                 putchar('\"');                  putchar('\"');
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;

Legend:
Removed from v.1.126  
changed lines
  Added in v.1.127

CVSweb