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

Diff for /mandoc/mandocdb.c between version 1.49.2.10 and 1.49.2.18

version 1.49.2.10, 2013/11/21 01:53:48 version 1.49.2.18, 2014/08/14 04:13:30
Line 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #ifdef HAVE_CONFIG_H  
 #include "config.h"  #include "config.h"
 #endif  
   
 #include <sys/types.h>  #include <sys/types.h>
   
Line 36 
Line 34 
   
 #if defined(__APPLE__)  #if defined(__APPLE__)
 # include <libkern/OSByteOrder.h>  # include <libkern/OSByteOrder.h>
 #elif defined(__linux__)  #elif defined(__linux__) || defined(__CYGWIN__)
 # include <endian.h>  # include <endian.h>
 #elif defined(__sun)  #elif defined(__sun)
 # include <sys/byteorder.h>  # include <sys/byteorder.h>
Line 45 
Line 43 
 # include <sys/endian.h>  # include <sys/endian.h>
 #endif  #endif
   
 #if defined(__linux__) || defined(__sun)  #if defined(__linux__) || defined(__CYGWIN__) || defined(__sun)
 # include <db_185.h>  # include <db_185.h>
 #else  #else
 # include <db.h>  # include <db.h>
Line 54 
Line 52 
 #include "man.h"  #include "man.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "mandoc.h"  #include "mandoc.h"
   #include "mandoc_aux.h"
 #include "mandocdb.h"  #include "mandocdb.h"
 #include "manpath.h"  #include "manpath.h"
   
Line 288  static const struct mdoc_handler mdocs[MDOC_MAX] = {
Line 287  static const struct mdoc_handler mdocs[MDOC_MAX] = {
 };  };
   
 static  const char       *progname;  static  const char       *progname;
   static  int               mparse_options;  /* abort the parse early */
 static  int               use_all;  /* Use all directories and files. */  static  int               use_all;  /* Use all directories and files. */
 static  int               verb;  /* Output verbosity level. */  static  int               verb;  /* Output verbosity level. */
 static  int               warnings;  /* Potential problems in manuals. */  static  int               warnings;  /* Potential problems in manuals. */
Line 328  main(int argc, char *argv[])
Line 328  main(int argc, char *argv[])
         hash = NULL;          hash = NULL;
         op = OP_DEFAULT;          op = OP_DEFAULT;
         dir = NULL;          dir = NULL;
           mparse_options = MPARSE_SO;
   
         while (-1 != (ch = getopt(argc, argv, "aC:d:tu:vW")))          while (-1 != (ch = getopt(argc, argv, "aC:d:Qtu:vW")))
                 switch (ch) {                  switch (ch) {
                 case ('a'):                  case ('a'):
                         use_all = 1;                          use_all = 1;
Line 352  main(int argc, char *argv[])
Line 353  main(int argc, char *argv[])
                         dir = optarg;                          dir = optarg;
                         op = OP_UPDATE;                          op = OP_UPDATE;
                         break;                          break;
                   case ('Q'):
                           mparse_options |= MPARSE_QUICK;
                           break;
                 case ('t'):                  case ('t'):
                         dup2(STDOUT_FILENO, STDERR_FILENO);                          dup2(STDOUT_FILENO, STDERR_FILENO);
                         if (op) {                          if (op) {
Line 394  main(int argc, char *argv[])
Line 398  main(int argc, char *argv[])
         info.lorder = 4321;          info.lorder = 4321;
         info.flags = R_DUP;          info.flags = R_DUP;
   
         mp = mparse_alloc(MPARSE_AUTO, MANDOCLEVEL_FATAL, NULL, NULL, NULL);          mp = mparse_alloc(mparse_options, MANDOCLEVEL_FATAL, NULL, NULL);
   
         memset(&buf, 0, sizeof(struct buf));          memset(&buf, 0, sizeof(struct buf));
         memset(&dbuf, 0, sizeof(struct buf));          memset(&dbuf, 0, sizeof(struct buf));
Line 595  out:
Line 599  out:
   
 usage:  usage:
         fprintf(stderr,          fprintf(stderr,
                 "usage: %s [-avvv] [-C file] | dir ... | -t file ...\n"                  "usage: %s [-aQvvv] [-C file] | dir ... | -t file ...\n"
                 "                        -d dir [file ...] | "                  "                        -d dir [file ...] | "
                 "-u dir [file ...]\n",                  "-u dir [file ...]\n",
                 progname);                  progname);
Line 646  index_merge(const struct of *of, struct mparse *mp,
Line 650  index_merge(const struct of *of, struct mparse *mp,
                 if ((MANDOC_SRC & of->src_form ||                  if ((MANDOC_SRC & of->src_form ||
                     ! (MANDOC_FORM & of->src_form)) &&                      ! (MANDOC_FORM & of->src_form)) &&
                     MANDOCLEVEL_FATAL > mparse_readfd(mp, -1, fn))                      MANDOCLEVEL_FATAL > mparse_readfd(mp, -1, fn))
                         mparse_result(mp, &mdoc, &man);                          mparse_result(mp, &mdoc, &man, NULL);
   
                 if (NULL != mdoc) {                  if (NULL != mdoc) {
                         msec = mdoc_meta(mdoc)->msec;                          msec = mdoc_meta(mdoc)->msec;
Line 978  index_prune(const struct of *ofile, struct mdb *mdb, s
Line 982  index_prune(const struct of *ofile, struct mdb *mdb, s
 cont:  cont:
                 if (recs->cur >= recs->size) {                  if (recs->cur >= recs->size) {
                         recs->size += MANDOC_SLOP;                          recs->size += MANDOC_SLOP;
                         recs->stack = mandoc_realloc(recs->stack,                          recs->stack = mandoc_reallocarray(recs->stack,
                                         recs->size * sizeof(recno_t));                              recs->size, sizeof(recno_t));
                 }                  }
   
                 recs->stack[(int)recs->cur] = recs->last;                  recs->stack[(int)recs->cur] = recs->last;
Line 1377  static int
Line 1381  static int
 pman_node(MAN_ARGS)  pman_node(MAN_ARGS)
 {  {
         const struct man_node *head, *body;          const struct man_node *head, *body;
         char            *start, *sv, *title;          char            *start, *title;
         size_t           sz, titlesz;          size_t           sz;
   
         if (NULL == n)          if (NULL == n)
                 return(0);                  return(0);
Line 1398  pman_node(MAN_ARGS)
Line 1402  pman_node(MAN_ARGS)
                                 NULL != (head = (head->child)) &&                                  NULL != (head = (head->child)) &&
                                 MAN_TEXT == head->type &&                                  MAN_TEXT == head->type &&
                                 0 == strcmp(head->string, "NAME") &&                                  0 == strcmp(head->string, "NAME") &&
                                 NULL != (body = body->child) &&                                  NULL != body->child) {
                                 MAN_TEXT == body->type) {  
   
                         title = NULL;  
                         titlesz = 0;  
                         /*                          /*
                          * Suck the entire NAME section into memory.                           * Suck the entire NAME section into memory.
                          * Yes, we might run away.                           * Yes, we might run away.
                          * But too many manuals have big, spread-out                           * But too many manuals have big, spread-out
                          * NAME sections over many lines.                           * NAME sections over many lines.
                          */                           */
                         for ( ; NULL != body; body = body->next) {  
                                 if (MAN_TEXT != body->type)                          title = NULL;
                                         break;                          man_deroff(&title, body);
                                 if (0 == (sz = strlen(body->string)))  
                                         continue;  
                                 title = mandoc_realloc  
                                         (title, titlesz + sz + 1);  
                                 memcpy(title + titlesz, body->string, sz);  
                                 titlesz += sz + 1;  
                                 title[(int)titlesz - 1] = ' ';  
                         }  
                         if (NULL == title)                          if (NULL == title)
                                 return(0);                                  return(0);
   
                         title = mandoc_realloc(title, titlesz + 1);  
                         title[(int)titlesz] = '\0';  
   
                         /* Skip leading space.  */  
   
                         sv = title;  
                         while (isspace((unsigned char)*sv))  
                                 sv++;  
   
                         if (0 == (sz = strlen(sv))) {  
                                 free(title);  
                                 return(0);  
                         }  
   
                         /* Erase trailing space. */  
   
                         start = &sv[sz - 1];  
                         while (start > sv && isspace((unsigned char)*start))  
                                 *start-- = '\0';  
   
                         if (start == sv) {  
                                 free(title);  
                                 return(0);  
                         }  
   
                         start = sv;  
   
                         /*                          /*
                          * Go through a special heuristic dance here.                           * Go through a special heuristic dance here.
                          * This is why -man manuals are great!                           * This is why -man manuals are great!
Line 1460  pman_node(MAN_ARGS)
Line 1426  pman_node(MAN_ARGS)
                          * the name parts here.                           * the name parts here.
                          */                           */
   
                           start = title;
                         for ( ;; ) {                          for ( ;; ) {
                                 sz = strcspn(start, " ,");                                  sz = strcspn(start, " ,");
                                 if ('\0' == start[(int)sz])                                  if ('\0' == start[(int)sz])
Line 1484  pman_node(MAN_ARGS)
Line 1451  pman_node(MAN_ARGS)
   
                         buf->len = 0;                          buf->len = 0;
   
                         if (sv == start) {                          if (start == title) {
                                 buf_append(buf, start);                                  buf_append(buf, start);
                                 free(title);                                  free(title);
                                 return(1);                                  return(1);

Legend:
Removed from v.1.49.2.10  
changed lines
  Added in v.1.49.2.18

CVSweb