aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-03 05:22:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-03 05:22:45 +0000
commit02046d75d7ec4c27ec31d04e15c9d9fe018a01ab (patch)
tree88fb456e129ed40338e63c83d92faea4da97a7b1 /mdoc_term.c
parent62dcabc9f407fb96cb3f2517d3f6d5f39dd756b1 (diff)
downloadmandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.tar.gz
mandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.tar.zst
mandoc-02046d75d7ec4c27ec31d04e15c9d9fe018a01ab.zip
Implement the traditional -h option for man(1): show the SYNOPSIS only.
As usual, we get mandoc -h and apropos -h for free. Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec". Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c43
1 files changed, 25 insertions, 18 deletions
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);