diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-07-18 19:44:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-07-18 19:44:39 +0000 |
commit | 74f1eb0e192f60b865fa0a1e03580e66b3f35a3f (patch) | |
tree | db8d536a5325710fd050307019bb02122d51833b /usr.bin/mandoc | |
parent | 02cdff506154f56833ff6416f88443960b22cb83 (diff) |
sync to 1.8.0: move mdoc_a2att, mdoc_a2st, and mdoc_a2lib to libmdoc
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/libmdoc.h | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.h | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_action.c | 106 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 59 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 12 |
6 files changed, 114 insertions, 78 deletions
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h index f81c2aa9aa0..caee3b97f25 100644 --- a/usr.bin/mandoc/libmdoc.h +++ b/usr.bin/mandoc/libmdoc.h @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.14 2009/07/13 00:33:40 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.15 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -97,6 +97,7 @@ enum merr { EQUOTPHR, ENOCTX, ESPACE, + ELIB, MERRMAX }; @@ -153,6 +154,9 @@ enum mdoc_sec mdoc_atosec(const char *); time_t mdoc_atotime(const char *); size_t mdoc_macro2len(int); +const char *mdoc_a2att(const char *); +const char *mdoc_a2lib(const char *); +const char *mdoc_a2st(const char *); const char *mdoc_a2arch(const char *); const char *mdoc_a2vol(const char *); const char *mdoc_a2msec(const char *); diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 478f08c4e19..618ec809979 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.17 2009/07/12 22:35:08 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.18 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -79,6 +79,7 @@ const char *const __mdoc_merrnames[MERRMAX] = { "unterminated quoted phrase", /* EQUOTPHR */ "closure macro without prior context", /* ENOCTX */ "invalid whitespace after control character", /* ESPACE */ + "no description found for library" /* ELIB */ }; const char *const __mdoc_macronames[MDOC_MAX] = { diff --git a/usr.bin/mandoc/mdoc.h b/usr.bin/mandoc/mdoc.h index 89f1925db54..65287ac056c 100644 --- a/usr.bin/mandoc/mdoc.h +++ b/usr.bin/mandoc/mdoc.h @@ -1,4 +1,4 @@ -/* $Id: mdoc.h,v 1.9 2009/07/12 22:35:08 schwarze Exp $ */ +/* $Id: mdoc.h,v 1.10 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -295,10 +295,6 @@ const struct mdoc_node *mdoc_node(const struct mdoc *); const struct mdoc_meta *mdoc_meta(const struct mdoc *); int mdoc_endparse(struct mdoc *); -const char *mdoc_a2att(const char *); -const char *mdoc_a2lib(const char *); -const char *mdoc_a2st(const char *); - __END_DECLS #endif /*!MDOC_H*/ diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c index 95ee2b88db7..08c392e69fc 100644 --- a/usr.bin/mandoc/mdoc_action.c +++ b/usr.bin/mandoc/mdoc_action.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.14 2009/07/12 22:35:08 schwarze Exp $ */ +/* $Id: mdoc_action.c,v 1.15 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -32,22 +32,22 @@ struct actions { int (*post)(POST_ARGS); }; -static int concat(struct mdoc *, const struct mdoc_node *, - char *, size_t); - static int post_ar(POST_ARGS); +static int post_at(POST_ARGS); static int post_bl(POST_ARGS); static int post_bl_head(POST_ARGS); -static int post_bl_width(POST_ARGS); static int post_bl_tagwidth(POST_ARGS); +static int post_bl_width(POST_ARGS); static int post_dd(POST_ARGS); static int post_display(POST_ARGS); static int post_dt(POST_ARGS); +static int post_lb(POST_ARGS); static int post_lk(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_prol(POST_ARGS); static int post_sh(POST_ARGS); +static int post_st(POST_ARGS); static int post_std(POST_ARGS); static int pre_bd(PRE_ARGS); @@ -91,7 +91,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ot */ { NULL, NULL }, /* Pa */ { NULL, post_std }, /* Rv */ - { NULL, NULL }, /* St */ + { NULL, post_st }, /* St */ { NULL, NULL }, /* Va */ { NULL, NULL }, /* Vt */ { NULL, NULL }, /* Xr */ @@ -109,7 +109,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ac */ { NULL, NULL }, /* Ao */ { NULL, NULL }, /* Aq */ - { NULL, NULL }, /* At */ + { NULL, post_at }, /* At */ { NULL, NULL }, /* Bc */ { NULL, NULL }, /* Bf */ { NULL, NULL }, /* Bo */ @@ -160,7 +160,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Hf */ { NULL, NULL }, /* Fr */ { NULL, NULL }, /* Ud */ - { NULL, NULL }, /* Lb */ + { NULL, post_lb }, /* Lb */ { NULL, NULL }, /* Lp */ { NULL, post_lk }, /* Lk */ { NULL, NULL }, /* Mt */ @@ -174,6 +174,9 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* %Q */ }; +static int concat(struct mdoc *, const struct mdoc_node *, + char *, size_t); + int mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n) @@ -285,6 +288,81 @@ post_nm(POST_ARGS) static int +post_lb(POST_ARGS) +{ + const char *p; + char *buf; + size_t sz; + + assert(MDOC_TEXT == m->last->child->type); + p = mdoc_a2lib(m->last->child->string); + if (NULL == p) { + sz = strlen(m->last->child->string) + + 2 + strlen("\\(lqlibrary\\(rq"); + buf = malloc(sz); + if (NULL == buf) + return(mdoc_nerr(m, m->last, EMALLOC)); + (void)snprintf(buf, sz, "library \\(lq%s\\(rq", + m->last->child->string); + free(m->last->child->string); + m->last->child->string = buf; + return(1); + } + + free(m->last->child->string); + m->last->child->string = strdup(p); + if (NULL == m->last->child->string) + return(mdoc_nerr(m, m->last, EMALLOC)); + return(1); +} + + +static int +post_st(POST_ARGS) +{ + const char *p; + + assert(MDOC_TEXT == m->last->child->type); + p = mdoc_a2st(m->last->child->string); + assert(p); + free(m->last->child->string); + m->last->child->string = strdup(p); + if (NULL == m->last->child->string) + return(mdoc_nerr(m, m->last, EMALLOC)); + return(1); +} + + +static int +post_at(POST_ARGS) +{ + struct mdoc_node *n; + const char *p; + + if (m->last->child) { + assert(MDOC_TEXT == m->last->child->type); + p = mdoc_a2att(m->last->child->string); + assert(p); + free(m->last->child->string); + m->last->child->string = strdup(p); + if (NULL == m->last->child->string) + return(mdoc_nerr(m, m->last, EMALLOC)); + return(1); + } + + n = m->last; + m->next = MDOC_NEXT_CHILD; + + if ( ! mdoc_word_alloc(m, n->line, n->pos, "AT&T UNIX")) + return(0); + + m->last = n; + m->next = MDOC_NEXT_SIBLING; + return(1); +} + + +static int post_sh(POST_ARGS) { enum mdoc_sec sec; @@ -660,9 +738,9 @@ post_lk(POST_ARGS) n = m->last; m->next = MDOC_NEXT_CHILD; - /* FIXME: this isn't documented anywhere! */ - if ( ! mdoc_word_alloc(m, m->last->line, - m->last->pos, "~")) + + /* XXX: this isn't documented anywhere! */ + if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "~")) return(0); m->last = n; @@ -681,12 +759,10 @@ post_ar(POST_ARGS) n = m->last; m->next = MDOC_NEXT_CHILD; - if ( ! mdoc_word_alloc(m, m->last->line, - m->last->pos, "file")) + if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "file")) return(0); m->next = MDOC_NEXT_SIBLING; - if ( ! mdoc_word_alloc(m, m->last->line, - m->last->pos, "...")) + if ( ! mdoc_word_alloc(m, m->last->line, m->last->pos, "...")) return(0); m->last = n; diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 19cfc5c50c3..5a9a1470417 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.31 2009/07/18 19:13:44 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.32 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -127,7 +127,6 @@ static int termp__t_pre(DECL_ARGS); static int termp_ap_pre(DECL_ARGS); static int termp_aq_pre(DECL_ARGS); static int termp_ar_pre(DECL_ARGS); -static int termp_at_pre(DECL_ARGS); static int termp_bd_pre(DECL_ARGS); static int termp_bf_pre(DECL_ARGS); static int termp_bq_pre(DECL_ARGS); @@ -148,7 +147,6 @@ static int termp_ft_pre(DECL_ARGS); static int termp_ic_pre(DECL_ARGS); static int termp_in_pre(DECL_ARGS); static int termp_it_pre(DECL_ARGS); -static int termp_lb_pre(DECL_ARGS); static int termp_lk_pre(DECL_ARGS); static int termp_ms_pre(DECL_ARGS); static int termp_mt_pre(DECL_ARGS); @@ -167,7 +165,6 @@ static int termp_sh_pre(DECL_ARGS); static int termp_sm_pre(DECL_ARGS); static int termp_sq_pre(DECL_ARGS); static int termp_ss_pre(DECL_ARGS); -static int termp_st_pre(DECL_ARGS); static int termp_sx_pre(DECL_ARGS); static int termp_sy_pre(DECL_ARGS); static int termp_ud_pre(DECL_ARGS); @@ -214,7 +211,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Ot */ { termp_pa_pre, NULL }, /* Pa */ { termp_rv_pre, NULL }, /* Rv */ - { termp_st_pre, NULL }, /* St */ + { NULL, NULL }, /* St */ { termp_va_pre, NULL }, /* Va */ { termp_vt_pre, termp_vt_post }, /* Vt */ { termp_xr_pre, NULL }, /* Xr */ @@ -232,7 +229,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Ac */ { termp_aq_pre, termp_aq_post }, /* Ao */ { termp_aq_pre, termp_aq_post }, /* Aq */ - { termp_at_pre, NULL }, /* At */ + { NULL, NULL }, /* At */ { NULL, NULL }, /* Bc */ { termp_bf_pre, NULL }, /* Bf */ { termp_bq_pre, termp_bq_post }, /* Bo */ @@ -283,7 +280,7 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Hf */ { NULL, NULL }, /* Fr */ { termp_ud_pre, NULL }, /* Ud */ - { termp_lb_pre, termp_lb_post }, /* Lb */ + { NULL, termp_lb_post }, /* Lb */ { termp_pp_pre, NULL }, /* Lp */ { termp_lk_pre, NULL }, /* Lk */ { termp_mt_pre, NULL }, /* Mt */ @@ -322,7 +319,6 @@ mdoc_run(struct termp *p, const struct mdoc *m) * Main output function. When this is called, assume that the * tree is properly formed. */ - print_head(p, mdoc_meta(m)); assert(mdoc_node(m)); assert(MDOC_ROOT == mdoc_node(m)->type); @@ -1037,18 +1033,6 @@ termp_pp_pre(DECL_ARGS) /* ARGSUSED */ static int -termp_st_pre(DECL_ARGS) -{ - const char *cp; - - if (node->child && (cp = mdoc_a2st(node->child->string))) - term_word(p, cp); - return(0); -} - - -/* ARGSUSED */ -static int termp_rs_pre(DECL_ARGS) { @@ -1293,23 +1277,6 @@ termp_bt_pre(DECL_ARGS) /* ARGSUSED */ -static int -termp_lb_pre(DECL_ARGS) -{ - const char *lb; - - assert(node->child && MDOC_TEXT == node->child->type); - lb = mdoc_a2lib(node->child->string); - if (lb) { - term_word(p, lb); - return(0); - } - term_word(p, "library"); - return(1); -} - - -/* ARGSUSED */ static void termp_lb_post(DECL_ARGS) { @@ -1839,24 +1806,6 @@ termp_in_post(DECL_ARGS) /* ARGSUSED */ static int -termp_at_pre(DECL_ARGS) -{ - const char *att; - - att = NULL; - - if (node->child) - att = mdoc_a2att(node->child->string); - if (NULL == att) - att = "AT&T UNIX"; - - term_word(p, att); - return(0); -} - - -/* ARGSUSED */ -static int termp_brq_pre(DECL_ARGS) { diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 16d3c35412b..ee50bbeca52 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.26 2009/07/18 16:21:52 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.27 2009/07/18 19:44:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -870,6 +870,16 @@ post_bf(POST_ARGS) static int +post_lb(POST_ARGS) +{ + + if (mdoc_a2lib(mdoc->last->child->string)) + return(1); + return(mdoc_nwarn(mdoc, mdoc->last, ELIB)); +} + + +static int post_nm(POST_ARGS) { |