aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--apropos.111
-rw-r--r--main.c14
-rw-r--r--man.111
-rw-r--r--man_term.c40
-rw-r--r--mandoc.110
-rw-r--r--mdoc_term.c43
-rw-r--r--term.h3
-rw-r--r--term_ascii.c10
8 files changed, 89 insertions, 53 deletions
diff --git a/apropos.1 b/apropos.1
index 6affb6c4..50b250d0 100644
--- a/apropos.1
+++ b/apropos.1
@@ -1,4 +1,4 @@
-.\" $Id: apropos.1,v 1.34 2014/08/30 18:08:10 schwarze Exp $
+.\" $Id: apropos.1,v 1.35 2014/09/03 05:22:45 schwarze Exp $
.\"
.\" Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 30 2014 $
+.Dd $Mdocdate: September 3 2014 $
.Dt APROPOS 1
.Os
.Sh NAME
@@ -24,7 +24,7 @@
.Nd search manual page databases
.Sh SYNOPSIS
.Nm
-.Op Fl acfklVw
+.Op Fl acfhklVw
.Op Fl C Ar file
.Op Fl M Ar path
.Op Fl m Ar path
@@ -107,6 +107,11 @@ This overrides any earlier
and
.Fl l
options.
+.It Fl h
+Instead of showing the title lines, show the SYNOPSIS sections, just like
+.Xr man 1
+.Fl h
+would.
.It Fl k
Support the full
.Ar expression
diff --git a/main.c b/main.c
index a6d5013b..81f2d0c9 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.189 2014/09/01 22:45:53 schwarze Exp $ */
+/* $Id: main.c,v 1.190 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
show_usage = 0;
outmode = OUTMODE_DEF;
- while (-1 != (c = getopt(argc, argv, "aC:cfI:iklM: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,
@@ -414,7 +418,7 @@ usage(enum argmode argmode)
switch (argmode) {
case ARG_FILE:
- fputs("usage: mandoc [-acfklV] [-Ios=name] "
+ fputs("usage: mandoc [-acfhklV] [-Ios=name] "
"[-mformat] [-Ooption] [-Toutput] [-Wlevel]\n"
"\t [file ...]\n", stderr);
break;
@@ -424,12 +428,12 @@ usage(enum argmode argmode)
"\t [section] name ...\n", stderr);
break;
case ARG_WORD:
- fputs("usage: whatis [-acfklVw] [-C file] "
+ 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 [-acfklVw] [-C file] "
+ fputs("usage: apropos [-acfhklVw] [-C file] "
"[-M path] [-m path] [-O outkey] [-S arch]\n"
"\t [-s section] expression ...\n", stderr);
break;
diff --git a/man.1 b/man.1
index bff2fd5e..b9644446 100644
--- a/man.1
+++ b/man.1
@@ -1,5 +1,4 @@
-.\" $Id: man.1,v 1.4 2014/08/30 18:08:10 schwarze Exp $
-.\" $OpenBSD: man.1,v 1.55 2014/04/03 06:15:18 jmc Exp $
+.\" $Id: man.1,v 1.5 2014/09/03 05:22:45 schwarze Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +31,7 @@
.\"
.\" @(#)man.1 8.2 (Berkeley) 1/2/94
.\"
-.Dd $Mdocdate: August 30 2014 $
+.Dd $Mdocdate: September 3 2014 $
.Dt MAN 1
.Os
.Sh NAME
@@ -97,9 +96,9 @@ and
.Fl l
options.
.It Fl h
-Display only the
-.Dq SYNOPSIS
-lines of the requested manual pages.
+Display only the SYNOPSIS lines of the requested manual pages.
+Implies
+.Fl a .
.It Fl k
A synonym for
.Xr apropos 1 .
diff --git a/man_term.c b/man_term.c
index d61b728d..3057d326 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.150 2014/08/10 23:54:41 schwarze Exp $ */
+/* $Id: man_term.c,v 1.151 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -141,38 +141,50 @@ void
terminal_man(void *arg, const struct man *man)
{
struct termp *p;
- const struct man_node *n;
const struct man_meta *meta;
+ struct man_node *n;
struct mtermp mt;
p = (struct termp *)arg;
- if (0 == p->defindent)
- p->defindent = 7;
-
p->overstep = 0;
- p->maxrmargin = p->defrmargin;
+ p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
p->symtab = mchars_alloc();
- n = man_node(man);
+ n = man_node(man)->child;
meta = man_meta(man);
- term_begin(p, print_man_head, print_man_foot, meta);
- p->flags |= TERMP_NOSPACE;
-
memset(&mt, 0, sizeof(struct mtermp));
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
mt.offset = term_len(p, p->defindent);
mt.pardist = 1;
- if (n->child)
- print_man_nodelist(p, &mt, n->child, meta);
-
- term_end(p);
+ if (p->synopsisonly) {
+ while (n != NULL) {
+ if (n->tok == MAN_SH &&
+ n->child->child->type == MAN_TEXT &&
+ !strcmp(n->child->child->string, "SYNOPSIS")) {
+ if (n->child->next->child != NULL)
+ print_man_nodelist(p, &mt,
+ n->child->next->child, meta);
+ term_newln(p);
+ break;
+ }
+ n = n->next;
+ }
+ } else {
+ if (p->defindent == 0)
+ p->defindent = 7;
+ term_begin(p, print_man_head, print_man_foot, meta);
+ p->flags |= TERMP_NOSPACE;
+ if (n != NULL)
+ print_man_nodelist(p, &mt, n, meta);
+ term_end(p);
+ }
}
diff --git a/mandoc.1 b/mandoc.1
index dea7d2bd..6df15edc 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.109 2014/08/30 18:08:10 schwarze Exp $
+.\" $Id: mandoc.1,v 1.110 2014/09/03 05:22:45 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 30 2014 $
+.Dd $Mdocdate: September 3 2014 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Nd format and display UNIX manuals
.Sh SYNOPSIS
.Nm mandoc
-.Op Fl acfklV
+.Op Fl acfhklV
.Sm off
.Op Fl I Cm os Li = Ar name
.Sm on
@@ -85,6 +85,10 @@ for the
.Xr mdoc 7
.Sq \&Os
macro.
+.It Fl h
+Display only the SYNOPSIS lines.
+Implies
+.Fl a .
.It Fl k
A synonym for
.Xr apropos 1 .
diff --git a/mdoc_term.c b/mdoc_term.c
index f10b5c49..21aa4a7c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.280 2014/08/21 12:57:17 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.281 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -252,34 +252,44 @@ static const struct termact termacts[MDOC_MAX] = {
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
- const struct mdoc_node *n;
const struct mdoc_meta *meta;
+ struct mdoc_node *n;
struct termp *p;
p = (struct termp *)arg;
- if (0 == p->defindent)
- p->defindent = 5;
-
p->overstep = 0;
- p->maxrmargin = p->defrmargin;
+ p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
p->symtab = mchars_alloc();
- n = mdoc_node(mdoc);
+ n = mdoc_node(mdoc)->child;
meta = mdoc_meta(mdoc);
- term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
-
- if (n->child) {
- if (MDOC_Sh != n->child->tok)
- term_vspace(p);
- print_mdoc_nodelist(p, NULL, meta, n->child);
+ if (p->synopsisonly) {
+ while (n != NULL) {
+ if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
+ if (n->child->next->child != NULL)
+ print_mdoc_nodelist(p, NULL,
+ meta, n->child->next->child);
+ term_newln(p);
+ break;
+ }
+ n = n->next;
+ }
+ } else {
+ if (p->defindent == 0)
+ p->defindent = 5;
+ term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
+ if (n != NULL) {
+ if (n->tok != MDOC_Sh)
+ term_vspace(p);
+ print_mdoc_nodelist(p, NULL, meta, n);
+ }
+ term_end(p);
}
-
- term_end(p);
}
static void
@@ -463,9 +473,6 @@ print_mdoc_head(struct termp *p, const void *arg)
* switches on the manual section.
*/
- p->offset = 0;
- p->rmargin = p->maxrmargin;
-
assert(meta->vol);
if (NULL == meta->arch)
volume = mandoc_strdup(meta->vol);
diff --git a/term.h b/term.h
index decd7f40..e1eec88d 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.101 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: term.h,v 1.102 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -54,6 +54,7 @@ struct termp_tbl {
struct termp {
enum termtype type;
struct rofftbl tbl; /* table configuration */
+ int synopsisonly; /* print the synopsis only */
int mdocstyle; /* imitate mdoc(7) output */
size_t defindent; /* Default indent for text. */
size_t defrmargin; /* Right margin of the device. */
diff --git a/term_ascii.c b/term_ascii.c
index ab629026..887710a2 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,4 +1,4 @@
-/* $Id: term_ascii.c,v 1.32 2014/08/17 22:10:29 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.33 2014/09/03 05:22:45 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -58,7 +58,7 @@ static size_t locale_width(const struct termp *, int);
static struct termp *
ascii_init(enum termenc enc, char *outopts)
{
- const char *toks[4];
+ const char *toks[5];
char *v;
struct termp *p;
@@ -97,7 +97,8 @@ ascii_init(enum termenc enc, char *outopts)
toks[0] = "indent";
toks[1] = "width";
toks[2] = "mdoc";
- toks[3] = NULL;
+ toks[3] = "synopsis";
+ toks[4] = NULL;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
@@ -115,6 +116,9 @@ ascii_init(enum termenc enc, char *outopts)
p->mdocstyle = 1;
p->defindent = 5;
break;
+ case 3:
+ p->synopsisonly = 1;
+ break;
default:
break;
}