version 1.91, 2009/10/18 13:34:17 |
version 1.94, 2009/10/22 18:55:32 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
|
#include "out.h" |
#include "term.h" |
#include "term.h" |
#include "mdoc.h" |
#include "mdoc.h" |
#include "chars.h" |
#include "chars.h" |
Line 346 print_node(DECL_ARGS) |
|
Line 347 print_node(DECL_ARGS) |
|
static void |
static void |
print_foot(DECL_ARGS) |
print_foot(DECL_ARGS) |
{ |
{ |
struct tm *tm; |
char buf[DATESIZ]; |
char *buf, *os; |
char *os; |
|
|
/* |
/* |
* Output the footer in new-groff style, that is, three columns |
* Output the footer in new-groff style, that is, three columns |
Line 357 print_foot(DECL_ARGS) |
|
Line 358 print_foot(DECL_ARGS) |
|
* SYSTEM DATE SYSTEM |
* SYSTEM DATE SYSTEM |
*/ |
*/ |
|
|
if (NULL == (buf = malloc(p->rmargin))) |
|
err(EXIT_FAILURE, "malloc"); |
|
if (NULL == (os = malloc(p->rmargin))) |
if (NULL == (os = malloc(p->rmargin))) |
err(EXIT_FAILURE, "malloc"); |
err(EXIT_FAILURE, "malloc"); |
|
|
tm = localtime(&m->date); |
time2a(m->date, buf, DATESIZ); |
|
|
if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm)) |
|
err(EXIT_FAILURE, "strftime"); |
|
|
|
(void)strlcpy(os, m->os, p->rmargin); |
(void)strlcpy(os, m->os, p->rmargin); |
|
|
term_vspace(p); |
term_vspace(p); |
Line 397 print_foot(DECL_ARGS) |
|
Line 393 print_foot(DECL_ARGS) |
|
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
p->flags = 0; |
p->flags = 0; |
|
|
free(buf); |
|
free(os); |
free(os); |
} |
} |
|
|
Line 475 print_head(DECL_ARGS) |
|
Line 470 print_head(DECL_ARGS) |
|
static size_t |
static size_t |
arg2height(const struct mdoc_node *n) |
arg2height(const struct mdoc_node *n) |
{ |
{ |
int r; |
struct roffsu su; |
|
|
assert(MDOC_TEXT == n->type); |
assert(MDOC_TEXT == n->type); |
assert(n->string); |
assert(n->string); |
|
if ( ! a2roffsu(n->string, &su, SCALE_VS)) |
|
SCALE_VS_INIT(&su, strlen(n->string)); |
|
|
if ((r = a2height(n->string)) < 0) |
return(term_vspan(&su)); |
return(1); |
|
|
|
return((size_t)r); |
|
} |
} |
|
|
|
|
static size_t |
static size_t |
arg2width(const struct mdoc_argv *arg, int pos) |
arg2width(const struct mdoc_argv *arg, int pos) |
{ |
{ |
int r; |
struct roffsu su; |
|
|
assert(arg->value[pos]); |
assert(arg->value[pos]); |
if ('\0' == arg->value[pos][0]) |
if ( ! a2roffsu(arg->value[pos], &su, SCALE_MAX)) |
return(2); |
SCALE_HS_INIT(&su, strlen(arg->value[pos])); |
|
|
if ((r = a2width(arg->value[pos])) >= 0) |
/* XXX: pachemu? */ |
return((size_t)r); |
return(term_hspan(&su) + 2); |
|
|
return(strlen(arg->value[pos]) + 2); |
|
} |
} |
|
|
|
|
/* FIXME: put in utility file for front-ends. */ |
|
static int |
static int |
arg_listtype(const struct mdoc_node *n) |
arg_listtype(const struct mdoc_node *n) |
{ |
{ |
Line 548 arg_listtype(const struct mdoc_node *n) |
|
Line 539 arg_listtype(const struct mdoc_node *n) |
|
static size_t |
static size_t |
arg2offs(const struct mdoc_argv *arg) |
arg2offs(const struct mdoc_argv *arg) |
{ |
{ |
int r; |
struct roffsu su; |
|
|
if ('\0' == arg->value[0][0]) |
if ('\0' == arg->value[0][0]) |
return(0); |
return(0); |
Line 558 arg2offs(const struct mdoc_argv *arg) |
|
Line 549 arg2offs(const struct mdoc_argv *arg) |
|
return(INDENT + 1); |
return(INDENT + 1); |
else if (0 == strcmp(arg->value[0], "indent-two")) |
else if (0 == strcmp(arg->value[0], "indent-two")) |
return((INDENT + 1) * 2); |
return((INDENT + 1) * 2); |
else if ((r = a2width(arg->value[0])) >= 0) |
else if ( ! a2roffsu(arg->value[0], &su, SCALE_MAX)) |
return((size_t)r); |
SCALE_HS_INIT(&su, strlen(arg->value[0])); |
|
|
return(strlen(arg->value[0])); |
return(term_hspan(&su)); |
} |
} |
|
|
|
|