summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:05:21 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:05:21 +0000
commit002654087a2649b42224713c7386f9c9d3b71435 (patch)
tree0deca47fa43559ea06eeb65f1dc893083709506d
parent80339b751a1833d9bbbf9856e7f48f56d91ba1d3 (diff)
downloadmandoc-002654087a2649b42224713c7386f9c9d3b71435.tar.gz
Let read.c worry about the currently-open file instead of having this
information duplicated in main.c. For the time being, remove evt_close and evt_open, as the only known mparse interface (main.c) doesn't need them.
-rw-r--r--main.c22
-rw-r--r--mandoc.h5
-rw-r--r--read.c13
3 files changed, 3 insertions, 37 deletions
diff --git a/main.c b/main.c
index 2099b110..3cb730ad 100644
--- a/main.c
+++ b/main.c
@@ -54,7 +54,6 @@ enum outt {
struct curparse {
struct mparse *mp;
- const char *file; /* current file-name */
enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
enum outt outtype; /* which output to use */
@@ -182,8 +181,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"static buffer exhausted",
};
-static void evt_close(void *, const char *);
-static int evt_open(void *, const char *);
static int moptions(enum mparset *, char *);
static void mmsg(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
@@ -243,7 +240,7 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- curp.mp = mparse_alloc(type, evt_open, evt_close, curp.wlevel, mmsg, &curp);
+ curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp);
argc -= optind;
argv += optind;
@@ -293,23 +290,6 @@ usage(void)
exit((int)MANDOCLEVEL_BADARG);
}
-static int
-evt_open(void *arg, const char *file)
-{
-
- evt_close(arg, file);
- return(1);
-}
-
-static void
-evt_close(void *arg, const char *file)
-{
- struct curparse *p;
-
- p = (struct curparse *)arg;
- p->file = file;
-}
-
static void
parse(struct curparse *curp, int fd,
const char *file, enum mandoclevel *level)
diff --git a/mandoc.h b/mandoc.h
index 9ebc0c8d..dceb0c32 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -341,8 +341,6 @@ enum mparset {
typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
-typedef int (*mevt_open)(void *, const char *);
-typedef void (*mevt_close)(void *, const char *);
struct mparse;
struct mdoc;
@@ -352,8 +350,7 @@ __BEGIN_DECLS
void mparse_free(struct mparse *);
void mparse_reset(struct mparse *);
-struct mparse *mparse_alloc(enum mparset, mevt_open,
- mevt_close,
+struct mparse *mparse_alloc(enum mparset,
enum mandoclevel, mandocmsg, void *);
enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
void mparse_result(struct mparse *, struct mdoc **, struct man **);
diff --git a/read.c b/read.c
index 8f401733..054086c4 100644
--- a/read.c
+++ b/read.c
@@ -58,8 +58,6 @@ struct mparse {
int reparse_count; /* finite interp. stack */
mandocmsg mmsg; /* warning/error message handler */
void *arg; /* argument to mmsg */
- mevt_open evt_open; /* file-open event */
- mevt_close evt_close; /* file-close event */
const char *file;
};
@@ -518,11 +516,6 @@ mparse_readfd_r(struct mparse *curp, int fd, const char *file, int re)
{
const char *svfile;
- if ( ! (*curp->evt_open)(curp->arg, file)) {
- curp->file_status = MANDOCLEVEL_SYSERR;
- return;
- }
-
if (-1 == fd)
if (-1 == (fd = open(file, O_RDONLY, 0))) {
perror(file);
@@ -541,7 +534,6 @@ mparse_readfd_r(struct mparse *curp, int fd, const char *file, int re)
if (STDIN_FILENO != fd && -1 == close(fd))
perror(file);
- (*curp->evt_close)(curp->arg, file);
curp->file = svfile;
}
@@ -554,8 +546,7 @@ mparse_readfd(struct mparse *curp, int fd, const char *file)
}
struct mparse *
-mparse_alloc(enum mparset inttype, mevt_open eopen,
- mevt_close eclose, enum mandoclevel wlevel, mandocmsg mmsg, void *arg)
+mparse_alloc(enum mparset inttype, enum mandoclevel wlevel, mandocmsg mmsg, void *arg)
{
struct mparse *curp;
@@ -565,8 +556,6 @@ mparse_alloc(enum mparset inttype, mevt_open eopen,
curp->mmsg = mmsg;
curp->arg = arg;
curp->inttype = inttype;
- curp->evt_open = eopen;
- curp->evt_close = eclose;
curp->roff = roff_alloc(&curp->regs, curp);
return(curp);