summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 21:46:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 21:46:24 +0000
commitef64725c09db0346dd0d5a32ae063e383d216b33 (patch)
tree59b22eafa2935cea48a1d8e0c12c41c51e6e944f
parent5fa47110bac19f7e6acb9a32e76e800657e98799 (diff)
downloadmandoc-ef64725c09db0346dd0d5a32ae063e383d216b33.tar.gz
mandoc-ef64725c09db0346dd0d5a32ae063e383d216b33.tar.zst
mandoc-ef64725c09db0346dd0d5a32ae063e383d216b33.zip
*** empty log message ***
-rw-r--r--main.c53
-rw-r--r--man.c3
-rw-r--r--man_validate.c3
-rw-r--r--term.h6
-rw-r--r--terminal.c18
5 files changed, 27 insertions, 56 deletions
diff --git a/main.c b/main.c
index 902d7324..b0b5561a 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.15 2009/03/25 21:03:13 kristaps Exp $ */
+/* $Id: main.c,v 1.16 2009/03/25 21:46:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -29,6 +29,8 @@
#include "mdoc.h"
#include "man.h"
+/* Account for FreeBSD and Linux in our declarations. */
+
#ifdef __linux__
extern int getsubopt(char **, char * const *, char **);
# ifndef __dead
@@ -54,9 +56,9 @@ struct curparse {
#define WARN_WERR (1 << 2) /* Warnings->errors. */
};
-#define IGN_SCOPE (1 << 0) /* Flag to ignore scope. */
-#define IGN_ESCAPE (1 << 1) /* Flag to ignore bad escapes. */
-#define IGN_MACRO (1 << 2) /* Flag to ignore unknown macros. */
+#define IGN_SCOPE (1 << 0) /* Ignore scope errors. */
+#define IGN_ESCAPE (1 << 1) /* Ignore bad escapes. */
+#define IGN_MACRO (1 << 2) /* Ignore unknown macros. */
enum intt {
INTT_MDOC = 0,
@@ -65,8 +67,6 @@ enum intt {
enum outt {
OUTT_ASCII = 0,
- OUTT_LATIN1,
- OUTT_UTF8,
OUTT_TREE,
OUTT_LINT
};
@@ -78,8 +78,6 @@ typedef void (*out_free)(void *);
extern char *__progname;
extern void *ascii_alloc(void);
-extern void *latin1_alloc(void);
-extern void *utf8_alloc(void);
extern int terminal_run(void *, const struct man *,
const struct mdoc *);
extern int tree_run(void *, const struct man *,
@@ -100,7 +98,6 @@ static int file(struct buf *, struct buf *,
static int fdesc(struct buf *, struct buf *,
const char *, int,
struct man *, struct mdoc *);
-
__dead static void version(void);
__dead static void usage(void);
@@ -158,23 +155,13 @@ main(int argc, char *argv[])
argv += optind;
/*
- * Allocate the appropriate front-end. Note that utf8, ascii
- * and latin1 all resolve to the terminal front-end with
- * different encodings (see terminal.c). Not all frontends have
- * cleanup or alloc routines.
+ * Allocate the appropriate front-end. Note that utf8, latin1
+ * (both not yet implemented) and ascii all resolve to the
+ * terminal front-end with different encodings (see terminal.c).
+ * Not all frontends have cleanup or alloc routines.
*/
switch (outtype) {
- case (OUTT_LATIN1):
- outdata = latin1_alloc();
- outrun = terminal_run;
- outfree = terminal_free;
- break;
- case (OUTT_UTF8):
- outdata = utf8_alloc();
- outrun = terminal_run;
- outfree = terminal_free;
- break;
case (OUTT_TREE):
outdata = NULL;
outrun = tree_run;
@@ -204,6 +191,8 @@ main(int argc, char *argv[])
mancb.man_err = merr;
mancb.man_warn = manwarn;
+ /* Configure buffers. */
+
bzero(&ln, sizeof(struct buf));
bzero(&blk, sizeof(struct buf));
@@ -211,11 +200,16 @@ main(int argc, char *argv[])
mdoc = NULL;
pflags = 0;
+ /*
+ * Allocate the parser. There are two kinds of parser: libman
+ * and libmdoc. We must separately copy over the flags that
+ * we'll use internally.
+ */
+
switch (inttype) {
case (INTT_MAN):
if (fflags & IGN_MACRO)
pflags |= MAN_IGN_MACRO;
-
man = man_alloc(&curp, pflags, &mancb);
break;
default:
@@ -225,20 +219,18 @@ main(int argc, char *argv[])
pflags |= MDOC_IGN_ESCAPE;
if (fflags & IGN_MACRO)
pflags |= MDOC_IGN_MACRO;
-
mdoc = mdoc_alloc(&curp, pflags, &mdoccb);
break;
}
/*
- * Loop around available files.
+ * Main loop around available files.
*/
if (NULL == *argv) {
curp.file = "<stdin>";
rc = 0;
- c = fdesc(&blk, &ln, "stdin",
- STDIN_FILENO, man, mdoc);
+ c = fdesc(&blk, &ln, "stdin", STDIN_FILENO, man, mdoc);
if (c && NULL == outrun)
rc = 1;
@@ -256,7 +248,6 @@ main(int argc, char *argv[])
man_reset(man);
if (mdoc)
mdoc_reset(mdoc);
-
argv++;
}
rc = NULL == *argv;
@@ -429,10 +420,6 @@ toptions(enum outt *tflags, char *arg)
if (0 == strcmp(arg, "ascii"))
*tflags = OUTT_ASCII;
- else if (0 == strcmp(arg, "latin1"))
- *tflags = OUTT_LATIN1;
- else if (0 == strcmp(arg, "utf8"))
- *tflags = OUTT_UTF8;
else if (0 == strcmp(arg, "lint"))
*tflags = OUTT_LINT;
else if (0 == strcmp(arg, "tree"))
diff --git a/man.c b/man.c
index 21c15e71..d3223e69 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.7 2009/03/25 21:03:13 kristaps Exp $ */
+/* $Id: man.c,v 1.8 2009/03/25 21:46:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -18,6 +18,7 @@
*/
#include <assert.h>
#include <ctype.h>
+#include <err.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/man_validate.c b/man_validate.c
index 4fb4aae7..2f2f9c8d 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.1 2009/03/25 15:17:49 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.2 2009/03/25 21:46:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -80,7 +80,6 @@ man_valid_post(struct man *m)
if (MAN_VALID & m->last->flags)
return(1);
-
m->last->flags |= MAN_VALID;
switch (m->last->type) {
diff --git a/term.h b/term.h
index cd065bdf..23d1b53e 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.32 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: term.h,v 1.33 2009/03/25 21:46:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -30,8 +30,8 @@ __BEGIN_DECLS
enum termenc {
TERMENC_ASCII,
- TERMENC_LATIN1,
- TERMENC_UTF8
+ TERMENC_LATIN1, /* Not implemented. */
+ TERMENC_UTF8 /* Not implemented. */
};
struct termp {
diff --git a/terminal.c b/terminal.c
index f4d7cd2a..07373b21 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1,4 +1,4 @@
-/* $Id: terminal.c,v 1.7 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: terminal.c,v 1.8 2009/03/25 21:46:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -52,22 +52,6 @@ static void sanity(const struct mdoc_node *); /* XXX */
void *
-latin1_alloc(void)
-{
-
- return(term_alloc(TERMENC_LATIN1));
-}
-
-
-void *
-utf8_alloc(void)
-{
-
- return(term_alloc(TERMENC_UTF8));
-}
-
-
-void *
ascii_alloc(void)
{