=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.70 retrieving revision 1.74 diff -u -p -r1.70 -r1.74 --- mandoc/mdoc_man.c 2014/08/21 12:57:17 1.70 +++ mandoc/mdoc_man.c 2014/11/19 22:00:37 1.74 @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.70 2014/08/21 12:57:17 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.74 2014/11/19 22:00:37 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze * @@ -46,6 +46,7 @@ static void font_push(char); static void font_pop(void); static void mid_it(void); static void post__t(DECL_ARGS); +static void post_aq(DECL_ARGS); static void post_bd(DECL_ARGS); static void post_bf(DECL_ARGS); static void post_bk(DECL_ARGS); @@ -72,6 +73,7 @@ static void post_vt(DECL_ARGS); static int pre__t(DECL_ARGS); static int pre_an(DECL_ARGS); static int pre_ap(DECL_ARGS); +static int pre_aq(DECL_ARGS); static int pre_bd(DECL_ARGS); static int pre_bf(DECL_ARGS); static int pre_bk(DECL_ARGS); @@ -112,7 +114,7 @@ static int pre_xr(DECL_ARGS); static void print_word(const char *); static void print_line(const char *, int); static void print_block(const char *, int); -static void print_offs(const char *); +static void print_offs(const char *, int); static void print_width(const char *, const struct mdoc_node *, size_t); static void print_count(int *); @@ -172,8 +174,8 @@ static const struct manact manacts[MDOC_MAX + 1] = { { NULL, pre__t, post__t, NULL, NULL }, /* %T */ { NULL, NULL, post_percent, NULL, NULL }, /* %V */ { NULL, NULL, NULL, NULL, NULL }, /* Ac */ - { cond_body, pre_enc, post_enc, "<", ">" }, /* Ao */ - { cond_body, pre_enc, post_enc, "<", ">" }, /* Aq */ + { cond_body, pre_aq, post_aq, NULL, NULL }, /* Ao */ + { cond_body, pre_aq, post_aq, NULL, NULL }, /* Aq */ { NULL, NULL, NULL, NULL, NULL }, /* At */ { NULL, NULL, NULL, NULL, NULL }, /* Bc */ { NULL, pre_bf, post_bf, NULL, NULL }, /* Bf */ @@ -416,7 +418,7 @@ print_block(const char *s, int newflags) } static void -print_offs(const char *v) +print_offs(const char *v, int keywords) { char buf[24]; struct roffsu su; @@ -425,11 +427,11 @@ print_offs(const char *v) print_line(".RS", MMAN_Bk_susp); /* Convert v into a number (of characters). */ - if (NULL == v || '\0' == *v || 0 == strcmp(v, "left")) + if (NULL == v || '\0' == *v || (keywords && !strcmp(v, "left"))) sz = 0; - else if (0 == strcmp(v, "indent")) + else if (keywords && !strcmp(v, "indent")) sz = 6; - else if (0 == strcmp(v, "indent-two")) + else if (keywords && !strcmp(v, "indent-two")) sz = 12; else if (a2roffsu(v, &su, SCALE_MAX)) { if (SCALE_EN == su.unit) @@ -594,7 +596,11 @@ print_node(DECL_ARGS) printf("\\&"); outflags &= ~MMAN_spc; } + if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMC)) + outflags |= MMAN_spc_force; print_word(n->string); + if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMO)) + outflags |= MMAN_spc; } else { /* * Conditionally run the pre-node action handler for a @@ -866,6 +872,25 @@ pre_ap(DECL_ARGS) } static int +pre_aq(DECL_ARGS) +{ + + print_word(n->parent->prev != NULL && + n->parent->prev->tok == MDOC_An ? "<" : "\\(la"); + outflags &= ~MMAN_spc; + return(1); +} + +static void +post_aq(DECL_ARGS) +{ + + outflags &= ~(MMAN_spc | MMAN_nl); + print_word(n->parent->prev != NULL && + n->parent->prev->tok == MDOC_An ? ">" : "\\(ra"); +} + +static int pre_bd(DECL_ARGS) { @@ -876,7 +901,7 @@ pre_bd(DECL_ARGS) print_line(".nf", 0); if (0 == n->norm->Bd.comp && NULL != n->parent->prev) outflags |= MMAN_sp; - print_offs(n->norm->Bd.offs); + print_offs(n->norm->Bd.offs, 1); return(1); } @@ -963,7 +988,7 @@ pre_bl(DECL_ARGS) * just nest and do not add up their indentation. */ if (n->norm->Bl.offs) { - print_offs(n->norm->Bl.offs); + print_offs(n->norm->Bl.offs, 0); Bl_stack[Bl_stack_len++] = 0; } @@ -1048,7 +1073,7 @@ static int pre_dl(DECL_ARGS) { - print_offs("6n"); + print_offs("6n", 0); return(1); } @@ -1340,7 +1365,7 @@ pre_it(DECL_ARGS) outflags |= MMAN_nl; font_push('B'); if (LIST_bullet == bln->norm->Bl.type) - print_word("o"); + print_word("\\(bu"); else print_word("-"); font_pop();