[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.127 and 1.133

version 1.127, 2018/08/17 20:33:37 version 1.133, 2020/01/19 18:02:00
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011-2019 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 75  static void   post_pf(DECL_ARGS);
Line 75  static void   post_pf(DECL_ARGS);
 static  void      post_sect(DECL_ARGS);  static  void      post_sect(DECL_ARGS);
 static  void      post_vt(DECL_ARGS);  static  void      post_vt(DECL_ARGS);
 static  int       pre__t(DECL_ARGS);  static  int       pre__t(DECL_ARGS);
   static  int       pre_abort(DECL_ARGS);
 static  int       pre_an(DECL_ARGS);  static  int       pre_an(DECL_ARGS);
 static  int       pre_ap(DECL_ARGS);  static  int       pre_ap(DECL_ARGS);
 static  int       pre_aq(DECL_ARGS);  static  int       pre_aq(DECL_ARGS);
Line 103  static int   pre_lk(DECL_ARGS);
Line 104  static int   pre_lk(DECL_ARGS);
 static  int       pre_li(DECL_ARGS);  static  int       pre_li(DECL_ARGS);
 static  int       pre_nm(DECL_ARGS);  static  int       pre_nm(DECL_ARGS);
 static  int       pre_no(DECL_ARGS);  static  int       pre_no(DECL_ARGS);
   static  void      pre_noarg(DECL_ARGS);
 static  int       pre_ns(DECL_ARGS);  static  int       pre_ns(DECL_ARGS);
 static  void      pre_onearg(DECL_ARGS);  static  void      pre_onearg(DECL_ARGS);
 static  int       pre_pp(DECL_ARGS);  static  int       pre_pp(DECL_ARGS);
Line 127  static void   print_node(DECL_ARGS);
Line 129  static void   print_node(DECL_ARGS);
 static const void_fp roff_man_acts[ROFF_MAX] = {  static const void_fp roff_man_acts[ROFF_MAX] = {
         pre_br,         /* br */          pre_br,         /* br */
         pre_onearg,     /* ce */          pre_onearg,     /* ce */
           pre_noarg,      /* fi */
         pre_ft,         /* ft */          pre_ft,         /* ft */
         pre_onearg,     /* ll */          pre_onearg,     /* ll */
         pre_onearg,     /* mc */          pre_onearg,     /* mc */
           pre_noarg,      /* nf */
         pre_onearg,     /* po */          pre_onearg,     /* po */
         pre_onearg,     /* rj */          pre_onearg,     /* rj */
         pre_sp,         /* sp */          pre_sp,         /* sp */
Line 172  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
Line 176  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
         { cond_head, pre_enc, NULL, "\\- ", NULL }, /* Nd */          { cond_head, pre_enc, NULL, "\\- ", NULL }, /* Nd */
         { NULL, pre_nm, post_nm, NULL, NULL }, /* Nm */          { NULL, pre_nm, post_nm, NULL, NULL }, /* Nm */
         { cond_body, pre_enc, post_enc, "[", "]" }, /* Op */          { cond_body, pre_enc, post_enc, "[", "]" }, /* Op */
         { NULL, pre_Ft, post_font, NULL, NULL }, /* Ot */          { NULL, pre_abort, NULL, NULL, NULL }, /* Ot */
         { NULL, pre_em, post_font, NULL, NULL }, /* Pa */          { NULL, pre_em, post_font, NULL, NULL }, /* Pa */
         { NULL, pre_ex, NULL, NULL, NULL }, /* Rv */          { NULL, pre_ex, NULL, NULL, NULL }, /* Rv */
         { NULL, NULL, NULL, NULL, NULL }, /* St */          { NULL, NULL, NULL, NULL, NULL }, /* St */
Line 245  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
Line 249  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
         { NULL, pre_em, post_font, NULL, NULL }, /* Fr */          { NULL, pre_em, post_font, NULL, NULL }, /* Fr */
         { NULL, NULL, NULL, NULL, NULL }, /* Ud */          { NULL, NULL, NULL, NULL, 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_abort, NULL, NULL, NULL }, /* Lp */
         { NULL, pre_lk, NULL, NULL, NULL }, /* Lk */          { NULL, pre_lk, NULL, NULL, NULL }, /* Lk */
         { NULL, pre_em, post_font, NULL, NULL }, /* Mt */          { NULL, pre_em, post_font, NULL, NULL }, /* Mt */
         { cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */          { cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */
Line 258  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
Line 262  static const struct mdoc_man_act mdoc_man_acts[MDOC_MA
         { NULL, NULL, post_percent, NULL, NULL }, /* %Q */          { NULL, NULL, post_percent, NULL, NULL }, /* %Q */
         { 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 */
           { NULL, NULL, NULL, NULL, NULL }, /* Tg */
 };  };
 static const struct mdoc_man_act *mdoc_man_act(enum roff_tok);  static const struct mdoc_man_act *mdoc_man_act(enum roff_tok);
   
Line 324  man_strlen(const char *cp)
Line 329  man_strlen(const char *cp)
                 case ESCAPE_UNICODE:                  case ESCAPE_UNICODE:
                 case ESCAPE_NUMBERED:                  case ESCAPE_NUMBERED:
                 case ESCAPE_SPECIAL:                  case ESCAPE_SPECIAL:
                   case ESCAPE_UNDEF:
                 case ESCAPE_OVERSTRIKE:                  case ESCAPE_OVERSTRIKE:
                         if (skip)                          if (skip)
                                 skip = 0;                                  skip = 0;
Line 600  print_count(int *count)
Line 606  print_count(int *count)
 }  }
   
 void  void
 man_man(void *arg, const struct roff_man *man)  man_mdoc(void *arg, const struct roff_meta *mdoc)
 {  {
   
         /*  
          * Dump the keep buffer.  
          * We're guaranteed by now that this exists (is non-NULL).  
          * Flush stdout afterward, just in case.  
          */  
         fputs(mparse_getkeep(man_mparse(man)), stdout);  
         fflush(stdout);  
 }  
   
 void  
 man_mdoc(void *arg, const struct roff_man *mdoc)  
 {  
         struct roff_node *n;          struct roff_node *n;
   
         printf(".\\\" Automatically generated from an mdoc input file."          printf(".\\\" Automatically generated from an mdoc input file."
Line 626  man_mdoc(void *arg, const struct roff_man *mdoc)
Line 619  man_mdoc(void *arg, const struct roff_man *mdoc)
         }          }
   
         printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",          printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
             mdoc->meta.title,              mdoc->title, (mdoc->msec == NULL ? "" : mdoc->msec),
             (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),              mdoc->date, mdoc->os, mdoc->vol);
             mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);  
   
         /* Disable hyphenation and if nroff, disable justification. */          /* Disable hyphenation and if nroff, disable justification. */
         printf(".nh\n.if n .ad l");          printf(".nh\n.if n .ad l");
Line 640  man_mdoc(void *arg, const struct roff_man *mdoc)
Line 632  man_mdoc(void *arg, const struct roff_man *mdoc)
                 *fontqueue.tail = 'R';                  *fontqueue.tail = 'R';
         }          }
         for (; n != NULL; n = n->next)          for (; n != NULL; n = n->next)
                 print_node(&mdoc->meta, n);                  print_node(mdoc, n);
         putchar('\n');          putchar('\n');
 }  }
   
Line 738  cond_body(DECL_ARGS)
Line 730  cond_body(DECL_ARGS)
 }  }
   
 static int  static int
   pre_abort(DECL_ARGS)
   {
           abort();
   }
   
   static int
 pre_enc(DECL_ARGS)  pre_enc(DECL_ARGS)
 {  {
         const char      *prefix;          const char      *prefix;
Line 942  post_aq(DECL_ARGS)
Line 940  post_aq(DECL_ARGS)
 static int  static int
 pre_bd(DECL_ARGS)  pre_bd(DECL_ARGS)
 {  {
   
         outflags &= ~(MMAN_PP | MMAN_sp | MMAN_br);          outflags &= ~(MMAN_PP | MMAN_sp | MMAN_br);
   
         if (DISP_unfilled == n->norm->Bd.type ||          if (DISP_unfilled == n->norm->Bd.type ||
Line 957  pre_bd(DECL_ARGS)
Line 954  pre_bd(DECL_ARGS)
 static void  static void
 post_bd(DECL_ARGS)  post_bd(DECL_ARGS)
 {  {
           enum roff_tok    bef, now;
   
         /* Close out this display. */          /* Close out this display. */
         print_line(".RE", MMAN_nl);          print_line(".RE", MMAN_nl);
         if (DISP_unfilled == n->norm->Bd.type ||          bef = n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi;
             DISP_literal  == n->norm->Bd.type)          if (n->last == NULL)
                 print_line(".fi", MMAN_nl);                  now = n->norm->Bd.type == DISP_unfilled ||
                       n->norm->Bd.type == DISP_literal ? ROFF_nf : ROFF_fi;
           else if (n->last->tok == ROFF_nf)
                   now = ROFF_nf;
           else if (n->last->tok == ROFF_fi)
                   now = ROFF_fi;
           else
                   now = n->last->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi;
           if (bef != now) {
                   outflags |= MMAN_nl;
                   print_word(".");
                   outflags &= ~MMAN_spc;
                   print_word(roff_name[bef]);
                   outflags |= MMAN_nl;
           }
   
         /* Maybe we are inside an enclosing list? */          /* Maybe we are inside an enclosing list? */
         if (NULL != n->parent->next)          if (NULL != n->parent->next)
Line 1613  pre_onearg(DECL_ARGS)
Line 1625  pre_onearg(DECL_ARGS)
 static int  static int
 pre_li(DECL_ARGS)  pre_li(DECL_ARGS)
 {  {
   
         font_push('R');          font_push('R');
         return 1;          return 1;
 }  }
Line 1646  pre_nm(DECL_ARGS)
Line 1657  pre_nm(DECL_ARGS)
 static void  static void
 post_nm(DECL_ARGS)  post_nm(DECL_ARGS)
 {  {
   
         switch (n->type) {          switch (n->type) {
         case ROFFT_BLOCK:          case ROFFT_BLOCK:
                 outflags &= ~MMAN_Bk;                  outflags &= ~MMAN_Bk;
Line 1664  post_nm(DECL_ARGS)
Line 1674  post_nm(DECL_ARGS)
 static int  static int
 pre_no(DECL_ARGS)  pre_no(DECL_ARGS)
 {  {
   
         outflags |= MMAN_spc_force;          outflags |= MMAN_spc_force;
         return 1;          return 1;
 }  }
   
   static void
   pre_noarg(DECL_ARGS)
   {
           outflags |= MMAN_nl;
           print_word(".");
           outflags &= ~MMAN_spc;
           print_word(roff_name[n->tok]);
           outflags |= MMAN_nl;
   }
   
 static int  static int
 pre_ns(DECL_ARGS)  pre_ns(DECL_ARGS)
 {  {
   
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return 0;          return 0;
 }  }

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

CVSweb