=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_term.c,v retrieving revision 1.61 retrieving revision 1.62 diff -c -r1.61 -r1.62 *** src/usr.bin/mandoc/mdoc_term.c 2009/10/21 19:13:50 1.61 --- src/usr.bin/mandoc/mdoc_term.c 2009/10/27 21:40:07 1.62 *************** *** 1,4 **** ! /* $Id: mdoc_term.c,v 1.61 2009/10/21 19:13:50 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_term.c,v 1.62 2009/10/27 21:40:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * *************** *** 48,53 **** --- 48,70 ---- void (*post)(DECL_ARGS); }; + static size_t a2width(const struct mdoc_argv *, int); + static size_t a2height(const struct mdoc_node *); + static size_t a2offs(const struct mdoc_argv *); + + static int arg_hasattr(int, const struct mdoc_node *); + static int arg_getattrs(const int *, int *, size_t, + const struct mdoc_node *); + static int arg_getattr(int, const struct mdoc_node *); + static int arg_listtype(const struct mdoc_node *); + static void print_bvspace(struct termp *, + const struct mdoc_node *, + const struct mdoc_node *); + static void print_node(DECL_ARGS); + static void print_head(DECL_ARGS); + static void print_body(DECL_ARGS); + static void print_foot(DECL_ARGS); + static void termp____post(DECL_ARGS); static void termp_an_post(DECL_ARGS); static void termp_aq_post(DECL_ARGS); *************** *** 236,261 **** { NULL, termp____post }, /* %Q */ { termp_sp_pre, NULL }, /* br */ { termp_sp_pre, NULL }, /* sp */ }; - static size_t arg2width(const struct mdoc_argv *, int); - static size_t arg2height(const struct mdoc_node *); - static size_t arg2offs(const struct mdoc_argv *); - static int arg_hasattr(int, const struct mdoc_node *); - static int arg_getattrs(const int *, int *, size_t, - const struct mdoc_node *); - static int arg_getattr(int, const struct mdoc_node *); - static int arg_listtype(const struct mdoc_node *); - static void print_bvspace(struct termp *, - const struct mdoc_node *, - const struct mdoc_node *); - static void print_node(DECL_ARGS); - static void print_head(DECL_ARGS); - static void print_body(DECL_ARGS); - static void print_foot(DECL_ARGS); - - void terminal_mdoc(void *arg, const struct mdoc *mdoc) { --- 253,262 ---- { NULL, termp____post }, /* %Q */ { termp_sp_pre, NULL }, /* br */ { termp_sp_pre, NULL }, /* sp */ + { termp_under_pre, termp____post }, /* %U */ }; void terminal_mdoc(void *arg, const struct mdoc *mdoc) { *************** *** 342,349 **** static void print_foot(DECL_ARGS) { ! struct tm *tm; ! char *buf, *os; /* * Output the footer in new-groff style, that is, three columns --- 343,350 ---- static void print_foot(DECL_ARGS) { ! char buf[DATESIZ]; ! char *os; /* * Output the footer in new-groff style, that is, three columns *************** *** 353,368 **** * SYSTEM DATE SYSTEM */ - if (NULL == (buf = malloc(p->rmargin))) - err(EXIT_FAILURE, "malloc"); if (NULL == (os = malloc(p->rmargin))) err(EXIT_FAILURE, "malloc"); ! tm = localtime(&m->date); - if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm)) - err(EXIT_FAILURE, "strftime"); - (void)strlcpy(os, m->os, p->rmargin); term_vspace(p); --- 354,364 ---- * SYSTEM DATE SYSTEM */ if (NULL == (os = malloc(p->rmargin))) err(EXIT_FAILURE, "malloc"); ! time2a(m->date, buf, DATESIZ); (void)strlcpy(os, m->os, p->rmargin); term_vspace(p); *************** *** 393,399 **** p->rmargin = p->maxrmargin; p->flags = 0; - free(buf); free(os); } --- 389,394 ---- *************** *** 469,475 **** static size_t ! arg2height(const struct mdoc_node *n) { struct roffsu su; --- 464,470 ---- static size_t ! a2height(const struct mdoc_node *n) { struct roffsu su; *************** *** 483,489 **** static size_t ! arg2width(const struct mdoc_argv *arg, int pos) { struct roffsu su; --- 478,484 ---- static size_t ! a2width(const struct mdoc_argv *arg, int pos) { struct roffsu su; *************** *** 538,544 **** static size_t ! arg2offs(const struct mdoc_argv *arg) { struct roffsu su; --- 533,539 ---- static size_t ! a2offs(const struct mdoc_argv *arg) { struct roffsu su; *************** *** 717,739 **** for (i = 0, nn = n->prev; nn && i < (int)bl->args->argv[vals[2]].sz; nn = nn->prev, i++) ! offset += arg2width (&bl->args->argv[vals[2]], i); /* Whether exceeds maximum column. */ if (i < (int)bl->args->argv[vals[2]].sz) ! width = arg2width(&bl->args->argv[vals[2]], i); else width = 0; if (vals[1] >= 0) ! offset += arg2offs(&bl->args->argv[vals[1]]); break; default: if (vals[0] >= 0) ! width = arg2width(&bl->args->argv[vals[0]], 0); if (vals[1] >= 0) ! offset += arg2offs(&bl->args->argv[vals[1]]); break; } --- 712,734 ---- for (i = 0, nn = n->prev; nn && i < (int)bl->args->argv[vals[2]].sz; nn = nn->prev, i++) ! offset += a2width (&bl->args->argv[vals[2]], i); /* Whether exceeds maximum column. */ if (i < (int)bl->args->argv[vals[2]].sz) ! width = a2width(&bl->args->argv[vals[2]], i); else width = 0; if (vals[1] >= 0) ! offset += a2offs(&bl->args->argv[vals[1]]); break; default: if (vals[0] >= 0) ! width = a2width(&bl->args->argv[vals[0]], 0); if (vals[1] >= 0) ! offset += a2offs(&bl->args->argv[vals[1]]); break; } *************** *** 1556,1562 **** type = nn->args->argv[i].arg; break; case (MDOC_Offset): ! p->offset += arg2offs(&nn->args->argv[i]); break; default: break; --- 1551,1557 ---- type = nn->args->argv[i].arg; break; case (MDOC_Offset): ! p->offset += a2offs(&nn->args->argv[i]); break; default: break; *************** *** 1811,1817 **** switch (n->tok) { case (MDOC_sp): ! len = n->child ? arg2height(n->child) : 1; break; case (MDOC_br): len = 0; --- 1806,1812 ---- switch (n->tok) { case (MDOC_sp): ! len = n->child ? a2height(n->child) : 1; break; case (MDOC_br): len = 0; *************** *** 2007,2012 **** --- 2002,2009 ---- termp____post(DECL_ARGS) { + /* TODO: %U. */ + p->flags |= TERMP_NOSPACE; switch (n->tok) { case (MDOC__T): *************** *** 2026,2041 **** { const struct mdoc_node *nn; ! if (NULL == (nn = n->child->next)) { ! p->under++; return(1); - } - p->under++; term_word(p, nn->string); p->flags |= TERMP_NOSPACE; term_word(p, ":"); - p->under--; p->bold++; for (nn = nn->next; nn; nn = nn->next) --- 2023,2039 ---- { const struct mdoc_node *nn; ! p->under++; ! nn = n->child; ! ! if (NULL == nn->next) return(1); term_word(p, nn->string); + p->under--; + p->flags |= TERMP_NOSPACE; term_word(p, ":"); p->bold++; for (nn = nn->next; nn; nn = nn->next)