=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.187 retrieving revision 1.191 diff -u -p -r1.187 -r1.191 --- mandoc/main.c 2014/08/23 22:26:06 1.187 +++ mandoc/main.c 2014/09/03 18:09:14 1.191 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.187 2014/08/23 22:26:06 schwarze Exp $ */ +/* $Id: main.c,v 1.191 2014/09/03 18:09:14 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze @@ -154,7 +154,7 @@ main(int argc, char *argv[]) show_usage = 0; outmode = OUTMODE_DEF; - while (-1 != (c = getopt(argc, argv, "aC:cfI:ikM:m:O:S:s:T:VW:w"))) { + while (-1 != (c = getopt(argc, argv, "aC:cfhI:iklM:m:O:S:s:T:VW:w"))) { switch (c) { case 'a': outmode = OUTMODE_ALL; @@ -168,6 +168,10 @@ main(int argc, char *argv[]) case 'f': search.argmode = ARG_WORD; break; + case 'h': + (void)strlcat(curp.outopts, "synopsis,", BUFSIZ); + outmode = OUTMODE_ALL; + break; case 'I': if (strncmp(optarg, "os=", 3)) { fprintf(stderr, @@ -189,6 +193,10 @@ main(int argc, char *argv[]) case 'k': search.argmode = ARG_EXPR; break; + case 'l': + search.argmode = ARG_FILE; + outmode = OUTMODE_ALL; + break; case 'M': defpaths = optarg; break; @@ -280,7 +288,6 @@ main(int argc, char *argv[]) mansearch_setup(1); if( ! mansearch(&search, &paths, argc, argv, &res, &sz)) usage(search.argmode); - manpath_free(&paths); resp = res; if (sz == 0) { @@ -363,9 +370,11 @@ main(int argc, char *argv[]) while (argc) { #if HAVE_SQLITE3 if (resp != NULL) { - if (resp->form) + if (resp->form & FORM_SRC) { + /* For .so only; ignore failure. */ + chdir(paths.paths[resp->ipath]); parse(&curp, -1, resp->file, &rc); - else + } else rc = passthrough(resp->file); resp++; } else @@ -384,6 +393,7 @@ main(int argc, char *argv[]) #if HAVE_SQLITE3 out: if (search.argmode != ARG_FILE) { + manpath_free(&paths); mansearch_free(res, sz); mansearch_setup(0); } @@ -408,22 +418,23 @@ usage(enum argmode argmode) switch (argmode) { case ARG_FILE: - fputs("usage: mandoc [-V] [-Ios=name] [-mformat]" - " [-Ooption] [-Toutput] [-Wlevel]\n" + fputs("usage: mandoc [-acfhklV] [-Ios=name] " + "[-mformat] [-Ooption] [-Toutput] [-Wlevel]\n" "\t [file ...]\n", stderr); break; case ARG_NAME: - fputs("usage: man [-acfhkVw] [-C file] " + fputs("usage: man [-acfhklVw] [-C file] " "[-M path] [-m path] [-S arch] [-s section]\n" "\t [section] name ...\n", stderr); break; case ARG_WORD: - fputs("usage: whatis [-V] [-C file] [-M path] [-m path] " - "[-S arch] [-s section] name ...\n", stderr); + fputs("usage: whatis [-acfhklVw] [-C file] " + "[-M path] [-m path] [-O outkey] [-S arch]\n" + "\t [-s section] name ...\n", stderr); break; case ARG_EXPR: - fputs("usage: apropos [-V] [-C file] [-M path] [-m path] " - "[-O outkey] [-S arch]\n" + fputs("usage: apropos [-acfhklVw] [-C file] " + "[-M path] [-m path] [-O outkey] [-S arch]\n" "\t [-s section] expression ...\n", stderr); break; }