=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.84 retrieving revision 1.90 diff -u -p -r1.84 -r1.90 --- mandoc/main.c 2010/06/07 10:52:44 1.84 +++ mandoc/main.c 2010/06/26 15:22:19 1.90 @@ -1,6 +1,6 @@ -/* $Id: main.c,v 1.84 2010/06/07 10:52:44 kristaps Exp $ */ +/* $Id: main.c,v 1.90 2010/06/26 15:22:19 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -30,10 +30,11 @@ #include #include "mandoc.h" +#include "regs.h" +#include "main.h" #include "mdoc.h" #include "man.h" #include "roff.h" -#include "main.h" #define UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) @@ -65,7 +66,8 @@ enum outt { OUTT_TREE, OUTT_HTML, OUTT_XHTML, - OUTT_LINT + OUTT_LINT, + OUTT_PS }; struct curparse { @@ -108,6 +110,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "unterminated quoted string", "argument requires the width argument", "superfluous width argument", + "ignoring argument", "bad date argument", "bad width argument", "unknown manual section", @@ -142,12 +145,13 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "macro requires argument(s)", "no title in document", "missing list type", + "missing display type", "line argument(s) will be lost", "body argument(s) will be lost", "column syntax is inconsistent", "missing font type", - "missing display type", "displays may not be nested", + "unsupported display type", "no scope to rewind: syntax violated", "scope broken, syntax violated", "line scope broken, syntax violated", @@ -447,11 +451,13 @@ fdesc(struct curparse *curp) struct man *man; struct mdoc *mdoc; struct roff *roff; + struct regset regs; man = NULL; mdoc = NULL; roff = NULL; memset(&ln, 0, sizeof(struct buf)); + memset(®s, 0, sizeof(struct regset)); /* * Two buffers: ln and buf. buf is the input file and may be @@ -534,7 +540,7 @@ fdesc(struct curparse *curp) of = 0; do { - re = roff_parseln(roff, lnn_start, + re = roff_parseln(roff, ®s, lnn_start, &ln.buf, &ln.sz, of, &of); } while (ROFF_RERUN == re); @@ -584,12 +590,26 @@ fdesc(struct curparse *curp) switch (curp->outtype) { case (OUTT_XHTML): curp->outdata = xhtml_alloc(curp->outopts); - curp->outman = html_man; - curp->outmdoc = html_mdoc; - curp->outfree = html_free; break; case (OUTT_HTML): curp->outdata = html_alloc(curp->outopts); + break; + case (OUTT_ASCII): + curp->outdata = ascii_alloc(curp->outopts); + curp->outfree = ascii_free; + break; + case (OUTT_PS): + curp->outdata = ps_alloc(); + curp->outfree = ps_free; + break; + default: + break; + } + + switch (curp->outtype) { + case (OUTT_HTML): + /* FALLTHROUGH */ + case (OUTT_XHTML): curp->outman = html_man; curp->outmdoc = html_mdoc; curp->outfree = html_free; @@ -598,14 +618,14 @@ fdesc(struct curparse *curp) curp->outman = tree_man; curp->outmdoc = tree_mdoc; break; - case (OUTT_LINT): - break; - default: - curp->outdata = ascii_alloc(curp->outopts); + case (OUTT_ASCII): + /* FALLTHROUGH */ + case (OUTT_PS): curp->outman = terminal_man; curp->outmdoc = terminal_mdoc; - curp->outfree = terminal_free; break; + default: + break; } } @@ -729,6 +749,8 @@ toptions(struct curparse *curp, char *arg) curp->outtype = OUTT_HTML; else if (0 == strcmp(arg, "xhtml")) curp->outtype = OUTT_XHTML; + else if (0 == strcmp(arg, "ps")) + curp->outtype = OUTT_PS; else { fprintf(stderr, "%s: Bad argument\n", arg); return(0);