source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Let read.c worry about the currently-open file instead of having
@ 2011-03-20 16:05 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-03-20 16:05 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        main.c
        mandoc.h
        read.c

Revision Data
-------------
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -Lmandoc.h -Lmandoc.h -u -p -r1.63 -r1.64
--- mandoc.h
+++ 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 **);
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lread.c -Lread.c -u -p -r1.3 -r1.4
--- read.c
+++ 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
 {
 	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
 	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 f
 }
 
 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_
 	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);
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -Lmain.c -Lmain.c -u -p -r1.155 -r1.156
--- main.c
+++ 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[MAN
 	"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;
@@ -291,23 +288,6 @@ usage(void)
 			progname);
 
 	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
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-20 16:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-20 16:05 mdocml: Let read.c worry about the currently-open file instead of having kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).