summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/main.c b/main.c
index d916864d..a0878099 100644
--- a/main.c
+++ b/main.c
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
struct manpage *res, *resp;
const char *progname, *sec, *thisarg;
char *conf_file, *defpaths, *auxpaths;
- char *oarg;
+ char *oarg, *tagarg;
unsigned char *uc;
size_t i, sz;
int prio, best_prio;
@@ -368,6 +368,17 @@ main(int argc, char *argv[])
#endif
}
+ /*
+ * Use the first argument for -O tag in addition to
+ * using it as a search term for man(1) or apropos(1).
+ */
+
+ if (conf.output.tag != NULL && *conf.output.tag == '\0') {
+ tagarg = argc > 0 && search.argmode == ARG_EXPR ?
+ strchr(*argv, '=') : NULL;
+ conf.output.tag = tagarg == NULL ? *argv : tagarg + 1;
+ }
+
/* man(1), whatis(1), apropos(1) */
if (search.argmode != ARG_FILE) {
@@ -480,8 +491,10 @@ main(int argc, char *argv[])
curp.mp = mparse_alloc(options, curp.os_e, curp.os_s);
if (argc < 1) {
- if (use_pager)
+ if (use_pager) {
tag_files = tag_init();
+ tag_files->tagname = conf.output.tag;
+ }
thisarg = "<stdin>";
mandoc_msg_setinfilename(thisarg);
parse(&curp, STDIN_FILENO, thisarg);
@@ -518,11 +531,7 @@ main(int argc, char *argv[])
if (use_pager) {
use_pager = 0;
tag_files = tag_init();
- if (conf.output.tag != NULL &&
- tag_files->tagname == NULL)
- tag_files->tagname =
- *conf.output.tag != '\0' ?
- conf.output.tag : *argv;
+ tag_files->tagname = conf.output.tag;
}
mandoc_msg_setinfilename(thisarg);