version 1.140, 2011/05/17 10:48:06 |
version 1.141, 2011/05/17 11:19:45 |
Line 107 static const char *const roffscales[SCALE_MAX] = { |
|
Line 107 static const char *const roffscales[SCALE_MAX] = { |
|
"ex", /* SCALE_FS */ |
"ex", /* SCALE_FS */ |
}; |
}; |
|
|
static void print_num(struct html *, const char *, size_t); |
static void bufncat(struct html *, const char *, size_t); |
static void print_spec(struct html *, const char *, size_t); |
static void print_spec(struct html *, const char *, size_t); |
static void print_res(struct html *, const char *, size_t); |
static void print_res(struct html *, const char *, size_t); |
static void print_ctag(struct html *, enum htmltag); |
static void print_ctag(struct html *, enum htmltag); |
static void print_doctype(struct html *); |
static int print_encode(struct html *, const char *, int); |
static void print_xmltype(struct html *); |
static void print_metaf(struct html *, enum mandoc_esc); |
static int print_encode(struct html *, const char *, int); |
static void print_attr(struct html *, const char *, const char *); |
static void print_metaf(struct html *, enum mandoc_esc); |
static void *ml_alloc(char *, enum htmltype); |
static void print_attr(struct html *, |
|
const char *, const char *); |
|
static void *ml_alloc(char *, enum htmltype); |
|
|
|
|
|
static void * |
static void * |
ml_alloc(char *outopts, enum htmltype type) |
ml_alloc(char *outopts, enum htmltype type) |
{ |
{ |
Line 222 print_gen_head(struct html *h) |
|
Line 218 print_gen_head(struct html *h) |
|
} |
} |
} |
} |
|
|
/* ARGSUSED */ |
|
static void |
static void |
print_num(struct html *h, const char *p, size_t len) |
|
{ |
|
char c; |
|
|
|
if ('\0' != (c = mchars_num2char(p, len))) |
|
putchar((int)c); |
|
} |
|
|
|
static void |
|
print_spec(struct html *h, const char *p, size_t len) |
print_spec(struct html *h, const char *p, size_t len) |
{ |
{ |
int cp; |
int cp; |
|
|
print_encode(struct html *h, const char *p, int norecurse) |
print_encode(struct html *h, const char *p, int norecurse) |
{ |
{ |
size_t sz; |
size_t sz; |
int len, nospace; |
int c, len, nospace; |
const char *seq; |
const char *seq; |
enum mandoc_esc esc; |
enum mandoc_esc esc; |
static const char rejs[6] = { '\\', '<', '>', '&', ASCII_HYPH, '\0' }; |
static const char rejs[6] = { '\\', '<', '>', '&', ASCII_HYPH, '\0' }; |
Line 388 print_encode(struct html *h, const char *p, int norecu |
|
Line 374 print_encode(struct html *h, const char *p, int norecu |
|
|
|
switch (esc) { |
switch (esc) { |
case (ESCAPE_NUMBERED): |
case (ESCAPE_NUMBERED): |
print_num(h, seq, len); |
c = mchars_num2char(seq, len); |
|
if ('\0' != c) |
|
putchar(c); |
break; |
break; |
case (ESCAPE_PREDEF): |
case (ESCAPE_PREDEF): |
print_res(h, seq, len); |
print_res(h, seq, len); |
Line 509 print_ctag(struct html *h, enum htmltag tag) |
|
Line 497 print_ctag(struct html *h, enum htmltag tag) |
|
} |
} |
} |
} |
|
|
|
|
void |
void |
print_gen_decls(struct html *h) |
print_gen_decls(struct html *h) |
{ |
{ |
|
|
print_xmltype(h); |
|
print_doctype(h); |
|
} |
|
|
|
|
|
static void |
|
print_xmltype(struct html *h) |
|
{ |
|
|
|
if (HTML_XHTML_1_0_STRICT == h->type) |
|
puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
|
} |
|
|
|
|
|
static void |
|
print_doctype(struct html *h) |
|
{ |
|
const char *doctype; |
const char *doctype; |
const char *dtd; |
const char *dtd; |
const char *name; |
const char *name; |
Line 542 print_doctype(struct html *h) |
|
Line 511 print_doctype(struct html *h) |
|
dtd = "http://www.w3.org/TR/html4/strict.dtd"; |
dtd = "http://www.w3.org/TR/html4/strict.dtd"; |
break; |
break; |
default: |
default: |
|
puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
name = "html"; |
name = "html"; |
doctype = "-//W3C//DTD XHTML 1.0 Strict//EN"; |
doctype = "-//W3C//DTD XHTML 1.0 Strict//EN"; |
dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; |
dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; |
Line 631 print_stagq(struct html *h, const struct tag *suntil) |
|
Line 601 print_stagq(struct html *h, const struct tag *suntil) |
|
} |
} |
} |
} |
|
|
|
|
void |
void |
bufinit(struct html *h) |
bufinit(struct html *h) |
{ |
{ |
Line 640 bufinit(struct html *h) |
|
Line 609 bufinit(struct html *h) |
|
h->buflen = 0; |
h->buflen = 0; |
} |
} |
|
|
|
|
void |
void |
bufcat_style(struct html *h, const char *key, const char *val) |
bufcat_style(struct html *h, const char *key, const char *val) |
{ |
{ |
|
|
bufcat(h, key); |
bufcat(h, key); |
bufncat(h, ":", 1); |
bufcat(h, ":"); |
bufcat(h, val); |
bufcat(h, val); |
bufncat(h, ";", 1); |
bufcat(h, ";"); |
} |
} |
|
|
|
|
void |
void |
bufcat(struct html *h, const char *p) |
bufcat(struct html *h, const char *p) |
{ |
{ |
|
|
bufncat(h, p, strlen(p)); |
h->buflen = strlcat(h->buf, p, BUFSIZ); |
|
assert(h->buflen < BUFSIZ); |
|
h->buflen--; |
} |
} |
|
|
|
|
void |
void |
buffmt(struct html *h, const char *fmt, ...) |
bufcat_fmt(struct html *h, const char *fmt, ...) |
{ |
{ |
va_list ap; |
va_list ap; |
|
|
Line 672 buffmt(struct html *h, const char *fmt, ...) |
|
Line 640 buffmt(struct html *h, const char *fmt, ...) |
|
h->buflen = strlen(h->buf); |
h->buflen = strlen(h->buf); |
} |
} |
|
|
|
static void |
void |
|
bufncat(struct html *h, const char *p, size_t sz) |
bufncat(struct html *h, const char *p, size_t sz) |
{ |
{ |
|
|
if (h->buflen + sz > BUFSIZ - 1) |
assert(h->buflen + sz + 1 < BUFSIZ); |
sz = BUFSIZ - 1 - h->buflen; |
strncat(h->buf, p, sz); |
|
|
(void)strncat(h->buf, p, sz); |
|
h->buflen += sz; |
h->buflen += sz; |
} |
} |
|
|
|
|
void |
void |
buffmt_includes(struct html *h, const char *name) |
buffmt_includes(struct html *h, const char *name) |
{ |
{ |
Line 708 buffmt_includes(struct html *h, const char *name) |
|
Line 672 buffmt_includes(struct html *h, const char *name) |
|
bufcat(h, pp); |
bufcat(h, pp); |
} |
} |
|
|
|
|
void |
void |
buffmt_man(struct html *h, |
buffmt_man(struct html *h, |
const char *name, const char *sec) |
const char *name, const char *sec) |
Line 725 buffmt_man(struct html *h, |
|
Line 688 buffmt_man(struct html *h, |
|
bufcat(h, sec ? sec : "1"); |
bufcat(h, sec ? sec : "1"); |
break; |
break; |
case('N'): |
case('N'): |
buffmt(h, name); |
bufcat_fmt(h, name); |
break; |
break; |
default: |
default: |
bufncat(h, p, 2); |
bufncat(h, p, 2); |
Line 737 buffmt_man(struct html *h, |
|
Line 700 buffmt_man(struct html *h, |
|
bufcat(h, pp); |
bufcat(h, pp); |
} |
} |
|
|
|
|
void |
void |
bufcat_su(struct html *h, const char *p, const struct roffsu *su) |
bufcat_su(struct html *h, const char *p, const struct roffsu *su) |
{ |
{ |
Line 747 bufcat_su(struct html *h, const char *p, const struct |
|
Line 709 bufcat_su(struct html *h, const char *p, const struct |
|
if (SCALE_MM == su->unit && 0.0 == (v /= 100.0)) |
if (SCALE_MM == su->unit && 0.0 == (v /= 100.0)) |
v = 1.0; |
v = 1.0; |
|
|
buffmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]); |
bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]); |
} |
} |
|
|
|
|
void |
void |
html_idcat(char *dst, const char *src, int sz) |
html_idcat(char *dst, const char *src, int sz) |