=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.84 retrieving revision 1.93 diff -u -p -r1.84 -r1.93 --- mandoc/main.c 2010/06/07 10:52:44 1.84 +++ mandoc/main.c 2010/06/29 14:53:14 1.93 @@ -1,6 +1,6 @@ -/* $Id: main.c,v 1.84 2010/06/07 10:52:44 kristaps Exp $ */ +/* $Id: main.c,v 1.93 2010/06/29 14:53:14 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 { @@ -86,6 +88,7 @@ struct curparse { struct man *man; /* man parser */ struct mdoc *mdoc; /* mdoc parser */ struct roff *roff; /* roff parser (!NULL) */ + struct regset regs; /* roff registers */ enum outt outtype; /* which output to use */ out_mdoc outmdoc; /* mdoc output ptr */ out_man outman; /* man output ptr */ @@ -108,6 +111,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 +146,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", @@ -294,7 +299,7 @@ man_init(struct curparse *curp) if (curp->fflags & FL_NIGN_ESCAPE) pflags &= ~MAN_IGN_ESCAPE; - return(man_alloc(curp, pflags, mmsg)); + return(man_alloc(&curp->regs, curp, pflags, mmsg)); } @@ -302,7 +307,7 @@ static struct roff * roff_init(struct curparse *curp) { - return(roff_alloc(mmsg, curp)); + return(roff_alloc(&curp->regs, mmsg, curp)); } @@ -322,7 +327,7 @@ mdoc_init(struct curparse *curp) if (curp->fflags & FL_NIGN_MACRO) pflags &= ~MDOC_IGN_MACRO; - return(mdoc_alloc(curp, pflags, mmsg)); + return(mdoc_alloc(&curp->regs, curp, pflags, mmsg)); } @@ -451,6 +456,7 @@ fdesc(struct curparse *curp) man = NULL; mdoc = NULL; roff = NULL; + memset(&ln, 0, sizeof(struct buf)); /* @@ -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->outopts); + 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; } } @@ -617,6 +637,7 @@ fdesc(struct curparse *curp) (*curp->outmdoc)(curp->outdata, mdoc); cleanup: + memset(&curp->regs, 0, sizeof(struct regset)); if (mdoc) mdoc_reset(mdoc); if (man) @@ -729,6 +750,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);