diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/Makefile | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/html.h | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/man_html.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/man_term.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/roff_html.c | 48 | ||||
-rw-r--r-- | usr.bin/mandoc/roff_term.c | 52 | ||||
-rw-r--r-- | usr.bin/mandoc/term.h | 12 |
9 files changed, 137 insertions, 66 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index d5943c1e69f..08c555b9a6f 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.106 2017/04/29 12:43:55 schwarze Exp $ +# $OpenBSD: Makefile,v 1.107 2017/05/04 22:07:44 schwarze Exp $ .include <bsd.own.mk> @@ -6,16 +6,17 @@ CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter DPADD += ${LIBUTIL} LDADD += -lutil -lz -SRCS= mandoc.c mandoc_aux.c mandoc_ohash.c preconv.c read.c \ +SRCS= mandoc_aux.c mandoc_ohash.c mandoc.c chars.c preconv.c read.c \ roff.c tbl.c tbl_opts.c tbl_layout.c tbl_data.c eqn.c SRCS+= mdoc_macro.c mdoc.c \ mdoc_argv.c mdoc_state.c mdoc_validate.c att.c msec.c st.c SRCS+= man_macro.c man.c man_validate.c -SRCS+= main.c mdoc_term.c tag.c chars.c term.c tree.c man_term.c eqn_term.c +SRCS+= main.c out.c tag.c tree.c +SRCS+= term.c term_ascii.c term_ps.c +SRCS+= roff_term.c mdoc_term.c man_term.c eqn_term.c tbl_term.c SRCS+= mdoc_man.c -SRCS+= html.c mdoc_html.c man_html.c out.c eqn_html.c +SRCS+= html.c roff_html.c mdoc_html.c man_html.c eqn_html.c tbl_html.c SRCS+= mdoc_markdown.c -SRCS+= term_ps.c term_ascii.c tbl_term.c tbl_html.c SRCS+= dbm_map.c dbm.c dba_write.c dba_array.c dba.c dba_read.c SRCS+= manpath.c mandocdb.c mansearch.c diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h index b4446f0d665..b4a4c35cb82 100644 --- a/usr.bin/mandoc/html.h +++ b/usr.bin/mandoc/html.h @@ -1,4 +1,4 @@ -/* $OpenBSD: html.h,v 1.46 2017/03/15 11:29:50 schwarze Exp $ */ +/* $OpenBSD: html.h,v 1.47 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -116,6 +116,8 @@ struct roff_node; struct tbl_span; struct eqn; +void roff_html_pre(struct html *, const struct roff_node *); + void print_gen_decls(struct html *); void print_gen_head(struct html *); struct tag *print_otag(struct html *, enum htmltag, const char *, ...); diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index 30f90693618..0aa05cb62d3 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_html.c,v 1.90 2017/05/04 17:48:24 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.91 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -63,11 +63,11 @@ static int man_SM_pre(MAN_ARGS); static int man_SS_pre(MAN_ARGS); static int man_UR_pre(MAN_ARGS); static int man_alt_pre(MAN_ARGS); -static int man_br_pre(MAN_ARGS); static int man_ign_pre(MAN_ARGS); static int man_in_pre(MAN_ARGS); static void man_root_post(MAN_ARGS); static void man_root_pre(MAN_ARGS); +static int man_sp_pre(MAN_ARGS); static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { NULL, NULL }, /* TH */ @@ -90,7 +90,7 @@ static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { man_I_pre, NULL }, /* I */ { man_alt_pre, NULL }, /* IR */ { man_alt_pre, NULL }, /* RI */ - { man_br_pre, NULL }, /* sp */ + { man_sp_pre, NULL }, /* sp */ { NULL, NULL }, /* nf */ { NULL, NULL }, /* fi */ { NULL, NULL }, /* RE */ @@ -303,13 +303,7 @@ print_man_node(MAN_ARGS) t = h->tag; if (n->tok < ROFF_MAX) { - switch(n->tok) { - case ROFF_br: - man_br_pre(man, n, h); - break; - default: - abort(); - } + roff_html_pre(h, n); break; } @@ -421,18 +415,14 @@ man_root_post(MAN_ARGS) static int -man_br_pre(MAN_ARGS) +man_sp_pre(MAN_ARGS) { struct roffsu su; SCALE_VS_INIT(&su, 1); - - if (MAN_sp == n->tok) { - if (NULL != (n = n->child)) - if ( ! a2roffsu(n->string, &su, SCALE_VS)) - su.scale = 1.0; - } else - su.scale = 0.0; + if (NULL != (n = n->child)) + if ( ! a2roffsu(n->string, &su, SCALE_VS)) + su.scale = 1.0; print_otag(h, TAG_DIV, "suh", &su); diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 526606aacba..467d719c7e2 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_term.c,v 1.146 2017/05/04 17:48:24 schwarze Exp $ */ +/* $OpenBSD: man_term.c,v 1.147 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -455,9 +455,7 @@ pre_sp(DECL_ARGS) } } - if (n->tok == ROFF_br) - len = 0; - else if (n->child == NULL) + if (n->child == NULL) len = 1; else { if ( ! a2roffsu(n->child->string, &su, SCALE_VS)) @@ -985,13 +983,7 @@ print_man_node(DECL_ARGS) } if (n->tok < ROFF_MAX) { - switch (n->tok) { - case ROFF_br: - pre_sp(p, mt, n, meta); - break; - default: - abort(); - } + roff_term_pre(p, n); return; } diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index 72afef4cf03..de61d94cfcb 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_html.c,v 1.156 2017/05/04 17:48:24 schwarze Exp $ */ +/* $OpenBSD: mdoc_html.c,v 1.157 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -392,13 +392,7 @@ print_mdoc_node(MDOC_ARGS) } assert(h->tblt == NULL); if (n->tok < ROFF_MAX) { - switch(n->tok) { - case ROFF_br: - mdoc_sp_pre(meta, n, h); - break; - default: - abort(); - } + roff_html_pre(h, n); break; } assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); @@ -1335,16 +1329,12 @@ mdoc_sp_pre(MDOC_ARGS) struct roffsu su; SCALE_VS_INIT(&su, 1); - - if (MDOC_sp == n->tok) { - if (NULL != (n = n->child)) { - if ( ! a2roffsu(n->string, &su, SCALE_VS)) - su.scale = 1.0; - else if (su.scale < 0.0) - su.scale = 0.0; - } - } else - su.scale = 0.0; + if (NULL != (n = n->child)) { + if ( ! a2roffsu(n->string, &su, SCALE_VS)) + su.scale = 1.0; + else if (su.scale < 0.0) + su.scale = 0.0; + } print_otag(h, TAG_DIV, "suh", &su); diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 7dd2f7e2447..4f33c5865a0 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_term.c,v 1.250 2017/05/04 17:48:24 schwarze Exp $ */ +/* $OpenBSD: mdoc_term.c,v 1.251 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -363,13 +363,7 @@ print_mdoc_node(DECL_ARGS) break; default: if (n->tok < ROFF_MAX) { - switch (n->tok) { - case ROFF_br: - termp_sp_pre(p, &npair, meta, n); - break; - default: - abort(); - } + roff_term_pre(p, n); break; } assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); diff --git a/usr.bin/mandoc/roff_html.c b/usr.bin/mandoc/roff_html.c new file mode 100644 index 00000000000..d6c460ac47d --- /dev/null +++ b/usr.bin/mandoc/roff_html.c @@ -0,0 +1,48 @@ +/* $OpenBSD: roff_html.c,v 1.1 2017/05/04 22:07:44 schwarze Exp $ */ +/* + * Copyright (c) 2017 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 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/types.h> + +#include <assert.h> + +#include "roff.h" +#include "out.h" +#include "html.h" + +#define ROFF_HTML_ARGS struct html *h, const struct roff_node *n + +typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS); + +static void roff_html_pre_br(ROFF_HTML_ARGS); + +static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = { + roff_html_pre_br, /* br */ +}; + + +void +roff_html_pre(struct html *h, const struct roff_node *n) +{ + assert(n->tok < ROFF_MAX); + (*roff_html_pre_acts[n->tok])(h, n); +} + +static void +roff_html_pre_br(ROFF_HTML_ARGS) +{ + print_otag(h, TAG_DIV, ""); + print_text(h, "\\~"); /* So the div isn't empty. */ +} diff --git a/usr.bin/mandoc/roff_term.c b/usr.bin/mandoc/roff_term.c new file mode 100644 index 00000000000..c4e5b818cd4 --- /dev/null +++ b/usr.bin/mandoc/roff_term.c @@ -0,0 +1,52 @@ +/* $OpenBSD: roff_term.c,v 1.1 2017/05/04 22:07:44 schwarze Exp $ */ +/* + * Copyright (c) 2017 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 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/types.h> + +#include <assert.h> + +#include "roff.h" +#include "out.h" +#include "term.h" + +#define ROFF_TERM_ARGS struct termp *p, const struct roff_node *n + +typedef void (*roff_term_pre_fp)(ROFF_TERM_ARGS); + +static void roff_term_pre_br(ROFF_TERM_ARGS); + +static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = { + roff_term_pre_br, /* br */ +}; + + +void +roff_term_pre(struct termp *p, const struct roff_node *n) +{ + assert(n->tok < ROFF_MAX); + (*roff_term_pre_acts[n->tok])(p, n); +} + +static void +roff_term_pre_br(ROFF_TERM_ARGS) +{ + term_newln(p); + if (p->flags & TERMP_BRIND) { + p->offset = p->rmargin; + p->rmargin = p->maxrmargin; + p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); + } +} diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h index 770d24f3d29..4b688de65d5 100644 --- a/usr.bin/mandoc/term.h +++ b/usr.bin/mandoc/term.h @@ -1,7 +1,7 @@ -/* $OpenBSD: term.h,v 1.62 2015/11/07 13:57:55 schwarze Exp $ */ +/* $OpenBSD: term.h,v 1.63 2017/05/04 22:07:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2011-2015, 2017 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 @@ -38,7 +38,10 @@ enum termfont { #define TERM_MAXMARGIN 100000 /* FIXME */ +struct eqn; struct roff_meta; +struct roff_node; +struct tbl_span; struct termp; typedef void (*term_margin)(struct termp *, const struct roff_meta *); @@ -106,11 +109,10 @@ struct termp { }; -struct tbl_span; -struct eqn; - const char *ascii_uc2str(int); +void roff_term_pre(struct termp *, const struct roff_node *); + void term_eqn(struct termp *, const struct eqn *); void term_tbl(struct termp *, const struct tbl_span *); void term_free(struct termp *); |