]> git.cameronkatri.com Git - mandoc.git/blobdiff - main.c
Do not mistreat empty arguments to font alternating macros
[mandoc.git] / main.c
diff --git a/main.c b/main.c
index d5d61e8123f3f264bf576f7b0248c919864413bd..61e90fe581f52d22c0e95a20a2e31c2c7683b34f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/*     $Id: main.c,v 1.229 2015/03/27 17:37:25 schwarze Exp $ */
+/*     $Id: main.c,v 1.232 2015/04/03 08:46:17 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
 #include <string.h>
 #include <unistd.h>
 
-#include "mandoc.h"
 #include "mandoc_aux.h"
-#include "main.h"
+#include "mandoc.h"
+#include "roff.h"
 #include "mdoc.h"
 #include "man.h"
+#include "main.h"
 #include "manconf.h"
 #include "mansearch.h"
 
@@ -83,7 +84,7 @@ struct        curparse {
        out_man           outman;       /* man output ptr */
        out_free          outfree;      /* free output ptr */
        void             *outdata;      /* data for output */
-       char              outopts[BUFSIZ]; /* buf of output opts */
+       struct manoutput *outopts;      /* output options */
 };
 
 static int               fs_lookup(const struct manpaths *,
@@ -127,7 +128,7 @@ main(int argc, char *argv[])
        struct manpage  *res, *resp;
        char            *conf_file, *defpaths;
        size_t           isec, i, sz;
-       int              prio, best_prio, synopsis_only;
+       int              prio, best_prio;
        char             sec;
        enum mandoclevel rctmp;
        enum outmode     outmode;
@@ -174,12 +175,12 @@ main(int argc, char *argv[])
        memset(&curp, 0, sizeof(struct curparse));
        curp.outtype = OUTT_LOCALE;
        curp.wlevel  = MANDOCLEVEL_BADARG;
+       curp.outopts = &conf.output;
        options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
        defos = NULL;
 
        pager_pid = 1;
        show_usage = 0;
-       synopsis_only = 0;
        outmode = OUTMODE_DEF;
 
        while (-1 != (c = getopt(argc, argv,
@@ -198,8 +199,7 @@ main(int argc, char *argv[])
                        search.argmode = ARG_WORD;
                        break;
                case 'h':
-                       (void)strlcat(curp.outopts, "synopsis,", BUFSIZ);
-                       synopsis_only = 1;
+                       conf.output.synopsisonly = 1;
                        pager_pid = 0;
                        outmode = OUTMODE_ALL;
                        break;
@@ -240,8 +240,9 @@ main(int argc, char *argv[])
                        break;
                case 'O':
                        search.outkey = optarg;
-                       (void)strlcat(curp.outopts, optarg, BUFSIZ);
-                       (void)strlcat(curp.outopts, ",", BUFSIZ);
+                       while (optarg != NULL)
+                               manconf_output(&conf.output,
+                                   strsep(&optarg, ","));
                        break;
                case 'S':
                        search.arch = optarg;
@@ -444,7 +445,8 @@ main(int argc, char *argv[])
                                chdir(conf.manpath.paths[resp->ipath]);
                                parse(&curp, fd, resp->file);
                        } else
-                               passthrough(resp->file, fd, synopsis_only);
+                               passthrough(resp->file, fd,
+                                   conf.output.synopsisonly);
 
                        rctmp = mparse_wait(curp.mp);
                        if (rc < rctmp)
@@ -995,7 +997,7 @@ spawn_pager(void)
        if (pager == NULL || *pager == '\0')
                pager = getenv("PAGER");
        if (pager == NULL || *pager == '\0')
-               pager = "/usr/bin/more -s";
+               pager = "more -s";
        cp = mandoc_strdup(pager);
 
        /*