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

Diff for /mandoc/mandocdb.c between version 1.209 and 1.216

version 1.209, 2015/11/07 17:58:55 version 1.216, 2016/03/17 21:26:26
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011-2016 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 156  static void  parse_man(struct mpage *, const struct ro
Line 156  static void  parse_man(struct mpage *, const struct ro
                         const struct roff_node *);                          const struct roff_node *);
 static  void     parse_mdoc(struct mpage *, const struct roff_meta *,  static  void     parse_mdoc(struct mpage *, const struct roff_meta *,
                         const struct roff_node *);                          const struct roff_node *);
 static  int      parse_mdoc_body(struct mpage *, const struct roff_meta *,  
                         const struct roff_node *);  
 static  int      parse_mdoc_head(struct mpage *, const struct roff_meta *,  static  int      parse_mdoc_head(struct mpage *, const struct roff_meta *,
                         const struct roff_node *);                          const struct roff_node *);
 static  int      parse_mdoc_Fd(struct mpage *, const struct roff_meta *,  static  int      parse_mdoc_Fd(struct mpage *, const struct roff_meta *,
Line 173  static int  parse_mdoc_Nm(struct mpage *, const struct
Line 171  static int  parse_mdoc_Nm(struct mpage *, const struct
                         const struct roff_node *);                          const struct roff_node *);
 static  int      parse_mdoc_Sh(struct mpage *, const struct roff_meta *,  static  int      parse_mdoc_Sh(struct mpage *, const struct roff_meta *,
                         const struct roff_node *);                          const struct roff_node *);
   static  int      parse_mdoc_Va(struct mpage *, const struct roff_meta *,
                           const struct roff_node *);
 static  int      parse_mdoc_Xr(struct mpage *, const struct roff_meta *,  static  int      parse_mdoc_Xr(struct mpage *, const struct roff_meta *,
                         const struct roff_node *);                          const struct roff_node *);
 static  void     putkey(const struct mpage *, char *, uint64_t);  static  void     putkey(const struct mpage *, char *, uint64_t);
Line 242  static const struct mdoc_handler mdocs[MDOC_MAX] = {
Line 242  static const struct mdoc_handler mdocs[MDOC_MAX] = {
         { NULL, TYPE_Pa },  /* Pa */          { NULL, TYPE_Pa },  /* Pa */
         { NULL, 0 },  /* Rv */          { NULL, 0 },  /* Rv */
         { NULL, TYPE_St },  /* St */          { NULL, TYPE_St },  /* St */
         { NULL, TYPE_Va },  /* Va */          { parse_mdoc_Va, TYPE_Va },  /* Va */
         { parse_mdoc_body, TYPE_Va },  /* Vt */          { parse_mdoc_Va, TYPE_Vt },  /* Vt */
         { parse_mdoc_Xr, 0 },  /* Xr */          { parse_mdoc_Xr, 0 },  /* Xr */
         { NULL, 0 },  /* %A */          { NULL, 0 },  /* %A */
         { NULL, 0 },  /* %B */          { NULL, 0 },  /* %B */
Line 341  mandocdb(int argc, char *argv[])
Line 341  mandocdb(int argc, char *argv[])
   
 #if HAVE_PLEDGE  #if HAVE_PLEDGE
         if (pledge("stdio rpath wpath cpath fattr flock proc exec", NULL) == -1) {          if (pledge("stdio rpath wpath cpath fattr flock proc exec", NULL) == -1) {
                 perror("pledge");                  warn("pledge");
                 return (int)MANDOCLEVEL_SYSERR;                  return (int)MANDOCLEVEL_SYSERR;
         }          }
 #endif  #endif
Line 420  mandocdb(int argc, char *argv[])
Line 420  mandocdb(int argc, char *argv[])
         argv += optind;          argv += optind;
   
 #if HAVE_PLEDGE  #if HAVE_PLEDGE
         if (nodb && pledge("stdio rpath", NULL) == -1) {          if (nodb) {
                 perror("pledge");                  if (pledge("stdio rpath", NULL) == -1) {
                 return (int)MANDOCLEVEL_SYSERR;                          warn("pledge");
                           return (int)MANDOCLEVEL_SYSERR;
                   }
         }          }
 #endif  #endif
   
Line 452  mandocdb(int argc, char *argv[])
Line 454  mandocdb(int argc, char *argv[])
                          * all files specified on the command-line.                           * all files specified on the command-line.
                          */                           */
 #if HAVE_PLEDGE  #if HAVE_PLEDGE
                         if (!nodb && pledge("stdio rpath wpath cpath fattr flock",                          if (!nodb) {
                             NULL) == -1) {                                  if (pledge("stdio rpath wpath cpath fattr flock", NULL) == -1) {
                                 perror("pledge");                                          warn("pledge");
                                 exitcode = (int)MANDOCLEVEL_SYSERR;                                          exitcode = (int)MANDOCLEVEL_SYSERR;
                                 goto out;                                          goto out;
                                   }
                         }                          }
 #endif  #endif
                         use_all = 1;                          use_all = 1;
Line 571  usage:
Line 574  usage:
  *   or   *   or
  *   [./]cat<section>[/<arch>]/<name>.0   *   [./]cat<section>[/<arch>]/<name>.0
  *   *
  * TODO: accomodate for multi-language directories.   * TODO: accommodate for multi-language directories.
  */   */
 static int  static int
 treescan(void)  treescan(void)
Line 1131  mpages_merge(struct mparse *mp)
Line 1134  mpages_merge(struct mparse *mp)
                 man = NULL;                  man = NULL;
                 sodest = NULL;                  sodest = NULL;
   
                 mparse_open(mp, &fd, mlink->file);                  if ((fd = mparse_open(mp, mlink->file)) == -1) {
                 if (fd == -1) {  
                         say(mlink->file, "&open");                          say(mlink->file, "&open");
                         goto nextpage;                          goto nextpage;
                 }                  }
Line 1143  mpages_merge(struct mparse *mp)
Line 1145  mpages_merge(struct mparse *mp)
                  */                   */
                 if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) {                  if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) {
                         mparse_readfd(mp, fd, mlink->file);                          mparse_readfd(mp, fd, mlink->file);
                           close(fd);
                         mparse_result(mp, &man, &sodest);                          mparse_result(mp, &man, &sodest);
                 }                  }
   
Line 1443  parse_man(struct mpage *mpage, const struct roff_meta 
Line 1446  parse_man(struct mpage *mpage, const struct roff_meta 
         char             byte;          char             byte;
         size_t           sz;          size_t           sz;
   
         if (NULL == n)          if (n == NULL)
                 return;                  return;
   
         /*          /*
Line 1455  parse_man(struct mpage *mpage, const struct roff_meta 
Line 1458  parse_man(struct mpage *mpage, const struct roff_meta 
   
         if (n->type == ROFFT_BODY && n->tok == MAN_SH) {          if (n->type == ROFFT_BODY && n->tok == MAN_SH) {
                 body = n;                  body = n;
                 assert(body->parent);                  if ((head = body->parent->head) != NULL &&
                 if (NULL != (head = body->parent->head) &&                      (head = head->child) != NULL &&
                     1 == head->nchild &&                      head->next == NULL &&
                     NULL != (head = (head->child)) &&  
                     head->type == ROFFT_TEXT &&                      head->type == ROFFT_TEXT &&
                     0 == strcmp(head->string, "NAME") &&                      strcmp(head->string, "NAME") == 0 &&
                     NULL != body->child) {                      body->child != NULL) {
   
                         /*                          /*
                          * Suck the entire NAME section into memory.                           * Suck the entire NAME section into memory.
Line 1686  parse_mdoc_Fo(struct mpage *mpage, const struct roff_m
Line 1688  parse_mdoc_Fo(struct mpage *mpage, const struct roff_m
 }  }
   
 static int  static int
   parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta,
           const struct roff_node *n)
   {
           char *cp;
   
           if (n->type != ROFFT_ELEM && n->type != ROFFT_BODY)
                   return 0;
   
           if (n->child != NULL &&
               n->child->next == NULL &&
               n->child->type == ROFFT_TEXT)
                   return 1;
   
           cp = NULL;
           deroff(&cp, n);
           if (cp != NULL) {
                   putkey(mpage, cp, TYPE_Vt | (n->tok == MDOC_Va ||
                       n->type == ROFFT_BODY ? TYPE_Va : 0));
                   free(cp);
           }
   
           return 0;
   }
   
   static int
 parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,  parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,
         const struct roff_node *n)          const struct roff_node *n)
 {  {
Line 1751  parse_mdoc_head(struct mpage *mpage, const struct roff
Line 1778  parse_mdoc_head(struct mpage *mpage, const struct roff
 {  {
   
         return n->type == ROFFT_HEAD;          return n->type == ROFFT_HEAD;
 }  
   
 static int  
 parse_mdoc_body(struct mpage *mpage, const struct roff_meta *meta,  
         const struct roff_node *n)  
 {  
   
         return n->type == ROFFT_BODY;  
 }  }
   
 /*  /*

Legend:
Removed from v.1.209  
changed lines
  Added in v.1.216

CVSweb