version 1.55, 2013/12/24 22:08:50 |
version 1.61, 2014/03/30 23:34:32 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include <string.h> |
#include <string.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "out.h" |
#include "out.h" |
#include "man.h" |
#include "man.h" |
#include "mdoc.h" |
#include "mdoc.h" |
Line 89 static int pre_in(DECL_ARGS); |
|
Line 90 static int pre_in(DECL_ARGS); |
|
static int pre_it(DECL_ARGS); |
static int pre_it(DECL_ARGS); |
static int pre_lk(DECL_ARGS); |
static int pre_lk(DECL_ARGS); |
static int pre_li(DECL_ARGS); |
static int pre_li(DECL_ARGS); |
|
static int pre_ll(DECL_ARGS); |
static int pre_nm(DECL_ARGS); |
static int pre_nm(DECL_ARGS); |
static int pre_no(DECL_ARGS); |
static int pre_no(DECL_ARGS); |
static int pre_ns(DECL_ARGS); |
static int pre_ns(DECL_ARGS); |
Line 240 static const struct manact manacts[MDOC_MAX + 1] = { |
|
Line 242 static const struct manact manacts[MDOC_MAX + 1] = { |
|
{ NULL, pre_sp, post_sp, NULL, NULL }, /* sp */ |
{ NULL, pre_sp, post_sp, NULL, NULL }, /* sp */ |
{ NULL, NULL, post_percent, NULL, NULL }, /* %U */ |
{ NULL, NULL, post_percent, NULL, NULL }, /* %U */ |
{ NULL, NULL, NULL, NULL, NULL }, /* Ta */ |
{ NULL, NULL, NULL, NULL, NULL }, /* Ta */ |
|
{ NULL, pre_ll, post_sp, NULL, NULL }, /* ll */ |
{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */ |
{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */ |
}; |
}; |
|
|
Line 256 static int outflags; |
|
Line 259 static int outflags; |
|
#define MMAN_An_split (1 << 9) /* author mode is "split" */ |
#define MMAN_An_split (1 << 9) /* author mode is "split" */ |
#define MMAN_An_nosplit (1 << 10) /* author mode is "nosplit" */ |
#define MMAN_An_nosplit (1 << 10) /* author mode is "nosplit" */ |
#define MMAN_PD (1 << 11) /* inter-paragraph spacing disabled */ |
#define MMAN_PD (1 << 11) /* inter-paragraph spacing disabled */ |
|
#define MMAN_nbrword (1 << 12) /* do not break the next word */ |
|
|
#define BL_STACK_MAX 32 |
#define BL_STACK_MAX 32 |
|
|
Line 364 print_word(const char *s) |
|
Line 368 print_word(const char *s) |
|
case (ASCII_HYPH): |
case (ASCII_HYPH): |
putchar('-'); |
putchar('-'); |
break; |
break; |
|
case (ASCII_BREAK): |
|
printf("\\:"); |
|
break; |
|
case (' '): |
|
if (MMAN_nbrword & outflags) { |
|
printf("\\ "); |
|
break; |
|
} |
|
/* FALLTHROUGH */ |
default: |
default: |
putchar((unsigned char)*s); |
putchar((unsigned char)*s); |
break; |
break; |
Line 371 print_word(const char *s) |
|
Line 384 print_word(const char *s) |
|
if (TPremain) |
if (TPremain) |
TPremain--; |
TPremain--; |
} |
} |
|
outflags &= ~MMAN_nbrword; |
} |
} |
|
|
static void |
static void |
Line 450 print_offs(const char *v) |
|
Line 464 print_offs(const char *v) |
|
/* |
/* |
* Set up the indentation for a list item; used from pre_it(). |
* Set up the indentation for a list item; used from pre_it(). |
*/ |
*/ |
void |
static void |
print_width(const char *v, const struct mdoc_node *child, size_t defsz) |
print_width(const char *v, const struct mdoc_node *child, size_t defsz) |
{ |
{ |
char buf[24]; |
char buf[24]; |
Line 502 print_width(const char *v, const struct mdoc_node *chi |
|
Line 516 print_width(const char *v, const struct mdoc_node *chi |
|
TPremain = remain; |
TPremain = remain; |
} |
} |
|
|
void |
static void |
print_count(int *count) |
print_count(int *count) |
{ |
{ |
char buf[12]; |
char buf[12]; |
Line 587 print_node(DECL_ARGS) |
|
Line 601 print_node(DECL_ARGS) |
|
*/ |
*/ |
act = manacts + n->tok; |
act = manacts + n->tok; |
cond = NULL == act->cond || (*act->cond)(meta, n); |
cond = NULL == act->cond || (*act->cond)(meta, n); |
if (cond && act->pre) |
if (cond && act->pre && ENDBODY_NOT == n->end) |
do_sub = (*act->pre)(meta, n); |
do_sub = (*act->pre)(meta, n); |
} |
} |
|
|
Line 603 print_node(DECL_ARGS) |
|
Line 617 print_node(DECL_ARGS) |
|
/* |
/* |
* Lastly, conditionally run the post-node handler. |
* Lastly, conditionally run the post-node handler. |
*/ |
*/ |
|
if (MDOC_ENDED & n->flags) |
|
return; |
|
|
if (cond && act->post) |
if (cond && act->post) |
(*act->post)(meta, n); |
(*act->post)(meta, n); |
|
|
|
if (ENDBODY_NOT != n->end) |
|
n->pending->flags |= MDOC_ENDED; |
|
|
|
if (ENDBODY_NOSPACE == n->end) |
|
outflags &= ~(MMAN_spc | MMAN_nl); |
} |
} |
|
|
static int |
static int |
Line 642 post_enc(DECL_ARGS) |
|
Line 665 post_enc(DECL_ARGS) |
|
suffix = manacts[n->tok].suffix; |
suffix = manacts[n->tok].suffix; |
if (NULL == suffix) |
if (NULL == suffix) |
return; |
return; |
outflags &= ~MMAN_spc; |
outflags &= ~(MMAN_spc | MMAN_nl); |
print_word(suffix); |
print_word(suffix); |
} |
} |
|
|
Line 1022 post_eo(DECL_ARGS) |
|
Line 1045 post_eo(DECL_ARGS) |
|
static int |
static int |
pre_fa(DECL_ARGS) |
pre_fa(DECL_ARGS) |
{ |
{ |
|
int am_Fa; |
|
|
if (MDOC_Fa == n->tok) |
am_Fa = MDOC_Fa == n->tok; |
|
|
|
if (am_Fa) |
n = n->child; |
n = n->child; |
|
|
while (NULL != n) { |
while (NULL != n) { |
font_push('I'); |
font_push('I'); |
|
if (am_Fa || MDOC_SYNPRETTY & n->flags) |
|
outflags |= MMAN_nbrword; |
print_node(meta, n); |
print_node(meta, n); |
font_pop(); |
font_pop(); |
if (NULL != (n = n->next)) |
if (NULL != (n = n->next)) |
Line 1127 pre_fo(DECL_ARGS) |
|
Line 1155 pre_fo(DECL_ARGS) |
|
pre_syn(n); |
pre_syn(n); |
break; |
break; |
case (MDOC_HEAD): |
case (MDOC_HEAD): |
|
if (MDOC_SYNPRETTY & n->flags) |
|
print_block(".HP 4n", MMAN_nl); |
font_push('B'); |
font_push('B'); |
break; |
break; |
case (MDOC_BODY): |
case (MDOC_BODY): |
Line 1139 pre_fo(DECL_ARGS) |
|
Line 1169 pre_fo(DECL_ARGS) |
|
} |
} |
return(1); |
return(1); |
} |
} |
|
|
static void |
static void |
post_fo(DECL_ARGS) |
post_fo(DECL_ARGS) |
{ |
{ |
Line 1384 pre_lk(DECL_ARGS) |
|
Line 1414 pre_lk(DECL_ARGS) |
|
print_word(link->string); |
print_word(link->string); |
font_pop(); |
font_pop(); |
return(0); |
return(0); |
|
} |
|
|
|
static int |
|
pre_ll(DECL_ARGS) |
|
{ |
|
|
|
print_line(".ll", 0); |
|
return(1); |
} |
} |
|
|
static int |
static int |