summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-07-25 18:05:55 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-07-25 18:05:55 +0000
commit2c7e21c9c6f035c407794c7a5c7f104993112ae9 (patch)
treec4b4a76dac0cea861453ea825cdd2a1a0476f6b3 /usr.bin/mandoc/main.c
parentfce92b3e5f7a530f60b9a1d28e5efbd86d838887 (diff)
Sync to bsd.lv; in particular, pull in lots of bug fixes.
new features: * support the .in macro in man(7) * support minimal PDF output * support .Sm in mdoc(7) HTML output * support .Vb and .nf in man(7) HTML output * complete the mdoc(7) manual bug fixes: * do not let mdoc(7) .Pp produce a newline before/after .Sh; reported by jmc@ * avoid double blank lines related to man(7) .sp and .br * let man(7) .nf and .fi flush the line; reported by jsg@ and naddy@ * let "\ " produce a non-breaking space; reported by deraadt@ * discard \m colour escape sequences; reported by J.C. Roberts * map undefined 1-character-escapes to the literal character itself maintenance: * express mdoc(7) arguments in terms of an enum for additional type-safety * simplify mandoc_special() and a2roffdeco() * use strcspn in term_word() in place of a manual loop * minor optimisations in the -Tps and -Thtml formatting frontends
Diffstat (limited to 'usr.bin/mandoc/main.c')
-rw-r--r--usr.bin/mandoc/main.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 53b4e7b81e3..512581e4e30 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.42 2010/07/13 01:09:12 schwarze Exp $ */
+/* $Id: main.c,v 1.43 2010/07/25 18:05:54 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,6 +20,7 @@
#include <sys/stat.h>
#include <assert.h>
+#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
@@ -56,7 +57,8 @@ enum outt {
OUTT_HTML,
OUTT_XHTML,
OUTT_LINT,
- OUTT_PS
+ OUTT_PS,
+ OUTT_PDF
};
struct curparse {
@@ -99,6 +101,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"list type must come first",
"bad standard",
"bad library",
+ "tab in non-literal context",
"bad escape sequence",
"unterminated quoted string",
"argument requires the width argument",
@@ -480,6 +483,26 @@ fdesc(struct curparse *curp)
++lnn;
break;
}
+
+ /*
+ * Warn about bogus characters. If you're using
+ * non-ASCII encoding, you're screwing your
+ * readers. Since I'd rather this not happen,
+ * I'll be helpful and drop these characters so
+ * we don't display gibberish. Note to manual
+ * writers: use special characters.
+ */
+
+ if ( ! isgraph((u_char)blk.buf[i]) &&
+ ! isblank((u_char)blk.buf[i])) {
+ if ( ! mmsg(MANDOCERR_BADCHAR, curp,
+ lnn_start, pos,
+ "ignoring byte"))
+ goto bailout;
+ i++;
+ continue;
+ }
+
/* Trailing backslash is like a plain character. */
if ('\\' != blk.buf[i] || i + 1 == (int)blk.sz) {
if (pos >= (int)ln.sz)
@@ -597,9 +620,13 @@ fdesc(struct curparse *curp)
curp->outdata = ascii_alloc(curp->outopts);
curp->outfree = ascii_free;
break;
+ case (OUTT_PDF):
+ curp->outdata = pdf_alloc(curp->outopts);
+ curp->outfree = pspdf_free;
+ break;
case (OUTT_PS):
curp->outdata = ps_alloc(curp->outopts);
- curp->outfree = ps_free;
+ curp->outfree = pspdf_free;
break;
default:
break;
@@ -617,6 +644,8 @@ fdesc(struct curparse *curp)
curp->outman = tree_man;
curp->outmdoc = tree_mdoc;
break;
+ case (OUTT_PDF):
+ /* FALLTHROUGH */
case (OUTT_ASCII):
/* FALLTHROUGH */
case (OUTT_PS):
@@ -751,6 +780,8 @@ toptions(struct curparse *curp, char *arg)
curp->outtype = OUTT_XHTML;
else if (0 == strcmp(arg, "ps"))
curp->outtype = OUTT_PS;
+ else if (0 == strcmp(arg, "pdf"))
+ curp->outtype = OUTT_PDF;
else {
fprintf(stderr, "%s: Bad argument\n", arg);
return(0);