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

Diff for /mandoc/main.c between version 1.197 and 1.204

version 1.197, 2014/11/11 02:10:04 version 1.204, 2014/12/09 09:14:33
Line 83  struct curparse {
Line 83  struct curparse {
 };  };
   
 static  int               koptions(int *, char *);  static  int               koptions(int *, char *);
   #if HAVE_SQLITE3
   int                       mandocdb(int, char**);
   #endif
 static  int               moptions(int *, char *);  static  int               moptions(int *, char *);
 static  void              mmsg(enum mandocerr, enum mandoclevel,  static  void              mmsg(enum mandocerr, enum mandoclevel,
                                 const char *, int, int, const char *);                                  const char *, int, int, const char *);
Line 96  static void    version(void) __attribute__((noreturn))
Line 99  static void    version(void) __attribute__((noreturn))
 static  int               woptions(struct curparse *, char *);  static  int               woptions(struct curparse *, char *);
   
 static  const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9};  static  const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9};
   static  char              help_arg[] = "help";
   static  char             *help_argv[] = {help_arg, NULL};
 static  const char       *progname;  static  const char       *progname;
   
   
Line 115  main(int argc, char *argv[])
Line 120  main(int argc, char *argv[])
 #endif  #endif
         enum mandoclevel rc;          enum mandoclevel rc;
         enum outmode     outmode;          enum outmode     outmode;
         pid_t            child_pid;  
         int              fd;          int              fd;
         int              show_usage;          int              show_usage;
         int              use_pager;          int              use_pager;
Line 129  main(int argc, char *argv[])
Line 133  main(int argc, char *argv[])
         else          else
                 ++progname;                  ++progname;
   
   #if HAVE_SQLITE3
           if (strcmp(progname, BINM_MAKEWHATIS) == 0)
                   return(mandocdb(argc, argv));
   #endif
   
         /* Search options. */          /* Search options. */
   
         memset(&paths, 0, sizeof(struct manpaths));          memset(&paths, 0, sizeof(struct manpaths));
Line 137  main(int argc, char *argv[])
Line 146  main(int argc, char *argv[])
         memset(&search, 0, sizeof(struct mansearch));          memset(&search, 0, sizeof(struct mansearch));
         search.outkey = "Nd";          search.outkey = "Nd";
   
         if (strcmp(progname, "man") == 0)          if (strcmp(progname, BINM_MAN) == 0)
                 search.argmode = ARG_NAME;                  search.argmode = ARG_NAME;
         else if (strncmp(progname, "apropos", 7) == 0)          else if (strcmp(progname, BINM_APROPOS) == 0)
                 search.argmode = ARG_EXPR;                  search.argmode = ARG_EXPR;
         else if (strncmp(progname, "whatis", 6) == 0)          else if (strcmp(progname, BINM_WHATIS) == 0)
                 search.argmode = ARG_WORD;                  search.argmode = ARG_WORD;
           else if (strncmp(progname, "help", 4) == 0)
                   search.argmode = ARG_NAME;
         else          else
                 search.argmode = ARG_FILE;                  search.argmode = ARG_FILE;
   
         /* Parser and formatter options. */          /* Parser and formatter options. */
   
         memset(&curp, 0, sizeof(struct curparse));          memset(&curp, 0, sizeof(struct curparse));
         curp.outtype = OUTT_ASCII;          curp.outtype = OUTT_LOCALE;
         curp.wlevel  = MANDOCLEVEL_FATAL;          curp.wlevel  = MANDOCLEVEL_FATAL;
         options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;          options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
         defos = NULL;          defos = NULL;
Line 177  main(int argc, char *argv[])
Line 188  main(int argc, char *argv[])
                 case 'h':                  case 'h':
                         (void)strlcat(curp.outopts, "synopsis,", BUFSIZ);                          (void)strlcat(curp.outopts, "synopsis,", BUFSIZ);
                         synopsis_only = 1;                          synopsis_only = 1;
                           use_pager = 0;
                         outmode = OUTMODE_ALL;                          outmode = OUTMODE_ALL;
                         break;                          break;
                 case 'I':                  case 'I':
Line 273  main(int argc, char *argv[])
Line 285  main(int argc, char *argv[])
         resp = NULL;          resp = NULL;
 #endif  #endif
   
         /* Quirk for a man(1) section argument without -s. */          /*
            * Quirks for help(1)
            * and for a man(1) section argument without -s.
            */
   
         if (search.argmode == ARG_NAME &&          if (search.argmode == ARG_NAME) {
             argv[0] != NULL &&                  if (*progname == 'h') {
             isdigit((unsigned char)argv[0][0]) &&                          if (argc == 0) {
             (argv[0][1] == '\0' || !strcmp(argv[0], "3p"))) {                                  argv = help_argv;
                 search.sec = argv[0];                                  argc = 1;
                 argv++;                          }
                 argc--;                  } else if (argv[0] != NULL &&
                       isdigit((unsigned char)argv[0][0]) &&
                       (argv[0][1] == '\0' || !strcmp(argv[0], "3p"))) {
                           search.sec = argv[0];
                           argv++;
                           argc--;
                   }
         }          }
   
         rc = MANDOCLEVEL_OK;          rc = MANDOCLEVEL_OK;
Line 293  main(int argc, char *argv[])
Line 314  main(int argc, char *argv[])
                 if (argc == 0)                  if (argc == 0)
                         usage(search.argmode);                          usage(search.argmode);
   
                   if (search.argmode == ARG_NAME &&
                       outmode == OUTMODE_ONE)
                           search.firstmatch = 1;
   
                 /* Access the mandoc database. */                  /* Access the mandoc database. */
   
                 manpath_parse(&paths, conf_file, defpaths, auxpaths);                  manpath_parse(&paths, conf_file, defpaths, auxpaths);
Line 383  main(int argc, char *argv[])
Line 408  main(int argc, char *argv[])
         while (argc) {          while (argc) {
 #if HAVE_SQLITE3  #if HAVE_SQLITE3
                 if (resp != NULL) {                  if (resp != NULL) {
                         rc = mparse_open(curp.mp, &fd, resp->file,                          rc = mparse_open(curp.mp, &fd, resp->file);
                             &child_pid);  
                         if (fd == -1)                          if (fd == -1)
                                 /* nothing */;                                  /* nothing */;
                         else if (resp->form & FORM_SRC) {                          else if (resp->form & FORM_SRC) {
Line 398  main(int argc, char *argv[])
Line 422  main(int argc, char *argv[])
                 } else                  } else
 #endif  #endif
                 {                  {
                         rc = mparse_open(curp.mp, &fd, *argv++,                          rc = mparse_open(curp.mp, &fd, *argv++);
                             &child_pid);  
                         if (fd != -1)                          if (fd != -1)
                                 parse(&curp, fd, argv[-1], &rc);                                  parse(&curp, fd, argv[-1], &rc);
                 }                  }
   
                 if (child_pid &&                  if (mparse_wait(curp.mp) != MANDOCLEVEL_OK)
                     mparse_wait(curp.mp, child_pid) != MANDOCLEVEL_OK)  
                         rc = MANDOCLEVEL_SYSERR;                          rc = MANDOCLEVEL_SYSERR;
   
                 if (MANDOCLEVEL_OK != rc && curp.wstop)                  if (MANDOCLEVEL_OK != rc && curp.wstop)

Legend:
Removed from v.1.197  
changed lines
  Added in v.1.204

CVSweb