=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.80 retrieving revision 1.90 diff -u -p -r1.80 -r1.90 --- mandoc/main.c 2010/05/31 23:40:25 1.80 +++ mandoc/main.c 2010/06/26 15:22:19 1.90 @@ -1,6 +1,6 @@ -/* $Id: main.c,v 1.80 2010/05/31 23:40:25 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 { @@ -97,7 +99,7 @@ struct curparse { static const char * const mandocerrs[MANDOCERR_MAX] = { "ok", "text should be uppercase", - "sections out of conentional order", + "sections out of conventional order", "section name repeats", "out of order prologue", "repeated prologue entry", @@ -108,9 +110,10 @@ 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 sction", + "unknown manual section", "section not in conventional manual section", "end of line whitespace", "scope open on exit", @@ -141,13 +144,14 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "macro requires body argument(s)", "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", - "missing list type", "displays may not be nested", + "unsupported display type", "no scope to rewind: syntax violated", "scope broken, syntax violated", "line scope broken, syntax violated", @@ -395,7 +399,7 @@ read_whole_file(struct curparse *curp, struct buf *fb, *with_mmap = 1; fb->sz = (size_t)st.st_size; fb->buf = mmap(NULL, fb->sz, PROT_READ, - MAP_FILE, curp->fd, 0); + MAP_FILE|MAP_SHARED, curp->fd, 0); if (fb->buf != MAP_FAILED) return(1); } @@ -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(80); + 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);