diff options
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.h | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 49 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 19 |
4 files changed, 72 insertions, 8 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index f904ea1297b..1fc7a423202 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.73 2010/12/21 23:57:31 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.74 2010/12/26 21:04:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -541,6 +541,9 @@ mdoc_node_free(struct mdoc_node *p) if (MDOC_An == p->tok) if (p->data.An) free(p->data.An); + if (MDOC_Rs == p->tok && MDOC_BLOCK == p->type) + if (p->data.Rs) + free(p->data.Rs); if (MDOC_TS == p->tok && MDOC_BLOCK == p->type) if (p->data.TS) tbl_free(p->data.TS); diff --git a/usr.bin/mandoc/mdoc.h b/usr.bin/mandoc/mdoc.h index 58743e37deb..39a9275f274 100644 --- a/usr.bin/mandoc/mdoc.h +++ b/usr.bin/mandoc/mdoc.h @@ -1,4 +1,4 @@ -/* $Id: mdoc.h,v 1.38 2010/12/21 23:57:31 schwarze Exp $ */ +/* $Id: mdoc.h,v 1.39 2010/12/26 21:04:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -355,6 +355,10 @@ struct mdoc_an { enum mdoc_auth auth; /* -split, etc. */ }; +struct mdoc_rs { + struct mdoc_node *child_J; /* pointer to %J */ +}; + /* * Consists of normalised node arguments. These should be used instead * of iterating through the mdoc_arg pointers of a node: defaults are @@ -365,6 +369,7 @@ union mdoc_data { struct mdoc_bd *Bd; struct mdoc_bf *Bf; struct mdoc_bl *Bl; + struct mdoc_rs *Rs; struct tbl *TS; }; diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 4889626530f..39fa4dc365e 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.119 2010/12/21 23:57:31 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.120 2010/12/26 21:04:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -65,6 +65,7 @@ static void synopsis_pre(struct termp *, const struct mdoc_node *); static void termp____post(DECL_ARGS); +static void termp__t_post(DECL_ARGS); static void termp_an_post(DECL_ARGS); static void termp_bd_post(DECL_ARGS); static void termp_bk_post(DECL_ARGS); @@ -82,6 +83,7 @@ static void termp_sh_post(DECL_ARGS); static void termp_ss_post(DECL_ARGS); static int termp__a_pre(DECL_ARGS); +static int termp__t_pre(DECL_ARGS); static int termp_an_pre(DECL_ARGS); static int termp_ap_pre(DECL_ARGS); static int termp_bd_pre(DECL_ARGS); @@ -172,7 +174,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, termp____post }, /* %O */ { NULL, termp____post }, /* %P */ { NULL, termp____post }, /* %R */ - { termp_under_pre, termp____post }, /* %T */ + { termp__t_pre, termp__t_post }, /* %T */ { NULL, termp____post }, /* %V */ { NULL, NULL }, /* Ac */ { termp_quote_pre, termp_quote_post }, /* Ao */ @@ -1833,7 +1835,7 @@ static int termp_quote_pre(DECL_ARGS) { - if (MDOC_BODY != n->type) + if (MDOC_BODY != n->type && MDOC_ELEM != n->type) return(1); switch (n->tok) { @@ -1866,6 +1868,8 @@ termp_quote_pre(DECL_ARGS) case (MDOC_Pq): term_word(p, "("); break; + case (MDOC__T): + /* FALLTHROUGH */ case (MDOC_Qo): /* FALLTHROUGH */ case (MDOC_Qq): @@ -1893,7 +1897,7 @@ static void termp_quote_post(DECL_ARGS) { - if (MDOC_BODY != n->type) + if (MDOC_BODY != n->type && MDOC_ELEM != n->type) return; p->flags |= TERMP_NOSPACE; @@ -1928,6 +1932,8 @@ termp_quote_post(DECL_ARGS) case (MDOC_Pq): term_word(p, ")"); break; + case (MDOC__T): + /* FALLTHROUGH */ case (MDOC_Qo): /* FALLTHROUGH */ case (MDOC_Qq): @@ -2154,6 +2160,41 @@ termp_bk_post(DECL_ARGS) } /* ARGSUSED */ +static void +termp__t_post(DECL_ARGS) +{ + struct mdoc_node *nn; + + /* + * If we're in an `Rs' and there's a journal present, then quote + * us instead of underlining us (for disambiguation). + */ + nn = n->parent->parent; + if (nn && MDOC_Rs == nn->tok && nn->data.Rs->child_J) + termp_quote_post(p, pair, m, n); + + termp____post(p, pair, m, n); +} + +/* ARGSUSED */ +static int +termp__t_pre(DECL_ARGS) +{ + struct mdoc_node *nn; + + /* + * If we're in an `Rs' and there's a journal present, then quote + * us instead of underlining us (for disambiguation). + */ + nn = n->parent->parent; + if (nn && MDOC_Rs == nn->tok && nn->data.Rs->child_J) + return(termp_quote_pre(p, pair, m, n)); + + term_fontpush(p, TERMFONT_UNDER); + return(1); + } + +/* ARGSUSED */ static int termp_under_pre(DECL_ARGS) { diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index ca03cf6166a..fb579543fe6 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.80 2010/12/21 23:57:31 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.81 2010/12/26 21:04:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -127,6 +127,7 @@ static int pre_it(PRE_ARGS); static int pre_literal(PRE_ARGS); static int pre_os(PRE_ARGS); static int pre_par(PRE_ARGS); +static int pre_rs(PRE_ARGS); static int pre_sh(PRE_ARGS); static int pre_ss(PRE_ARGS); static int pre_std(PRE_ARGS); @@ -174,6 +175,7 @@ static v_pre pres_fd[] = { NULL, NULL }; static v_pre pres_it[] = { pre_it, pre_par, NULL }; static v_pre pres_os[] = { pre_os, NULL }; static v_pre pres_pp[] = { pre_par, NULL }; +static v_pre pres_rs[] = { pre_rs, NULL }; static v_pre pres_sh[] = { pre_sh, NULL }; static v_pre pres_ss[] = { pre_ss, NULL }; static v_pre pres_std[] = { pre_std, NULL }; @@ -265,7 +267,7 @@ const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Qo */ { NULL, NULL }, /* Qq */ { NULL, NULL }, /* Re */ - { NULL, posts_rs }, /* Rs */ + { pres_rs, posts_rs }, /* Rs */ { NULL, NULL }, /* Sc */ { NULL, NULL }, /* So */ { NULL, NULL }, /* Sq */ @@ -979,6 +981,16 @@ pre_dd(PRE_ARGS) return(1); } +static int +pre_rs(PRE_ARGS) +{ + + assert(NULL == n->data.Rs); + n->data.Rs = mandoc_calloc(1, sizeof(struct mdoc_rs)); + + return(1); +} + static int post_bf(POST_ARGS) @@ -1687,6 +1699,8 @@ post_rs(POST_ARGS) break; if (i < RSORD_MAX) { + if (MDOC__J == rsord[i]) + mdoc->last->parent->data.Rs->child_J = nn; next = nn->next; continue; } @@ -1704,6 +1718,7 @@ post_rs(POST_ARGS) next = NULL; for (nn = mdoc->last->child->next; nn; nn = next) { + /* Determine order of `nn'. */ for (i = 0; i < RSORD_MAX; i++) if (rsord[i] == nn->tok) |