version 1.17, 2008/12/07 14:38:57 |
version 1.20, 2008/12/07 22:40:18 |
|
|
void *data; |
void *data; |
}; |
}; |
|
|
|
static void mlg_roffmsg(void *arg, |
static char *mlg_literal(int); |
enum roffmsg, const char *, |
static char *mlg_At_literal(const char *); |
const char *, const char *); |
static char *mlg_fmt(int); |
|
static char *mlg_St_literal(int); |
|
static void mlg_roffmsg(void *arg, enum roffmsg, |
|
const char *, const char *, char *); |
|
static int mlg_roffhead(void *, const struct tm *, |
static int mlg_roffhead(void *, const struct tm *, |
const char *, const char *, |
const char *, const char *, |
const char *, const char *); |
const char *, const char *); |
static int mlg_rofftail(void *); |
static int mlg_rofftail(void *); |
static int mlg_roffin(void *, int, int *, char **); |
static int mlg_roffin(void *, int, |
|
int *, const char **); |
static int mlg_roffdata(void *, int, |
static int mlg_roffdata(void *, int, |
const char *, char *); |
const char *, const char *); |
static int mlg_roffout(void *, int); |
static int mlg_roffout(void *, int); |
static int mlg_roffblkin(void *, int, int *, char **); |
static int mlg_roffblkin(void *, int, int *, |
|
const char **); |
static int mlg_roffblkout(void *, int); |
static int mlg_roffblkout(void *, int); |
static int mlg_roffspecial(void *, int, |
static int mlg_roffspecial(void *, int, |
const char *, const int *, |
const char *, const int *, |
const char **, char **); |
const char **, const char **); |
static int mlg_roffblkheadin(void *, int, |
static int mlg_roffblkheadin(void *, int, |
int *, char **); |
int *, const char **); |
static int mlg_roffblkheadout(void *, int); |
static int mlg_roffblkheadout(void *, int); |
static int mlg_roffblkbodyin(void *, int, |
static int mlg_roffblkbodyin(void *, int, |
int *, char **); |
int *, const char **); |
static int mlg_roffblkbodyout(void *, int); |
static int mlg_roffblkbodyout(void *, int); |
|
|
|
static int mlg_ref_special(struct md_mlg *, int, |
|
const char *, const char **); |
|
static int mlg_formatted_special(struct md_mlg *, |
|
int, const int *, |
|
const char **, const char **); |
|
static int mlg_literal_special(struct md_mlg *, |
|
int, const char *, const int *, |
|
const char **, const char **); |
|
static int mlg_function_special(struct md_mlg *, |
|
const char *, const char **); |
|
static int mlg_atom_special(struct md_mlg *, int, |
|
const char *, const char **); |
|
|
static int mlg_begintag(struct md_mlg *, enum md_ns, |
static int mlg_begintag(struct md_mlg *, enum md_ns, |
int, int *, char **); |
int, int *, const char **); |
static int mlg_endtag(struct md_mlg *, enum md_ns, int); |
static int mlg_endtag(struct md_mlg *, enum md_ns, int); |
static int mlg_indent(struct md_mlg *); |
static int mlg_indent(struct md_mlg *); |
static int mlg_newline(struct md_mlg *); |
static int mlg_newline(struct md_mlg *); |
static void mlg_mode(struct md_mlg *, enum md_tok); |
static void mlg_mode(struct md_mlg *, enum md_tok); |
|
static int mlg_nstring(struct md_mlg *, |
|
const char *, const char *, size_t); |
|
static int mlg_string(struct md_mlg *, |
|
const char *, const char *); |
static int mlg_data(struct md_mlg *, int, |
static int mlg_data(struct md_mlg *, int, |
const char *, char *); |
const char *, const char *); |
static void mlg_err(struct md_mlg *, const char *, |
static void mlg_err(struct md_mlg *, const char *, |
const char *, const char *, ...); |
const char *, const char *, ...); |
static void mlg_warn(struct md_mlg *, const char *, |
static void mlg_msg(struct md_mlg *, |
const char *, const char *, ...); |
enum roffmsg, const char *, |
static void mlg_msg(struct md_mlg *, enum roffmsg, |
const char *, const char *); |
const char *, const char *, char *); |
|
static void mlg_vmsg(struct md_mlg *, enum roffmsg, |
static void mlg_vmsg(struct md_mlg *, enum roffmsg, |
const char *, const char *, |
const char *, const char *, |
const char *, va_list); |
const char *, va_list); |
Line 110 extern size_t strlcpy(char *, const char *, size_t); |
|
Line 124 extern size_t strlcpy(char *, const char *, size_t); |
|
#endif |
#endif |
|
|
|
|
static char * |
|
mlg_St_literal(int argc) |
|
{ |
|
|
|
switch (argc) { |
|
case(ROFF_p1003_1_88): |
|
return("IEEE Std 1003.1-1988 (“POSIX”)"); |
|
case(ROFF_p1003_1_90): |
|
return("IEEE Std 1003.1-1990 (“POSIX”)"); |
|
case(ROFF_p1003_1_96): |
|
return("ISO/IEC 9945-1:1996 (“POSIX”)"); |
|
case(ROFF_p1003_1_2001): |
|
return("IEEE Std 1003.1-2001 (“POSIX”)"); |
|
case(ROFF_p1003_1_2004): |
|
return("IEEE Std 1003.1-2004 (“POSIX”)"); |
|
case(ROFF_p1003_1): |
|
return("IEEE Std 1003.1 (“POSIX”)"); |
|
case(ROFF_p1003_1b): |
|
return("IEEE Std 1003.1b (“POSIX”)"); |
|
case(ROFF_p1003_1b_93): |
|
return("IEEE Std 1003.1b-1993 (“POSIX”)"); |
|
case(ROFF_p1003_1c_95): |
|
return("IEEE Std 1003.1c-1995 (“POSIX”)"); |
|
case(ROFF_p1003_1g_2000): |
|
return("IEEE Std 1003.1g-2000 (“POSIX”)"); |
|
case(ROFF_p1003_2_92): |
|
return("IEEE Std 1003.2-1992 (“POSIX.2”)"); |
|
case(ROFF_p1387_2_95): |
|
return("IEEE Std 1387.2-1995 (“POSIX.7.2”)"); |
|
case(ROFF_p1003_2): |
|
return("IEEE Std 1003.2 (“POSIX.2”)"); |
|
case(ROFF_p1387_2): |
|
return("IEEE Std 1387.2 (“POSIX.7.2”)"); |
|
case(ROFF_isoC_90): |
|
return("ISO/IEC 9899:1990 (“ISO C90”)"); |
|
case(ROFF_isoC_amd1): |
|
return("ISO/IEC 9899/AMD1:1995 (“ISO C90”)"); |
|
case(ROFF_isoC_tcor1): |
|
return("ISO/IEC 9899/TCOR1:1994 (“ISO C90”)"); |
|
case(ROFF_isoC_tcor2): |
|
return("ISO/IEC 9899/TCOR2:1995 (“ISO C90”)"); |
|
case(ROFF_isoC_99): |
|
return("ISO/IEC 9899:1999 (“ISO C99”)"); |
|
case(ROFF_ansiC): |
|
return("ANSI X3.159-1989 (“ANSI C”)"); |
|
case(ROFF_ansiC_89): |
|
return("ANSI X3.159-1989 (“ANSI C”)"); |
|
case(ROFF_ansiC_99): |
|
return("ANSI/ISO/IEC 9899-1999 (“ANSI C99”)"); |
|
case(ROFF_ieee754): |
|
return("IEEE Std 754-1985"); |
|
case(ROFF_iso8802_3): |
|
return("ISO 8802-3: 1989"); |
|
case(ROFF_xpg3): |
|
return("X/Open Portability Guide Issue 3 (“XPG3”)"); |
|
case(ROFF_xpg4): |
|
return("X/Open Portability Guide Issue 4 (“XPG4”)"); |
|
case(ROFF_xpg4_2): |
|
return("X/Open Portability Guide Issue 4.2 (“XPG4.2”)"); |
|
case(ROFF_xpg4_3): |
|
return("X/Open Portability Guide Issue 4.3 (“XPG4.3”)"); |
|
case(ROFF_xbd5): |
|
return("X/Open System Interface Definitions Issue 5 (“XBD5”)"); |
|
case(ROFF_xcu5): |
|
return("X/Open Commands and Utilities Issue 5 (“XCU5”)"); |
|
case(ROFF_xsh5): |
|
return("X/Open System Interfaces and Headers Issue 5 (“XSH5”)"); |
|
case(ROFF_xns5): |
|
return("X/Open Networking Services Issue 5 (“XNS5”)"); |
|
case(ROFF_xns5_2d2_0): |
|
return("X/Open Networking Services Issue 5.2 Draft 2.0 (“XNS5.2D2.0”)"); |
|
case(ROFF_xcurses4_2): |
|
return("X/Open Curses Issue 4 Version 2 (“XCURSES4.2”)"); |
|
case(ROFF_susv2): |
|
return("Version 2 of the Single UNIX Specification"); |
|
case(ROFF_susv3): |
|
return("Version 3 of the Single UNIX Specification"); |
|
case(ROFF_svid4): |
|
return("System V Interface Definition, Fourth Edition (“SVID4”)"); |
|
default: |
|
break; |
|
} |
|
|
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
|
|
static char * |
|
mlg_At_literal(const char *p) |
|
{ |
|
|
|
if (NULL == p) |
|
return("AT&T UNIX"); |
|
if (0 == strcmp(p, "v6")) |
|
return("Version 6 AT&T UNIX"); |
|
else if (0 == strcmp(p, "v7")) |
|
return("Version 7 AT&T UNIX"); |
|
else if (0 == strcmp(p, "32v")) |
|
return("Version 32v AT&T UNIX"); |
|
else if (0 == strcmp(p, "V.1")) |
|
return("AT&T System V.1 UNIX"); |
|
else if (0 == strcmp(p, "V.4")) |
|
return("AT&T System V.4 UNIX"); |
|
|
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
|
|
static char * |
|
mlg_fmt(int tok) |
|
{ |
|
|
|
switch (tok) { |
|
case (ROFF_Ex): |
|
return ("The %s utility exits 0 on success, and " |
|
">0 if an error occurs."); |
|
case (ROFF_Rv): |
|
return ("The %s() function returns the value 0 if " |
|
"successful; otherwise the value -1 " |
|
"is returned and the global variable " |
|
"<span class=\"inline-Va\">errno</span> " |
|
"is set to indicate the error."); |
|
default: |
|
break; |
|
} |
|
|
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
|
|
static char * |
|
mlg_literal(int tok) |
|
{ |
|
|
|
switch (tok) { |
|
case (ROFF_Bt): |
|
return("is currently in beta test."); |
|
case (ROFF_Ud): |
|
return("currently under development."); |
|
case (ROFF_Fx): |
|
return("FreeBSD"); |
|
case (ROFF_Nx): |
|
return("NetBSD"); |
|
case (ROFF_Ox): |
|
return("OpenBSD"); |
|
case (ROFF_Ux): |
|
return("UNIX"); |
|
case (ROFF_Bx): |
|
return("BSD"); |
|
case (ROFF_Bsx): |
|
return("BSDI BSD/OS"); |
|
default: |
|
break; |
|
} |
|
abort(); |
|
/* NOTREACHED */ |
|
} |
|
|
|
|
|
static int |
static int |
mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok, |
mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok, |
int *argc, char **argv) |
int *argc, const char **argv) |
{ |
{ |
ssize_t res; |
ssize_t res; |
|
|
Line 313 mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok, |
|
Line 165 mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok, |
|
if ( ! ml_nputs(p->mbuf, "<", 1, &p->pos)) |
if ( ! ml_nputs(p->mbuf, "<", 1, &p->pos)) |
return(0); |
return(0); |
|
|
res = (*p->cbs.ml_begintag)(p->mbuf, p->data, p->args, ns, tok, |
res = (*p->cbs.ml_begintag)(p->mbuf, p->data, |
argc, (const char **)argv); |
p->args, ns, tok, argc, argv); |
if (-1 == res) |
if (-1 == res) |
return(0); |
return(0); |
|
|
Line 418 mlg_mode(struct md_mlg *p, enum md_tok ns) |
|
Line 270 mlg_mode(struct md_mlg *p, enum md_tok ns) |
|
|
|
|
|
static int |
static int |
mlg_data(struct md_mlg *p, int space, const char *start, char *buf) |
mlg_string(struct md_mlg *p, const char *start, const char *buf) |
{ |
{ |
size_t sz; |
|
|
return(mlg_nstring(p, start, buf, strlen(buf))); |
|
} |
|
|
|
|
|
static int |
|
mlg_nstring(struct md_mlg *p, const char *start, |
|
const char *buf, size_t sz) |
|
{ |
int c; |
int c; |
|
ssize_t res; |
|
|
assert(p->mbuf); |
assert(p->mbuf); |
assert(0 != p->indent); |
assert(0 != p->indent); |
|
|
|
res = (*p->cbs.ml_beginstring)(p->mbuf, p->args, buf, sz); |
|
if (-1 == res) |
|
return(0); |
|
|
|
if (0 == (c = ml_nputstring(p->mbuf, buf, sz, &p->pos))) { |
|
mlg_err(p, start, buf, "bad string " |
|
"encoding: `%s'", buf); |
|
return(0); |
|
} else if (-1 == c) |
|
return(0); |
|
|
|
res = (*p->cbs.ml_endstring)(p->mbuf, p->args, buf, sz); |
|
if (-1 == res) |
|
return(0); |
|
|
|
return(1); |
|
} |
|
|
|
|
|
static int |
|
mlg_data(struct md_mlg *p, int space, |
|
const char *start, const char *buf) |
|
{ |
|
size_t sz; |
|
|
|
assert(p->mbuf); |
|
assert(0 != p->indent); |
|
|
if (ML_OVERRIDE_ONE & p->flags || |
if (ML_OVERRIDE_ONE & p->flags || |
ML_OVERRIDE_ALL & p->flags) |
ML_OVERRIDE_ALL & p->flags) |
space = 0; |
space = 0; |
Line 435 mlg_data(struct md_mlg *p, int space, const char *star |
|
Line 324 mlg_data(struct md_mlg *p, int space, const char *star |
|
if (0 == p->pos) { |
if (0 == p->pos) { |
if ( ! mlg_indent(p)) |
if ( ! mlg_indent(p)) |
return(0); |
return(0); |
|
if ( ! mlg_nstring(p, start, buf, sz)) |
c = ml_nputstring(p->mbuf, buf, sz, &p->pos); |
|
|
|
if (0 == c) { |
|
mlg_err(p, start, buf, "bad char sequence"); |
|
return(0); |
return(0); |
} else if (c > 1) { |
|
mlg_warn(p, start, buf, "bogus char sequence"); |
|
return(0); |
|
} else if (-1 == c) |
|
return(0); |
|
|
|
if (p->indent * INDENT + sz >= COLUMNS) |
if (p->indent * INDENT + sz >= COLUMNS) |
if ( ! mlg_newline(p)) |
if ( ! mlg_newline(p)) |
Line 464 mlg_data(struct md_mlg *p, int space, const char *star |
|
Line 344 mlg_data(struct md_mlg *p, int space, const char *star |
|
return(0); |
return(0); |
} |
} |
|
|
c = ml_nputstring(p->mbuf, buf, sz, &p->pos); |
return(mlg_nstring(p, start, buf, sz)); |
|
|
if (0 == c) { |
|
mlg_err(p, start, buf, "bad char sequence"); |
|
return(0); |
|
} else if (c > 1) { |
|
mlg_warn(p, start, buf, "bogus char sequence"); |
|
return(0); |
|
} else if (-1 == c) |
|
return(0); |
|
|
|
return(1); |
|
} |
} |
|
|
|
|
Line 584 mlg_rofftail(void *arg) |
|
Line 453 mlg_rofftail(void *arg) |
|
} |
} |
|
|
|
|
|
static int |
|
mlg_literal_special(struct md_mlg *p, int tok, const char *start, |
|
const int *argc, const char **argv, const char **more) |
|
{ |
|
char *lit; |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more)) |
|
return(0); |
|
|
|
lit = ml_literal(tok, argc, argv, more); |
|
assert(lit); |
|
|
|
if ( ! ml_puts(p->mbuf, lit, &p->pos)) |
|
return(0); |
|
while (*more) { |
|
if ( ! ml_nputs(p->mbuf, " ", 1, &p->pos)) |
|
return(0); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
} |
|
|
|
return(mlg_endtag(p, MD_NS_INLINE, tok)); |
|
} |
|
|
|
|
|
static int |
|
mlg_ref_special(struct md_mlg *p, int tok, |
|
const char *start, const char **more) |
|
{ |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more)) |
|
return(0); |
|
|
|
assert(*more); |
|
if ( ! ml_puts(p->mbuf, *more++, &p->pos)) |
|
return(0); |
|
|
|
if (*more) { |
|
if ( ! ml_nputs(p->mbuf, "(", 1, &p->pos)) |
|
return(0); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
if ( ! ml_nputs(p->mbuf, ")", 1, &p->pos)) |
|
return(0); |
|
} |
|
|
|
assert(NULL == *more); |
|
return(mlg_endtag(p, MD_NS_INLINE, tok)); |
|
} |
|
|
|
|
|
static int |
|
mlg_formatted_special(struct md_mlg *p, int tok, |
|
const int *argc, const char **argv, const char **more) |
|
{ |
|
char buf[256], *lit; |
|
|
|
/* FIXME: *more must be ml-filtered. */ |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more)) |
|
return(0); |
|
|
|
lit = ml_literal(tok, argc, argv, more); |
|
assert(lit); |
|
assert(*more); |
|
(void)snprintf(buf, sizeof(buf), lit, *more++); |
|
assert(NULL == *more); |
|
|
|
if ( ! ml_puts(p->mbuf, buf, &p->pos)) |
|
return(0); |
|
|
|
return(mlg_endtag(p, MD_NS_INLINE, tok)); |
|
} |
|
|
|
|
|
static int |
|
mlg_atom_special(struct md_mlg *p, int tok, |
|
const char *start, const char **more) |
|
{ |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more)) |
|
return(0); |
|
|
|
assert(*more); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
|
|
assert(NULL == *more); |
|
return(mlg_endtag(p, MD_NS_INLINE, tok)); |
|
} |
|
|
|
|
|
static int |
|
mlg_function_special(struct md_mlg *p, |
|
const char *start, const char **more) |
|
{ |
|
|
|
assert(*more); |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, ROFF_Fn, NULL, more)) |
|
return(0); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Fn)) |
|
return(0); |
|
|
|
if (NULL == *more) |
|
return(1); |
|
|
|
if ( ! ml_nputs(p->mbuf, "(", 1, &p->pos)) |
|
return(0); |
|
|
|
p->flags |= ML_OVERRIDE_ONE; |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, ROFF_Fa, NULL, more)) |
|
return(0); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Fa)) |
|
return(0); |
|
|
|
while (*more) { |
|
if ( ! ml_nputs(p->mbuf, ", ", 2, &p->pos)) |
|
return(0); |
|
if ( ! mlg_begintag(p, MD_NS_INLINE, ROFF_Fa, NULL, more)) |
|
return(0); |
|
if ( ! mlg_string(p, start, *more++)) |
|
return(0); |
|
if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Fa)) |
|
return(0); |
|
} |
|
|
|
return(ml_nputs(p->mbuf, ")", 1, &p->pos)); |
|
} |
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
mlg_roffspecial(void *arg, int tok, const char *start, |
mlg_roffspecial(void *arg, int tok, const char *start, |
const int *argc, const char **argv, char **more) |
const int *argc, const char **argv, const char **more) |
{ |
{ |
struct md_mlg *p; |
struct md_mlg *p; |
char buf[256]; |
|
|
|
assert(arg); |
assert(arg); |
p = (struct md_mlg *)arg; |
p = (struct md_mlg *)arg; |
|
|
/* |
|
* First handle macros without content. |
|
*/ |
|
|
|
switch (tok) { |
switch (tok) { |
case (ROFF_Ns): |
case (ROFF_Ns): |
p->flags |= ML_OVERRIDE_ONE; |
p->flags |= ML_OVERRIDE_ONE; |
return(1); |
return(1); |
|
|
case (ROFF_Sm): |
case (ROFF_Sm): |
assert(*more); |
assert(*more); |
if (0 == strcmp(*more, "on")) |
if (0 == strcmp(*more, "on")) |
Line 610 mlg_roffspecial(void *arg, int tok, const char *start, |
|
Line 611 mlg_roffspecial(void *arg, int tok, const char *start, |
|
else |
else |
p->flags &= ~ML_OVERRIDE_ALL; |
p->flags &= ~ML_OVERRIDE_ALL; |
return(1); |
return(1); |
default: |
|
break; |
|
} |
|
|
|
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more)) |
case (ROFF_Fn): |
return(0); |
return(mlg_function_special(p, start, more)); |
|
|
switch (tok) { |
|
case (ROFF_St): |
|
assert(NULL == *argv); |
|
assert(ROFF_ARGMAX != *argc); |
|
if ( ! ml_puts(p->mbuf, mlg_St_literal(*argc), |
|
&p->pos)) |
|
return(0); |
|
while (*more) { |
|
if ( ! ml_nputs(p->mbuf, " ", 1, &p->pos)) |
|
return(0); |
|
if ( ! ml_putstring(p->mbuf, *more++, &p->pos)) |
|
return(0); |
|
} |
|
break; |
|
|
|
case (ROFF_Xr): |
case (ROFF_Xr): |
if ( ! *more) { |
return(mlg_ref_special(p, tok, start, more)); |
mlg_err(p, start, start, "missing argument"); |
|
return(0); |
case (ROFF_Sx): /* FIXME */ |
} |
|
if ( ! ml_puts(p->mbuf, *more++, &p->pos)) |
|
return(0); |
|
if (*more) { |
|
if ( ! ml_nputs(p->mbuf, "(", 1, &p->pos)) |
|
return(0); |
|
if ( ! ml_puts(p->mbuf, *more++, &p->pos)) |
|
return(0); |
|
if ( ! ml_nputs(p->mbuf, ")", 1, &p->pos)) |
|
return(0); |
|
} |
|
if (*more) { |
|
mlg_err(p, start, start, "too many arguments"); |
|
return(0); |
|
} |
|
break; |
|
case (ROFF_Sx): |
|
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (ROFF_Nm): |
case (ROFF_Nm): |
assert(*more); |
return(mlg_atom_special(p, tok, start, more)); |
if ( ! ml_puts(p->mbuf, *more++, &p->pos)) |
|
return(0); |
case (ROFF_In): |
assert(NULL == *more); |
/* NOTREACHED */ |
break; |
|
|
|
case (ROFF_Ex): |
case (ROFF_Ex): |
/* NOTREACHED */ |
/* NOTREACHED */ |
case (ROFF_Rv): |
case (ROFF_Rv): |
assert(*more); |
return(mlg_formatted_special(p, tok, |
(void)snprintf(buf, sizeof(buf), |
argc, argv, more)); |
mlg_fmt(tok), *more++); |
|
if ( ! ml_puts(p->mbuf, buf, &p->pos)) |
|
return(0); |
|
assert(NULL == *more); |
|
break; |
|
case (ROFF_At): |
case (ROFF_At): |
if ( ! ml_puts(p->mbuf, mlg_At_literal(*more), &p->pos)) |
/* FALLTHROUGH */ |
return(0); |
case (ROFF_Bt): |
break; |
/* FALLTHROUGH */ |
|
case (ROFF_Ud): |
|
/* FALLTHROUGH */ |
|
case (ROFF_Ux): |
|
/* FALLTHROUGH */ |
case (ROFF_Bx): |
case (ROFF_Bx): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (ROFF_Bsx): |
case (ROFF_Bsx): |
Line 683 mlg_roffspecial(void *arg, int tok, const char *start, |
|
Line 647 mlg_roffspecial(void *arg, int tok, const char *start, |
|
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (ROFF_Nx): |
case (ROFF_Nx): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (ROFF_Ox): |
case (ROFF_St): |
if ( ! ml_puts(p->mbuf, mlg_literal(tok), &p->pos)) |
|
return(0); |
|
while (*more) { |
|
if ( ! ml_nputs(p->mbuf, " ", 1, &p->pos)) |
|
return(0); |
|
if ( ! ml_putstring(p->mbuf, *more++, &p->pos)) |
|
return(0); |
|
} |
|
break; |
|
case (ROFF_Bt): |
|
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (ROFF_Ud): |
case (ROFF_Ox): |
/* FALLTHROUGH */ |
return(mlg_literal_special(p, tok, start, |
case (ROFF_Ux): |
argc, argv, more)); |
assert(NULL == *more); |
|
if ( ! ml_puts(p->mbuf, mlg_literal(tok), &p->pos)) |
|
return(0); |
|
break; |
|
default: |
default: |
mlg_err(p, start, start, "`%s' not yet supported", |
break; |
toknames[tok]); |
|
return(0); |
|
} |
} |
|
|
return(mlg_endtag(p, MD_NS_INLINE, tok)); |
mlg_err(p, start, start, "`%s' not yet supported", |
|
toknames[tok]); |
|
return(0); |
} |
} |
|
|
|
|
static int |
static int |
mlg_roffblkin(void *arg, int tok, int *argc, char **argv) |
mlg_roffblkin(void *arg, int tok, |
|
int *argc, const char **argv) |
{ |
{ |
|
|
return(mlg_begintag((struct md_mlg *)arg, |
return(mlg_begintag((struct md_mlg *)arg, |
Line 730 mlg_roffblkout(void *arg, int tok) |
|
Line 681 mlg_roffblkout(void *arg, int tok) |
|
|
|
|
|
static int |
static int |
mlg_roffblkbodyin(void *arg, int tok, int *argc, char **argv) |
mlg_roffblkbodyin(void *arg, int tok, |
|
int *argc, const char **argv) |
{ |
{ |
|
|
return(mlg_begintag((struct md_mlg *)arg, |
return(mlg_begintag((struct md_mlg *)arg, |
Line 747 mlg_roffblkbodyout(void *arg, int tok) |
|
Line 699 mlg_roffblkbodyout(void *arg, int tok) |
|
|
|
|
|
static int |
static int |
mlg_roffblkheadin(void *arg, int tok, int *argc, char **argv) |
mlg_roffblkheadin(void *arg, int tok, |
|
int *argc, const char **argv) |
{ |
{ |
|
|
return(mlg_begintag((struct md_mlg *)arg, |
return(mlg_begintag((struct md_mlg *)arg, |
Line 764 mlg_roffblkheadout(void *arg, int tok) |
|
Line 717 mlg_roffblkheadout(void *arg, int tok) |
|
|
|
|
|
static int |
static int |
mlg_roffin(void *arg, int tok, int *argc, char **argv) |
mlg_roffin(void *arg, int tok, int *argc, const char **argv) |
{ |
{ |
|
|
return(mlg_begintag((struct md_mlg *)arg, |
return(mlg_begintag((struct md_mlg *)arg, |
Line 781 mlg_roffout(void *arg, int tok) |
|
Line 734 mlg_roffout(void *arg, int tok) |
|
|
|
|
|
static void |
static void |
mlg_roffmsg(void *arg, enum roffmsg lvl, |
mlg_roffmsg(void *arg, enum roffmsg lvl, const char *buf, |
const char *buf, const char *pos, char *msg) |
const char *pos, const char *msg) |
{ |
{ |
|
|
mlg_msg((struct md_mlg *)arg, lvl, buf, pos, msg); |
mlg_msg((struct md_mlg *)arg, lvl, buf, pos, msg); |
Line 790 mlg_roffmsg(void *arg, enum roffmsg lvl, |
|
Line 743 mlg_roffmsg(void *arg, enum roffmsg lvl, |
|
|
|
|
|
static int |
static int |
mlg_roffdata(void *arg, int space, const char *start, char *buf) |
mlg_roffdata(void *arg, int space, |
|
const char *start, const char *buf) |
{ |
{ |
struct md_mlg *p; |
struct md_mlg *p; |
|
|
Line 801 mlg_roffdata(void *arg, int space, const char *start, |
|
Line 755 mlg_roffdata(void *arg, int space, const char *start, |
|
return(0); |
return(0); |
|
|
mlg_mode(p, MD_TEXT); |
mlg_mode(p, MD_TEXT); |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 818 mlg_vmsg(struct md_mlg *p, enum roffmsg lvl, const cha |
|
Line 771 mlg_vmsg(struct md_mlg *p, enum roffmsg lvl, const cha |
|
|
|
|
|
static void |
static void |
mlg_warn(struct md_mlg *p, const char *start, |
|
const char *pos, const char *fmt, ...) |
|
{ |
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
mlg_vmsg(p, ROFF_WARN, start, pos, fmt, ap); |
|
va_end(ap); |
|
} |
|
|
|
|
|
static void |
|
mlg_err(struct md_mlg *p, const char *start, |
mlg_err(struct md_mlg *p, const char *start, |
const char *pos, const char *fmt, ...) |
const char *pos, const char *fmt, ...) |
{ |
{ |
Line 843 mlg_err(struct md_mlg *p, const char *start, |
|
Line 784 mlg_err(struct md_mlg *p, const char *start, |
|
|
|
static void |
static void |
mlg_msg(struct md_mlg *p, enum roffmsg lvl, |
mlg_msg(struct md_mlg *p, enum roffmsg lvl, |
const char *buf, const char *pos, char *msg) |
const char *buf, const char *pos, const char *msg) |
{ |
{ |
char *level; |
char *level; |
|
|