[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.4 and 1.49.2.12

version 1.49.2.4, 2013/09/17 23:12:21 version 1.49.2.12, 2014/03/19 22:09:29
Line 34 
Line 34 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #if defined(__linux__)  #if defined(__APPLE__)
   # include <libkern/OSByteOrder.h>
   #elif defined(__linux__)
 # include <endian.h>  # include <endian.h>
   #elif defined(__sun)
   # include <sys/byteorder.h>
   # include <sys/stat.h>
   #else
   # include <sys/endian.h>
   #endif
   
   #if defined(__linux__) || defined(__sun)
 # include <db_185.h>  # include <db_185.h>
 #elif defined(__APPLE__)  
 # include <libkern/OSByteOrder.h>  
 # include <db.h>  
 #else  #else
 # include <db.h>  # include <db.h>
 #endif  #endif
Line 281  static const struct mdoc_handler mdocs[MDOC_MAX] = {
Line 288  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 321  main(int argc, char *argv[])
Line 329  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 345  main(int argc, char *argv[])
Line 354  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 387  main(int argc, char *argv[])
Line 399  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 588  out:
Line 600  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 615  index_merge(const struct of *of, struct mparse *mp,
Line 627  index_merge(const struct of *of, struct mparse *mp,
         uint64_t         vbuf[2];          uint64_t         vbuf[2];
         char             type;          char             type;
   
           static char      emptystring[] = "";
   
         if (warnings) {          if (warnings) {
                 files = NULL;                  files = NULL;
                 hash_reset(&files);                  hash_reset(&files);
Line 727  index_merge(const struct of *of, struct mparse *mp,
Line 741  index_merge(const struct of *of, struct mparse *mp,
                         }                          }
                         buf_appendb(buf, ")", 2);                          buf_appendb(buf, ")", 2);
                         for (p = buf->cp; '\0' != *p; p++)                          for (p = buf->cp; '\0' != *p; p++)
                                 *p = tolower(*p);                                  *p = tolower((unsigned char)*p);
                         key.data = buf->cp;                          key.data = buf->cp;
                         key.size = buf->len;                          key.size = buf->len;
                         val.data = NULL;                          val.data = NULL;
                         val.size = 0;                          val.size = 0;
                         if (0 == skip)                          if (0 == skip)
                                 val.data = "";                                  val.data = emptystring;
                         else {                          else {
                                 ch = (*files->get)(files, &key, &val, 0);                                  ch = (*files->get)(files, &key, &val, 0);
                                 if (ch < 0) {                                  if (ch < 0) {
Line 1747  ofile_argbuild(int argc, char *argv[], struct of **of,
Line 1761  ofile_argbuild(int argc, char *argv[], struct of **of,
  * Recursively build up a list of files to parse.   * Recursively build up a list of files to parse.
  * We use this instead of ftw() and so on because I don't want global   * We use this instead of ftw() and so on because I don't want global
  * variables hanging around.   * variables hanging around.
  * This ignores the mandocdb.db and mandocdb.index files, but assumes that   * This ignores the mandoc.db and mandoc.index files, but assumes that
  * everything else is a manual.   * everything else is a manual.
  * Pass in a pointer to a NULL structure for the first invocation.   * Pass in a pointer to a NULL structure for the first invocation.
  */   */
Line 1756  ofile_dirbuild(const char *dir, const char* psec, cons
Line 1770  ofile_dirbuild(const char *dir, const char* psec, cons
                 int p_src_form, struct of **of)                  int p_src_form, struct of **of)
 {  {
         char             buf[PATH_MAX];          char             buf[PATH_MAX];
   #if defined(__sun)
           struct stat      sb;
   #endif
         size_t           sz;          size_t           sz;
         DIR             *d;          DIR             *d;
         const char      *fn, *sec, *arch;          const char      *fn, *sec, *arch;
Line 1778  ofile_dirbuild(const char *dir, const char* psec, cons
Line 1795  ofile_dirbuild(const char *dir, const char* psec, cons
   
                 src_form = p_src_form;                  src_form = p_src_form;
   
   #if defined(__sun)
                   stat(dp->d_name, &sb);
                   if (S_IFDIR & sb.st_mode) {
   #else
                 if (DT_DIR == dp->d_type) {                  if (DT_DIR == dp->d_type) {
   #endif
                         sec = psec;                          sec = psec;
                         arch = parch;                          arch = parch;
   
Line 1835  ofile_dirbuild(const char *dir, const char* psec, cons
Line 1857  ofile_dirbuild(const char *dir, const char* psec, cons
                         continue;                          continue;
                 }                  }
   
   #if defined(__sun)
                   if (0 == S_IFREG & sb.st_mode) {
   #else
                 if (DT_REG != dp->d_type) {                  if (DT_REG != dp->d_type) {
   #endif
                         if (warnings)                          if (warnings)
                                 fprintf(stderr,                                  fprintf(stderr,
                                     "%s/%s: not a regular file\n",                                      "%s/%s: not a regular file\n",

Legend:
Removed from v.1.49.2.4  
changed lines
  Added in v.1.49.2.12

CVSweb