diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | html.c | 14 | ||||
-rw-r--r-- | literals.c | 108 | ||||
-rw-r--r-- | ml.h | 2 | ||||
-rw-r--r-- | mlg.c | 4 | ||||
-rw-r--r-- | private.h | 54 | ||||
-rw-r--r-- | roff.c | 44 | ||||
-rw-r--r-- | xml.c | 5 |
8 files changed, 209 insertions, 26 deletions
@@ -36,7 +36,7 @@ INSTALL = Makefile $(HEADS) $(SRCS) $(MANS) FAIL = test.0 test.1 test.2 test.3 test.4 test.5 test.6 \ test.15 test.20 test.22 test.24 test.26 test.27 test.30 \ test.36 test.37 test.40 test.50 test.61 test.64 test.65 \ - test.66 + test.66 test.69 test.70 SUCCEED = test.7 test.8 test.9 test.10 test.11 test.12 test.13 \ test.14 test.16 test.17 test.18 test.19 test.21 test.23 \ @@ -44,7 +44,7 @@ SUCCEED = test.7 test.8 test.9 test.10 test.11 test.12 test.13 \ test.35 test.38 test.39 test.41 test.42 test.43 test.44 \ test.45 test.46 test.47 test.48 test.49 test.51 test.52 \ test.54 test.55 test.56 test.57 test.58 test.59 test.60 \ - test.62 test.63 test.67 + test.62 test.63 test.67 test.68 test.71 all: mdocml @@ -72,7 +72,7 @@ static int html_begin(struct md_mbuf *, const struct md_args *, const struct tm *, const char *, const char *, - enum roffmsec, const char *); + enum roffmsec, enum roffvol); static int html_printargs(struct md_mbuf *, int, const char *, const int *, const char **, size_t *); @@ -382,15 +382,23 @@ html_aputln(struct md_mbuf *mbuf, enum ml_scope scope, int i, static int html_begin(struct md_mbuf *mbuf, const struct md_args *args, const struct tm *tm, const char *os, - const char *name, enum roffmsec msec, const char *vol) + const char *name, enum roffmsec msec, enum roffvol vol) { struct html_pair attr[4]; - char ts[32]; + char ts[32], title[64]; int i; (void)snprintf(ts, sizeof(ts), "%s(%s)", name, roff_msecname(msec)); + (void)snprintf(ts, sizeof(ts), "%s", + name, roff_volname(vol)); + + if (vol >= ROFF_ARCH_START) { + + } + + i = 0; if ( ! html_typeput(mbuf, HTML_TYPE_4_01_STRICT, NULL)) @@ -65,6 +65,40 @@ #define ROFF_MSECname_DRAFT "draft" #define ROFF_MSECname_PAPER "paper" +#define ROFF_VOLname_AMD "AMD" +#define ROFF_VOLname_IND "IND" +#define ROFF_VOLname_KM "KM" +#define ROFF_VOLname_LOCAL "LOCAL" +#define ROFF_VOLname_PRM "PRM" +#define ROFF_VOLname_PS1 "PS1" +#define ROFF_VOLname_SMM "SMM" +#define ROFF_VOLname_URM "URM" +#define ROFF_VOLname_USD "USD" +#define ROFF_ARCHname_ALPHA "alpha" +#define ROFF_ARCHname_AMD64 "amd64" +#define ROFF_ARCHname_AMIGA "amiga" +#define ROFF_ARCHname_ARC "arc" +#define ROFF_ARCHname_ARMISH "armish" +#define ROFF_ARCHname_AVIION "aviion" +#define ROFF_ARCHname_HP300 "hp300" +#define ROFF_ARCHname_HPPA "hppa" +#define ROFF_ARCHname_HPPA64 "hppa64" +#define ROFF_ARCHname_I386 "i386" +#define ROFF_ARCHname_LANDISK "landisk" +#define ROFF_ARCHname_LUNA88K "luna88k" +#define ROFF_ARCHname_MAC68K "mac68k" +#define ROFF_ARCHname_MACPPC "macppc" +#define ROFF_ARCHname_MVME68K "mvme68k" +#define ROFF_ARCHname_MVME88K "mvme88k" +#define ROFF_ARCHname_MVMEPPC "mvmeppc" +#define ROFF_ARCHname_PMAX "pmax" +#define ROFF_ARCHname_SGI "sgi" +#define ROFF_ARCHname_SPARC "sparc" +#define ROFF_ARCHname_SPARC64 "sparc64" +#define ROFF_ARCHname_SUN3 "sun3" +#define ROFF_ARCHname_VAX "vax" +#define ROFF_ARCHname_ZAURUS "zaurus" + int roff_sec(const char **p) { @@ -423,3 +457,77 @@ roff_att(const char *p) return(ROFF_ATT_MAX); } + +enum roffvol +roff_vol(const char *p) +{ + + if (0 == strcmp(p, ROFF_VOLname_AMD)) + return(ROFF_VOL_AMD); + else if (0 == strcmp(p, ROFF_VOLname_IND)) + return(ROFF_VOL_IND); + else if (0 == strcmp(p, ROFF_VOLname_KM)) + return(ROFF_VOL_KM); + else if (0 == strcmp(p, ROFF_VOLname_LOCAL)) + return(ROFF_VOL_LOCAL); + else if (0 == strcmp(p, ROFF_VOLname_PRM)) + return(ROFF_VOL_PRM); + else if (0 == strcmp(p, ROFF_VOLname_PS1)) + return(ROFF_VOL_PS1); + else if (0 == strcmp(p, ROFF_VOLname_SMM)) + return(ROFF_VOL_SMM); + else if (0 == strcmp(p, ROFF_VOLname_URM)) + return(ROFF_VOL_URM); + else if (0 == strcmp(p, ROFF_VOLname_USD)) + return(ROFF_VOL_USD); + else if (0 == strcmp(p, ROFF_ARCHname_ALPHA)) + return(ROFF_ARCH_ALPHA); + else if (0 == strcmp(p, ROFF_ARCHname_AMD64)) + return(ROFF_ARCH_AMD64); + else if (0 == strcmp(p, ROFF_ARCHname_AMIGA)) + return(ROFF_ARCH_AMIGA); + else if (0 == strcmp(p, ROFF_ARCHname_ARC)) + return(ROFF_ARCH_ARC); + else if (0 == strcmp(p, ROFF_ARCHname_ARMISH)) + return(ROFF_ARCH_ARMISH); + else if (0 == strcmp(p, ROFF_ARCHname_AVIION)) + return(ROFF_ARCH_AVIION); + else if (0 == strcmp(p, ROFF_ARCHname_HP300)) + return(ROFF_ARCH_HP300); + else if (0 == strcmp(p, ROFF_ARCHname_HPPA)) + return(ROFF_ARCH_HPPA); + else if (0 == strcmp(p, ROFF_ARCHname_HPPA64)) + return(ROFF_ARCH_HPPA64); + else if (0 == strcmp(p, ROFF_ARCHname_I386)) + return(ROFF_ARCH_I386); + else if (0 == strcmp(p, ROFF_ARCHname_LANDISK)) + return(ROFF_ARCH_LANDISK); + else if (0 == strcmp(p, ROFF_ARCHname_LUNA88K)) + return(ROFF_ARCH_LUNA88K); + else if (0 == strcmp(p, ROFF_ARCHname_MAC68K)) + return(ROFF_ARCH_MAC68K); + else if (0 == strcmp(p, ROFF_ARCHname_MACPPC)) + return(ROFF_ARCH_MACPPC); + else if (0 == strcmp(p, ROFF_ARCHname_MVME68K)) + return(ROFF_ARCH_MVME68K); + else if (0 == strcmp(p, ROFF_ARCHname_MVME88K)) + return(ROFF_ARCH_MVME88K); + else if (0 == strcmp(p, ROFF_ARCHname_MVMEPPC)) + return(ROFF_ARCH_MVMEPPC); + else if (0 == strcmp(p, ROFF_ARCHname_PMAX)) + return(ROFF_ARCH_PMAX); + else if (0 == strcmp(p, ROFF_ARCHname_SGI)) + return(ROFF_ARCH_SGI); + else if (0 == strcmp(p, ROFF_ARCHname_SPARC)) + return(ROFF_ARCH_SPARC); + else if (0 == strcmp(p, ROFF_ARCHname_SPARC64)) + return(ROFF_ARCH_SPARC64); + else if (0 == strcmp(p, ROFF_ARCHname_SUN3)) + return(ROFF_ARCH_SUN3); + else if (0 == strcmp(p, ROFF_ARCHname_VAX)) + return(ROFF_ARCH_VAX); + else if (0 == strcmp(p, ROFF_ARCHname_ZAURUS)) + return(ROFF_ARCH_ZAURUS); + + return(ROFF_VOL_MAX); +} @@ -46,7 +46,7 @@ struct ml_cbs { const struct md_args *, const struct tm *, const char *, const char *, - enum roffmsec, const char *); + enum roffmsec, enum roffvol); int (*ml_end)(struct md_mbuf *, const struct md_args *); ssize_t (*ml_beginstring)(struct md_mbuf *, @@ -58,7 +58,7 @@ static int mlg_roffmsg(void *arg, const char *, const char *); static int mlg_roffhead(void *, const struct tm *, const char *, const char *, - enum roffmsec, const char *); + enum roffmsec, enum roffvol); static int mlg_rofftail(void *); static int mlg_roffin(void *, int, int *, const char **); @@ -404,7 +404,7 @@ mlg_alloc(const struct md_args *args, static int mlg_roffhead(void *arg, const struct tm *tm, const char *os, - const char *title, enum roffmsec sec, const char *vol) + const char *title, enum roffmsec sec, enum roffvol vol) { struct md_mlg *p; @@ -251,7 +251,7 @@ extern const char *const *tokargnames; enum roffmsg { ROFF_WARN, - ROFF_ERROR + ROFF_ERROR, }; enum roffmsec { @@ -268,7 +268,7 @@ enum roffmsec { ROFF_MSEC_UNASS, ROFF_MSEC_DRAFT, ROFF_MSEC_PAPER, - ROFF_MSEC_MAX + ROFF_MSEC_MAX, }; enum roffatt { @@ -280,7 +280,46 @@ enum roffatt { ROFF_ATT_32V, ROFF_ATT_V_1, ROFF_ATT_V_4, - ROFF_ATT_MAX + ROFF_ATT_MAX, +}; + +enum roffvol { + ROFF_VOL_NONE, + ROFF_VOL_AMD, + ROFF_VOL_IND, + ROFF_VOL_KM, + ROFF_VOL_LOCAL, + ROFF_VOL_PRM, + ROFF_VOL_PS1, + ROFF_VOL_SMM, + ROFF_VOL_URM, + ROFF_VOL_USD, +#define ROFF_ARCH_START ROFF_ARCH_ALPHA + ROFF_ARCH_ALPHA, + ROFF_ARCH_AMD64, + ROFF_ARCH_AMIGA, + ROFF_ARCH_ARC, + ROFF_ARCH_ARMISH, + ROFF_ARCH_AVIION, + ROFF_ARCH_HP300, + ROFF_ARCH_HPPA, + ROFF_ARCH_HPPA64, + ROFF_ARCH_I386, + ROFF_ARCH_LANDISK, + ROFF_ARCH_LUNA88K, + ROFF_ARCH_MAC68K, + ROFF_ARCH_MACPPC, + ROFF_ARCH_MVME68K, + ROFF_ARCH_MVME88K, + ROFF_ARCH_MVMEPPC, + ROFF_ARCH_PMAX, + ROFF_ARCH_SGI, + ROFF_ARCH_SPARC, + ROFF_ARCH_SPARC64, + ROFF_ARCH_SUN3, + ROFF_ARCH_VAX, + ROFF_ARCH_ZAURUS, + ROFF_VOL_MAX, }; #define ROFFSec_NMASK (0x07) @@ -306,7 +345,7 @@ struct roffcb { int (*roffmsg)(void *, enum roffmsg, const char *, const char *, const char *); int (*roffhead)(void *, const struct tm *, const char *, - const char *, enum roffmsec, const char *); + const char *, enum roffmsec, enum roffvol); int (*rofftail)(void *); int (*roffdata)(void *, int, const char *, const char *); int (*roffin)(void *, int, int *, const char **); @@ -329,27 +368,21 @@ typedef void (*(*md_init)(const struct md_args *, struct md_mbuf *, const struct md_rbuf *)); typedef int (*md_line)(void *, char *); typedef int (*md_exit)(void *, int); - void *md_init_html(const struct md_args *, struct md_mbuf *, const struct md_rbuf *); int md_line_html(void *, char *); int md_exit_html(void *, int); - void *md_init_xml(const struct md_args *, struct md_mbuf *, const struct md_rbuf *); int md_line_xml(void *, char *); int md_exit_xml(void *, int); - int md_buf_puts(struct md_mbuf *, const char *, size_t); int md_buf_putchar(struct md_mbuf *, char); int md_buf_putstring(struct md_mbuf *, const char *); - struct rofftree *roff_alloc(const struct roffcb *, void *); int roff_engine(struct rofftree *, char *); int roff_free(struct rofftree *, int); - int rofftok_scan(const char *, int *); - char *roff_literal(int, const int *, const char **, const char **); char *roff_fmtstring(int); @@ -357,6 +390,7 @@ char *roff_msecname(enum roffmsec); enum roffmsec roff_msec(const char *); int roff_sec(const char **); enum roffatt roff_att(const char *); +enum roffvol roff_vol(const char *); __END_DECLS @@ -70,7 +70,7 @@ struct rofftree { char os[64]; /* `Os' results. */ char title[64]; /* `Dt' results. */ enum roffmsec section; - char volume[64]; /* `Dt' results. */ + enum roffvol volume; int state; #define ROFF_PRELUDE (1 << 1) /* In roff prelude. */ /* FIXME: put into asec. */ #define ROFF_PRELUDE_Os (1 << 2) /* `Os' is parsed. */ @@ -1022,12 +1022,46 @@ roff_Dt(ROFFCALL_ARGS) return(roff_errp(tree, *argv, tok, ERR_BADARG)); argv++; - sz = sizeof(tree->volume); if (NULL == *argv) { - tree->volume[0] = 0; - } else if (strlcpy(tree->volume, *argv, sz) >= sz) - return(roff_errp(tree, *argv, tok, ERR_ARGLEN)); + switch (tree->section) { + case(ROFF_MSEC_1): + /* FALLTHROUGH */ + case(ROFF_MSEC_6): + /* FALLTHROUGH */ + case(ROFF_MSEC_7): + tree->volume = ROFF_VOL_URM; + break; + case(ROFF_MSEC_2): + /* FALLTHROUGH */ + case(ROFF_MSEC_3): + /* FALLTHROUGH */ + case(ROFF_MSEC_3p): + /* FALLTHROUGH */ + case(ROFF_MSEC_4): + /* FALLTHROUGH */ + case(ROFF_MSEC_5): + tree->volume = ROFF_VOL_PRM; + break; + case(ROFF_MSEC_8): + tree->volume = ROFF_VOL_PRM; + break; + case(ROFF_MSEC_9): + tree->volume = ROFF_VOL_KM; + break; + case(ROFF_MSEC_UNASS): + /* FALLTHROUGH */ + case(ROFF_MSEC_DRAFT): + /* FALLTHROUGH */ + case(ROFF_MSEC_PAPER): + tree->volume = ROFF_VOL_NONE; + break; + default: + abort(); + /* NOTREACHED */ + } + } else if (ROFF_VOL_MAX == (tree->volume = roff_vol(*argv))) + return(roff_errp(tree, *argv, tok, ERR_BADARG)); assert(NULL == tree->last); tree->state |= ROFF_PRELUDE_Dt; @@ -43,7 +43,7 @@ static int xml_begin(struct md_mbuf *, const struct md_args *, const struct tm *, const char *, const char *, - enum roffmsec, const char *); + enum roffmsec, enum roffvol); static int xml_end(struct md_mbuf *, const struct md_args *); static ssize_t xml_printtagname(struct md_mbuf *, @@ -124,8 +124,7 @@ xml_printtagname(struct md_mbuf *mbuf, enum md_ns ns, int tok) static int xml_begin(struct md_mbuf *mbuf, const struct md_args *args, const struct tm *tm, const char *os, - const char *title, enum roffmsec section, - const char *vol) + const char *title, enum roffmsec sec, enum roffvol vol) { if ( ! ml_puts(mbuf, "<?xml version=\"1.0\" " |