aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-02 23:48:19 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-02 23:48:19 +0000
commit56db51154e503662dc8c9cfed83c0bc0172a3f82 (patch)
tree95b7ad594c05dbe72ec6e2c2cec8bbbc787bcb47
parent8a1e7c36cb8b9ca64c677d1ff9d786c9e46fd7b0 (diff)
downloadmandoc-56db51154e503662dc8c9cfed83c0bc0172a3f82.tar.gz
mandoc-56db51154e503662dc8c9cfed83c0bc0172a3f82.tar.zst
mandoc-56db51154e503662dc8c9cfed83c0bc0172a3f82.zip
Third step towards parser unification:
Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
-rw-r--r--libman.h4
-rw-r--r--libmdoc.h4
-rw-r--r--man.c8
-rw-r--r--man.h13
-rw-r--r--man_html.c8
-rw-r--r--man_term.c34
-rw-r--r--man_validate.c26
-rw-r--r--mandoc_headers.325
-rw-r--r--mandocdb.c48
-rw-r--r--mdoc.c10
-rw-r--r--mdoc.h14
-rw-r--r--mdoc_html.c4
-rw-r--r--mdoc_man.c6
-rw-r--r--mdoc_term.c20
-rw-r--r--roff.h11
-rw-r--r--term.c8
-rw-r--r--term.h13
17 files changed, 125 insertions, 131 deletions
diff --git a/libman.h b/libman.h
index 62c7f294..d20e1b77 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.69 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: libman.h,v 1.70 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,7 +33,7 @@ struct man {
enum man_next next; /* where to put the next node */
struct roff_node *last; /* the last parsed node */
struct roff_node *first; /* the first parsed node */
- struct man_meta meta; /* document meta-data */
+ struct roff_meta meta; /* document meta-data */
struct roff *roff;
};
diff --git a/libmdoc.h b/libmdoc.h
index ceaf217e..5e749cc9 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.98 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.99 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -40,7 +40,7 @@ struct mdoc {
struct roff_node *last; /* the last node parsed */
struct roff_node *first; /* the first node parsed */
struct roff_node *last_es; /* the most recent Es node */
- struct mdoc_meta meta; /* document meta-data */
+ struct roff_meta meta; /* document meta-data */
enum roff_sec lastnamed;
enum roff_sec lastsec;
struct roff *roff;
diff --git a/man.c b/man.c
index aa1e4ac1..2a756560 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.151 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: man.c,v 1.152 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -69,7 +69,7 @@ man_node(const struct man *man)
return(man->first);
}
-const struct man_meta *
+const struct roff_meta *
man_meta(const struct man *man)
{
@@ -136,7 +136,7 @@ man_free1(struct man *man)
if (man->first)
man_node_delete(man, man->first);
free(man->meta.title);
- free(man->meta.source);
+ free(man->meta.os);
free(man->meta.date);
free(man->meta.vol);
free(man->meta.msec);
@@ -146,7 +146,7 @@ static void
man_alloc1(struct man *man)
{
- memset(&man->meta, 0, sizeof(struct man_meta));
+ memset(&man->meta, 0, sizeof(man->meta));
man->flags = 0;
man->last = mandoc_calloc(1, sizeof(*man->last));
man->first = man->last;
diff --git a/man.h b/man.h
index 66f75813..c27703a1 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.71 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: man.h,v 1.72 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -56,15 +56,6 @@
#define MAN_ll 37
#define MAN_MAX 38
-struct man_meta {
- char *msec; /* `TH' section (1, 3p, etc.) */
- char *date; /* `TH' normalised date */
- char *vol; /* `TH' volume */
- char *title; /* `TH' title (e.g., FOO) */
- char *source; /* `TH' source (e.g., GNU) */
- int hasbody; /* document is not empty */
-};
-
/* Names of macros. */
extern const char *const *man_macronames;
@@ -73,7 +64,7 @@ __BEGIN_DECLS
struct man;
const struct roff_node *man_node(const struct man *);
-const struct man_meta *man_meta(const struct man *);
+const struct roff_meta *man_meta(const struct man *);
const struct mparse *man_mparse(const struct man *);
void man_deroff(char **, const struct roff_node *);
diff --git a/man_html.c b/man_html.c
index 7533e979..51de28fd 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.114 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: man_html.c,v 1.115 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -37,7 +37,7 @@
#define INDENT 5
-#define MAN_ARGS const struct man_meta *man, \
+#define MAN_ARGS const struct roff_meta *man, \
const struct roff_node *n, \
struct mhtml *mh, \
struct html *h
@@ -348,8 +348,8 @@ man_root_post(MAN_ARGS)
PAIR_CLASS_INIT(&tag, "foot-os");
print_otag(h, TAG_TD, 1, &tag);
- if (man->source)
- print_text(h, man->source);
+ if (man->os)
+ print_text(h, man->os);
print_tagq(h, t);
}
diff --git a/man_term.c b/man_term.c
index cd1a2099..0404731a 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.172 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: man_term.c,v 1.173 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -49,7 +49,7 @@ struct mtermp {
#define DECL_ARGS struct termp *p, \
struct mtermp *mt, \
struct roff_node *n, \
- const struct man_meta *meta
+ const struct roff_meta *meta
struct termact {
int (*pre)(DECL_ARGS);
@@ -60,8 +60,10 @@ struct termact {
static void print_man_nodelist(DECL_ARGS);
static void print_man_node(DECL_ARGS);
-static void print_man_head(struct termp *, const void *);
-static void print_man_foot(struct termp *, const void *);
+static void print_man_head(struct termp *,
+ const struct roff_meta *);
+static void print_man_foot(struct termp *,
+ const struct roff_meta *);
static void print_bvspace(struct termp *,
const struct roff_node *, int);
@@ -139,7 +141,7 @@ void
terminal_man(void *arg, const struct man *man)
{
struct termp *p;
- const struct man_meta *meta;
+ const struct roff_meta *meta;
struct roff_node *n;
struct mtermp mt;
@@ -1012,13 +1014,11 @@ print_man_nodelist(DECL_ARGS)
}
static void
-print_man_foot(struct termp *p, const void *arg)
+print_man_foot(struct termp *p, const struct roff_meta *meta)
{
- const struct man_meta *meta;
char *title;
size_t datelen, titlen;
- meta = (const struct man_meta *)arg;
assert(meta->title);
assert(meta->msec);
assert(meta->date);
@@ -1030,8 +1030,8 @@ print_man_foot(struct termp *p, const void *arg)
/*
* Temporary, undocumented option to imitate mdoc(7) output.
- * In the bottom right corner, use the source instead of
- * the title.
+ * In the bottom right corner, use the operating system
+ * instead of the title.
*/
if ( ! p->mdocstyle) {
@@ -1041,14 +1041,14 @@ print_man_foot(struct termp *p, const void *arg)
}
mandoc_asprintf(&title, "%s(%s)",
meta->title, meta->msec);
- } else if (meta->source) {
- title = mandoc_strdup(meta->source);
+ } else if (meta->os) {
+ title = mandoc_strdup(meta->os);
} else {
title = mandoc_strdup("");
}
datelen = term_strlen(p, meta->date);
- /* Bottom left corner: manual source. */
+ /* Bottom left corner: operating system. */
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
p->trailspace = 1;
@@ -1056,8 +1056,8 @@ print_man_foot(struct termp *p, const void *arg)
p->rmargin = p->maxrmargin > datelen ?
(p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0;
- if (meta->source)
- term_word(p, meta->source);
+ if (meta->os)
+ term_word(p, meta->os);
term_flushln(p);
/* At the bottom in the middle: manual date. */
@@ -1084,14 +1084,12 @@ print_man_foot(struct termp *p, const void *arg)
}
static void
-print_man_head(struct termp *p, const void *arg)
+print_man_head(struct termp *p, const struct roff_meta *meta)
{
- const struct man_meta *meta;
const char *volume;
char *title;
size_t vollen, titlen;
- meta = (const struct man_meta *)arg;
assert(meta->title);
assert(meta->msec);
diff --git a/man_validate.c b/man_validate.c
index a73be7ca..3a695d00 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -305,16 +305,16 @@ post_TH(CHKARGS)
free(man->meta.title);
free(man->meta.vol);
- free(man->meta.source);
+ free(man->meta.os);
free(man->meta.msec);
free(man->meta.date);
man->meta.title = man->meta.vol = man->meta.date =
- man->meta.msec = man->meta.source = NULL;
+ man->meta.msec = man->meta.os = NULL;
nb = n;
- /* ->TITLE<- MSEC DATE SOURCE VOL */
+ /* ->TITLE<- MSEC DATE OS VOL */
n = n->child;
if (n && n->string) {
@@ -336,7 +336,7 @@ post_TH(CHKARGS)
nb->line, nb->pos, "TH");
}
- /* TITLE ->MSEC<- DATE SOURCE VOL */
+ /* TITLE ->MSEC<- DATE OS VOL */
if (n)
n = n->next;
@@ -348,7 +348,7 @@ post_TH(CHKARGS)
nb->line, nb->pos, "TH %s", man->meta.title);
}
- /* TITLE MSEC ->DATE<- SOURCE VOL */
+ /* TITLE MSEC ->DATE<- OS VOL */
if (n)
n = n->next;
@@ -364,14 +364,14 @@ post_TH(CHKARGS)
n ? n->pos : nb->pos, "TH");
}
- /* TITLE MSEC DATE ->SOURCE<- VOL */
+ /* TITLE MSEC DATE ->OS<- VOL */
if (n && (n = n->next))
- man->meta.source = mandoc_strdup(n->string);
+ man->meta.os = mandoc_strdup(n->string);
else if (man->defos != NULL)
- man->meta.source = mandoc_strdup(man->defos);
+ man->meta.os = mandoc_strdup(man->defos);
- /* TITLE MSEC DATE SOURCE ->VOL<- */
+ /* TITLE MSEC DATE OS ->VOL<- */
/* If missing, use the default VOL name for MSEC. */
if (n && (n = n->next))
@@ -446,8 +446,8 @@ post_UC(CHKARGS)
p = bsd_versions[0];
}
- free(man->meta.source);
- man->meta.source = mandoc_strdup(p);
+ free(man->meta.os);
+ man->meta.os = mandoc_strdup(p);
}
static void
@@ -485,8 +485,8 @@ post_AT(CHKARGS)
p = unix_versions[0];
}
- free(man->meta.source);
- man->meta.source = mandoc_strdup(p);
+ free(man->meta.os);
+ man->meta.os = mandoc_strdup(p);
}
static void
diff --git a/mandoc_headers.3 b/mandoc_headers.3
index d3400876..85cf1894 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -121,6 +121,7 @@ Provides
.Vt enum mdoc_endbody ,
.Vt enum roff_sec ,
.Vt enum roff_type ,
+.Vt struct roff_meta ,
and
.Vt struct roff_node .
.Pp
@@ -154,7 +155,6 @@ Provides
.Vt enum mdoc_list ,
.Vt enum mdoc_auth ,
.Vt enum mdoc_font ,
-.Vt struct mdoc_meta ,
.Vt struct mdoc_argv ,
.Vt struct mdoc_arg ,
.Vt struct mdoc_bd ,
@@ -188,9 +188,7 @@ Requires
for
.Vt enum roff_type .
.Pp
-Provides
-.Vt struct man_meta
-and the functions
+Provides the functions
.Fn man_*
described in
.Xr mandoc 3 .
@@ -226,11 +224,16 @@ are included, the same file should not include any formatter headers.
Requires
.In sys/types.h
for
-.Vt size_t
-and
+.Vt size_t ,
.Qq Pa mandoc.h
for
-.Vt enum mandocerr .
+.Vt enum mandocerr ,
+and
+.Qq Pa roff.h
+for
+.Vt struct roff_meta
+and
+.Vt struct roff_node .
.Pp
Provides
.Vt enum rofferr ,
@@ -297,7 +300,9 @@ or
Requires
.Qq Pa roff.h
for
-.Vt struct roff_node.
+.Vt struct roff_meta
+and
+.Vt struct roff_node .
.Pp
Provides
.Vt enum man_next ,
@@ -420,6 +425,10 @@ and
.Vt struct eqn
from
.Pa mandoc.h
+and
+.Vt struct roff_meta
+from
+.Qq Pa roff.h
as opaque types for function prototypes.
.Pp
When this header is included, the same file should not include
diff --git a/mandocdb.c b/mandocdb.c
index 73d7b108..55cb877d 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.189 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.190 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -130,7 +130,7 @@ enum stmt {
STMT__MAX
};
-typedef int (*mdoc_fp)(struct mpage *, const struct mdoc_meta *,
+typedef int (*mdoc_fp)(struct mpage *, const struct roff_meta *,
const struct roff_node *);
struct mdoc_handler {
@@ -156,28 +156,28 @@ static void mpages_free(void);
static void mpages_merge(struct mparse *);
static void names_check(void);
static void parse_cat(struct mpage *, int);
-static void parse_man(struct mpage *, const struct man_meta *,
+static void parse_man(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static void parse_mdoc(struct mpage *, const struct mdoc_meta *,
+static void parse_mdoc(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_body(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_head(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_head(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Fd(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static void parse_mdoc_fname(struct mpage *, const struct roff_node *);
-static int parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Fn(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Fo(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Fo(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Nd(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Nd(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Nm(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Nm(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Sh(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Sh(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_Xr(struct mpage *, const struct mdoc_meta *,
+static int parse_mdoc_Xr(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static void putkey(const struct mpage *, char *, uint64_t);
static void putkeys(const struct mpage *, char *, size_t, uint64_t);
@@ -1443,7 +1443,7 @@ putmdockey(const struct mpage *mpage,
}
static void
-parse_man(struct mpage *mpage, const struct man_meta *meta,
+parse_man(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
const struct roff_node *head, *body;
@@ -1569,7 +1569,7 @@ parse_man(struct mpage *mpage, const struct man_meta *meta,
}
static void
-parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1602,7 +1602,7 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fd(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
char *start, *end;
@@ -1667,7 +1667,7 @@ parse_mdoc_fname(struct mpage *mpage, const struct roff_node *n)
}
static int
-parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fn(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1684,7 +1684,7 @@ parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fo(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1698,7 +1698,7 @@ parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
char *cp;
@@ -1718,7 +1718,7 @@ parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Nd(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1728,7 +1728,7 @@ parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Nm(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1750,7 +1750,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Sh(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1758,7 +1758,7 @@ parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_head(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1766,7 +1766,7 @@ parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
}
static int
-parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_body(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
diff --git a/mdoc.c b/mdoc.c
index 9890b79b..6398c613 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.240 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.241 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -102,7 +102,7 @@ mdoc_node(const struct mdoc *mdoc)
return(mdoc->first);
}
-const struct mdoc_meta *
+const struct roff_meta *
mdoc_meta(const struct mdoc *mdoc)
{
@@ -134,7 +134,7 @@ static void
mdoc_alloc1(struct mdoc *mdoc)
{
- memset(&mdoc->meta, 0, sizeof(struct mdoc_meta));
+ memset(&mdoc->meta, 0, sizeof(mdoc->meta));
mdoc->flags = 0;
mdoc->lastnamed = mdoc->lastsec = SEC_NONE;
mdoc->last = mandoc_calloc(1, sizeof(*mdoc->last));
diff --git a/mdoc.h b/mdoc.h
index ad2ef3ac..4b3aa654 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.138 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.139 2015/04/02 23:48:19 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -172,16 +172,6 @@ enum mdocargt {
MDOC_ARG_MAX
};
-struct mdoc_meta {
- char *msec; /* `Dt' section (1, 3p, etc.) */
- char *vol; /* `Dt' volume (implied) */
- char *arch; /* `Dt' arch (i386, etc.) */
- char *date; /* `Dd' normalised date */
- char *title; /* `Dt' title (FOO, etc.) */
- char *os; /* `Os' system (OpenBSD, etc.) */
- char *name; /* leading `Nm' name */
-};
-
/*
* An argument to a macro (multiple values = `-column xxx yyy').
*/
@@ -295,7 +285,7 @@ __BEGIN_DECLS
struct mdoc;
const struct roff_node *mdoc_node(const struct mdoc *);
-const struct mdoc_meta *mdoc_meta(const struct mdoc *);
+const struct roff_meta *mdoc_meta(const struct mdoc *);
void mdoc_deroff(char **, const struct roff_node *);
__END_DECLS
diff --git a/mdoc_html.c b/mdoc_html.c
index 654a37bb..f785e8f4 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.228 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.229 2015/04/02 23:48:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -35,7 +35,7 @@
#define INDENT 5
-#define MDOC_ARGS const struct mdoc_meta *meta, \
+#define MDOC_ARGS const struct roff_meta *meta, \
struct roff_node *n, \
struct html *h
diff --git a/mdoc_man.c b/mdoc_man.c
index e1068ace..b7222586 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.90 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.91 2015/04/02 23:48:20 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -30,7 +30,7 @@
#include "out.h"
#include "main.h"
-#define DECL_ARGS const struct mdoc_meta *meta, struct roff_node *n
+#define DECL_ARGS const struct roff_meta *meta, struct roff_node *n
struct manact {
int (*cond)(DECL_ARGS); /* DON'T run actions */
@@ -547,7 +547,7 @@ man_man(void *arg, const struct man *man)
void
man_mdoc(void *arg, const struct mdoc *mdoc)
{
- const struct mdoc_meta *meta;
+ const struct roff_meta *meta;
struct roff_node *n;
meta = mdoc_meta(mdoc);
diff --git a/mdoc_term.c b/mdoc_term.c
index 410f941e..44b03b5c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.315 2015/04/02 22:48:17 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.316 2015/04/02 23:48:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -43,7 +43,7 @@ struct termpair {
#define DECL_ARGS struct termp *p, \
struct termpair *pair, \
- const struct mdoc_meta *meta, \
+ const struct roff_meta *meta, \
struct roff_node *n
struct termact {
@@ -58,8 +58,8 @@ static void print_bvspace(struct termp *,
const struct roff_node *);
static void print_mdoc_node(DECL_ARGS);
static void print_mdoc_nodelist(DECL_ARGS);
-static void print_mdoc_head(struct termp *, const void *);
-static void print_mdoc_foot(struct termp *, const void *);
+static void print_mdoc_head(struct termp *, const struct roff_meta *);
+static void print_mdoc_foot(struct termp *, const struct roff_meta *);
static void synopsis_pre(struct termp *,
const struct roff_node *);
@@ -253,7 +253,7 @@ static const struct termact termacts[MDOC_MAX] = {
void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
- const struct mdoc_meta *meta;
+ const struct roff_meta *meta;
struct roff_node *n;
struct termp *p;
@@ -407,13 +407,10 @@ print_mdoc_node(DECL_ARGS)
}
static void
-print_mdoc_foot(struct termp *p, const void *arg)
+print_mdoc_foot(struct termp *p, const struct roff_meta *meta)
{
- const struct mdoc_meta *meta;
size_t sz;
- meta = (const struct mdoc_meta *)arg;
-
term_fontrepl(p, TERMFONT_NONE);
/*
@@ -459,14 +456,11 @@ print_mdoc_foot(struct termp *p, const void *arg)
}
static void
-print_mdoc_head(struct termp *p, const void *arg)
+print_mdoc_head(struct termp *p, const struct roff_meta *meta)
{
- const struct mdoc_meta *meta;
char *volume, *title;
size_t vollen, titlen;
- meta = (const struct mdoc_meta *)arg;
-
/*
* The header is strange. It has three components, which are
* really two with the first duplicated. It goes like this:
diff --git a/roff.h b/roff.h
index 232100c8..42bc5615 100644
--- a/roff.h
+++ b/roff.h
@@ -104,3 +104,14 @@ struct roff_node {
enum roff_sec sec; /* Current named section. */
enum mdoc_endbody end; /* BODY */
};
+
+struct roff_meta {
+ char *msec; /* Manual section, usually a digit. */
+ char *vol; /* Manual volume title. */
+ char *os; /* Operating system. */
+ char *arch; /* Machine architecture. */
+ char *title; /* Manual title, usually CAPS. */
+ char *name; /* Leading manual name. */
+ char *date; /* Normalized date. */
+ int hasbody; /* Document is not empty. */
+};
diff --git a/term.c b/term.c
index ee2af9e6..6476b0e7 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.245 2015/03/06 13:02:43 schwarze Exp $ */
+/* $Id: term.c,v 1.246 2015/04/02 23:48:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -49,7 +49,7 @@ term_free(struct termp *p)
void
term_begin(struct termp *p, term_margin head,
- term_margin foot, const void *arg)
+ term_margin foot, const struct roff_meta *arg)
{
p->headf = head;
diff --git a/term.h b/term.h
index b65524b6..ab34717b 100644
--- a/term.h
+++ b/term.h
@@ -1,15 +1,15 @@
-/* $Id: term.h,v 1.111 2015/01/31 00:12:41 schwarze Exp $ */
+/* $Id: term.h,v 1.112 2015/04/02 23:48:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -38,9 +38,10 @@ enum termfont {
#define TERM_MAXMARGIN 100000 /* FIXME */
+struct roff_meta;
struct termp;
-typedef void (*term_margin)(struct termp *, const void *);
+typedef void (*term_margin)(struct termp *, const struct roff_meta *);
struct termp_tbl {
int width; /* width in fixed chars */
@@ -117,7 +118,7 @@ void term_vspace(struct termp *);
void term_word(struct termp *, const char *);
void term_flushln(struct termp *);
void term_begin(struct termp *, term_margin,
- term_margin, const void *);
+ term_margin, const struct roff_meta *);
void term_end(struct termp *);
void term_setwidth(struct termp *, const char *);