source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Downstream maintainers: this removes UGLY!  I don't want
@ 2010-06-27 15:52 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-06-27 15:52 UTC (permalink / raw)
  To: source

Log Message:
-----------
Downstream maintainers: this removes UGLY!  I don't want diverging
functionality and UGLY works quite well thanks to schwarze@'s careful
attention.

This also backs out function-prototype changes for struct regset,
instead stuffing a pointer to the regset directly into struct
mdoc/man/roff.

Modified Files:
--------------
    mdocml:
        Makefile
        libman.h
        libmdoc.h
        main.c
        man.3
        man.c
        man.h
        man_html.c
        mdoc.3
        mdoc.c
        mdoc.h
        mdoc_action.c
        mdoc_macro.c
        roff.3
        roff.c
        roff.h

Revision Data
-------------
Index: roff.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.3,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lroff.3 -Lroff.3 -u -p -r1.2 -r1.3
--- roff.3
+++ roff.3
@@ -30,7 +30,11 @@
 .In regs.h
 .In roff.h
 .Ft "struct roff *"
-.Fn roff_alloc "mandocmsg msgs" "void *data"
+.Fo roff_alloc
+.Fa "struct regset *regs"
+.Fa "mandocmsg msgs"
+.Fa "void *data"
+.Fc
 .Ft int
 .Fn roff_endparse "struct roff *roff"
 .Ft void
Index: mdoc_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -Lmdoc_action.c -Lmdoc_action.c -u -p -r1.71 -r1.72
--- mdoc_action.c
+++ mdoc_action.c
@@ -32,6 +32,11 @@
 #include "libmdoc.h"
 #include "libmandoc.h"
 
+/* 
+ * FIXME: this file is deprecated.  All future "actions" should be
+ * pushed into mdoc_validate.c.
+ */
+
 #define	POST_ARGS struct mdoc *m, struct mdoc_node *n
 #define	PRE_ARGS  struct mdoc *m, struct mdoc_node *n
 
Index: libman.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libman.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -Llibman.h -Llibman.h -u -p -r1.38 -r1.39
--- libman.h
+++ libman.h
@@ -26,8 +26,8 @@ enum	man_next {
 };
 
 struct	man {
-	void		*data;
-	mandocmsg	 msg;
+	void		*data; /* private application data */
+	mandocmsg	 msg; /* output message handler */
 	int		 pflags; /* parse flags (see man.h) */
 	int		 flags; /* parse flags */
 #define	MAN_HALT	(1 << 0) /* badness happened: die */
@@ -36,14 +36,14 @@ struct	man {
 #define	MAN_ILINE	(1 << 3) /* Ignored in next-line scope. */
 #define	MAN_LITERAL	(1 << 4) /* Literal input. */
 #define	MAN_BPLINE	(1 << 5)
-	enum man_next	 next;
-	struct man_node	*last;
-	struct man_node	*first;
-	struct man_meta	 meta;
+	enum man_next	 next; /* where to put the next node */
+	struct man_node	*last; /* the last parsed node */
+	struct man_node	*first; /* the first parsed node */
+	struct man_meta	 meta; /* document meta-data */
+	const struct regset *regs; /* readonly registers */
 };
 
 #define	MACRO_PROT_ARGS	  struct man *m, \
-			  const struct regset *regs, \
 			  enum mant tok, \
 			  int line, \
 			  int ppos, \
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -Lmain.c -Lmain.c -u -p -r1.91 -r1.92
--- main.c
+++ main.c
@@ -88,6 +88,7 @@ struct	curparse {
 	struct man	 *man;		/* man parser */
 	struct mdoc	 *mdoc;		/* mdoc parser */
 	struct roff	 *roff;		/* roff parser (!NULL) */
+	struct regset	  regs;		/* roff registers */
 	enum outt	  outtype; 	/* which output to use */
 	out_mdoc	  outmdoc;	/* mdoc output ptr */
 	out_man	  	  outman;	/* man output ptr */
@@ -298,7 +299,7 @@ man_init(struct curparse *curp)
 	if (curp->fflags & FL_NIGN_ESCAPE)
 		pflags &= ~MAN_IGN_ESCAPE;
 
-	return(man_alloc(curp, pflags, mmsg));
+	return(man_alloc(&curp->regs, curp, pflags, mmsg));
 }
 
 
@@ -306,7 +307,7 @@ static struct roff *
 roff_init(struct curparse *curp)
 {
 
-	return(roff_alloc(mmsg, curp));
+	return(roff_alloc(&curp->regs, mmsg, curp));
 }
 
 
@@ -326,7 +327,7 @@ mdoc_init(struct curparse *curp)
 	if (curp->fflags & FL_NIGN_MACRO)
 		pflags &= ~MDOC_IGN_MACRO;
 
-	return(mdoc_alloc(curp, pflags, mmsg));
+	return(mdoc_alloc(&curp->regs, curp, pflags, mmsg));
 }
 
 
@@ -451,13 +452,12 @@ 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(&regs, 0, sizeof(struct regset));
 
 	/*
 	 * Two buffers: ln and buf.  buf is the input file and may be
@@ -540,7 +540,7 @@ fdesc(struct curparse *curp)
 
 		of = 0;
 		do {
-			re = roff_parseln(roff, &regs, lnn_start, 
+			re = roff_parseln(roff, lnn_start, 
 					&ln.buf, &ln.sz, of, &of);
 		} while (ROFF_RERUN == re);
 
@@ -562,9 +562,9 @@ fdesc(struct curparse *curp)
 
 		/* Lastly, push down into the parsers themselves. */
 
-		if (man && ! man_parseln(man, &regs, lnn_start, ln.buf, of))
+		if (man && ! man_parseln(man, lnn_start, ln.buf, of))
 			goto bailout;
-		if (mdoc && ! mdoc_parseln(mdoc, &regs, lnn_start, ln.buf, of))
+		if (mdoc && ! mdoc_parseln(mdoc, lnn_start, ln.buf, of))
 			goto bailout;
 	}
 
@@ -637,6 +637,7 @@ fdesc(struct curparse *curp)
 		(*curp->outmdoc)(curp->outdata, mdoc);
 
  cleanup:
+	memset(&curp->regs, 0, sizeof(struct regset));
 	if (mdoc)
 		mdoc_reset(mdoc);
 	if (man)
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lman.h -Lman.h -u -p -r1.38 -r1.39
--- man.h
+++ man.h
@@ -106,11 +106,9 @@ __BEGIN_DECLS
 struct	man;
 
 void	 	  man_free(struct man *);
-struct	man	 *man_alloc(void *, int, mandocmsg);
+struct	man	 *man_alloc(const struct regset *, void *, int, mandocmsg);
 void		  man_reset(struct man *);
-int	 	  man_parseln(struct man *, 
-			const struct regset *,
-			int, char *, int);
+int	 	  man_parseln(struct man *, int, char *, int);
 int		  man_endparse(struct man *);
 
 const struct man_node *man_node(const struct man *);
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -Lmdoc.h -Lmdoc.h -u -p -r1.92 -r1.93
--- mdoc.h
+++ mdoc.h
@@ -303,10 +303,9 @@ struct	mdoc_node {
 #define	MDOC_LINE	 (1 << 3) /* first macro/text on line */
 	enum mdoc_type	  type; /* AST node type */
 	enum mdoc_sec	  sec; /* current named section */
+	/* FIXME: these can be union'd to shave a few bytes. */
 	struct mdoc_arg	 *args; 	/* BLOCK/ELEM */
-#ifdef	UGLY
 	struct mdoc_node *pending;	/* BLOCK */
-#endif
 	struct mdoc_node *head;		/* BLOCK */
 	struct mdoc_node *body;		/* BLOCK */
 	struct mdoc_node *tail;		/* BLOCK */
@@ -334,11 +333,9 @@ struct	mdoc;
 /* See mdoc.3 for documentation. */
 
 void	 	  mdoc_free(struct mdoc *);
-struct	mdoc	 *mdoc_alloc(void *, int, mandocmsg);
+struct	mdoc	 *mdoc_alloc(const struct regset *, void *, int, mandocmsg);
 void		  mdoc_reset(struct mdoc *);
-int	 	  mdoc_parseln(struct mdoc *, 
-			const struct regset *,
-			int, char *, int);
+int	 	  mdoc_parseln(struct mdoc *, int, char *, int);
 const struct mdoc_node *mdoc_node(const struct mdoc *);
 const struct mdoc_meta *mdoc_meta(const struct mdoc *);
 int		  mdoc_endparse(struct mdoc *);
Index: Makefile
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v
retrieving revision 1.282
retrieving revision 1.283
diff -LMakefile -LMakefile -u -p -r1.282 -r1.283
--- Makefile
+++ Makefile
@@ -23,10 +23,6 @@ CFLAGS    += -g $(WFLAGS) $(VFLAGS) -DHA
 # in the lower-left hand corner of -mdoc manuals.
 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
 
-# Unset this if you don't want Xo/Xc allowing split `It' lines, which
-# breaks symmetry.
-CFLAGS	  += -DUGLY
-
 LINTFLAGS += $(VFLAGS)
 
 MANDOCFLAGS = -Wall -fstrict
Index: man.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.3,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lman.3 -Lman.3 -u -p -r1.19 -r1.20
--- man.3
+++ man.3
@@ -33,7 +33,12 @@
 .In man.h
 .Vt extern const char * const * man_macronames;
 .Ft "struct man *"
-.Fn man_alloc "void *data" "int pflags" "mandocmsg msgs"
+.Fo man_alloc
+.Fa "const struct regset *regs"
+.Fa "void *data"
+.Fa "int pflags"
+.Fa "mandocmsg msgs"
+.Fc
 .Ft int
 .Fn man_endparse "struct man *man"
 .Ft void
@@ -45,7 +50,6 @@
 .Ft int
 .Fo man_parseln
 .Fa "struct man *man"
-.Fa "const struct regset *regs"
 .Fa "int line"
 .Fa "char *buf"
 .Fc
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lman_html.c -Lman_html.c -u -p -r1.38 -r1.39
--- man_html.c
+++ man_html.c
@@ -252,7 +252,6 @@ a2width(const struct man_node *n, struct
 }
 
 
-/* ARGSUSED */
 static int
 man_root_pre(MAN_ARGS)
 {
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.55 -r1.56
--- libmdoc.h
+++ libmdoc.h
@@ -26,8 +26,8 @@ enum	mdoc_next {
 };
 
 struct	mdoc {
-	void		 *data;
-	mandocmsg	  msg;
+	void		 *data; /* private application data */
+	mandocmsg	  msg; /* message callback */
 	int		  flags;
 #define	MDOC_HALT	 (1 << 0) /* error in parse: halt */
 #define	MDOC_LITERAL	 (1 << 1) /* in a literal scope */
@@ -37,16 +37,16 @@ struct	mdoc {
 #define	MDOC_PPHRASE	 (1 << 5) /* within a partial phrase */
 #define	MDOC_FREECOL	 (1 << 6) /* `It' invocation should close */
 	int		  pflags;
-	enum mdoc_next	  next;
-	struct mdoc_node *last;
-	struct mdoc_node *first;
-	struct mdoc_meta  meta;
+	enum mdoc_next	  next; /* where to put the next node */
+	struct mdoc_node *last; /* the last node parsed */
+	struct mdoc_node *first; /* the first node parsed */
+	struct mdoc_meta  meta; /* document meta-data */
 	enum mdoc_sec	  lastnamed;
 	enum mdoc_sec	  lastsec;
+	const struct regset *regs; /* readonly registers */
 };
 
 #define	MACRO_PROT_ARGS	struct mdoc *m, \
-			const struct regset *regs, \
 			enum mdoct tok, \
 			int line, \
 			int ppos, \
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -Lman.c -Lman.c -u -p -r1.78 -r1.79
--- man.c
+++ man.c
@@ -54,9 +54,7 @@ static	void		 man_node_free(struct man_n
 static	void		 man_node_unlink(struct man *, 
 				struct man_node *);
 static	int		 man_ptext(struct man *, int, char *, int);
-static	int		 man_pmacro(struct man *, 
-				const struct regset *regs,
-				int, char *, int);
+static	int		 man_pmacro(struct man *, int, char *, int);
 static	void		 man_free1(struct man *);
 static	void		 man_alloc1(struct man *);
 static	int		 macrowarn(struct man *, int, const char *, int);
@@ -97,7 +95,8 @@ man_free(struct man *man)
 
 
 struct man *
-man_alloc(void *data, int pflags, mandocmsg msg)
+man_alloc(const struct regset *regs,
+		void *data, int pflags, mandocmsg msg)
 {
 	struct man	*p;
 
@@ -107,6 +106,7 @@ man_alloc(void *data, int pflags, mandoc
 	p->data = data;
 	p->pflags = pflags;
 	p->msg = msg;
+	p->regs = regs;
 
 	man_alloc1(p);
 	return(p);
@@ -127,15 +127,14 @@ man_endparse(struct man *m)
 
 
 int
-man_parseln(struct man *m, const struct regset *regs,
-		int ln, char *buf, int offs)
+man_parseln(struct man *m, int ln, char *buf, int offs)
 {
 
 	if (MAN_HALT & m->flags)
 		return(0);
 
 	return(('.' == buf[offs] || '\'' == buf[offs]) ? 
-			man_pmacro(m, regs, ln, buf, offs) : 
+			man_pmacro(m, ln, buf, offs) : 
 			man_ptext(m, ln, buf, offs));
 }
 
@@ -451,8 +450,7 @@ macrowarn(struct man *m, int ln, const c
 
 
 int
-man_pmacro(struct man *m, const struct regset *regs,
-		int ln, char *buf, int offs)
+man_pmacro(struct man *m, int ln, char *buf, int offs)
 {
 	int		 i, j, ppos;
 	enum mant	 tok;
@@ -577,7 +575,7 @@ man_pmacro(struct man *m, const struct r
 	/* Call to handler... */
 
 	assert(man_macros[tok].fp);
-	if ( ! (*man_macros[tok].fp)(m, regs, tok, ln, ppos, &i, buf))
+	if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf))
 		goto err;
 
 out:
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -Lmdoc.c -Lmdoc.c -u -p -r1.148 -r1.149
--- mdoc.c
+++ mdoc.c
@@ -97,12 +97,8 @@ static	struct mdoc_node *node_alloc(stru
 				enum mdoct, enum mdoc_type);
 static	int		  node_append(struct mdoc *, 
 				struct mdoc_node *);
-static	int		  mdoc_ptext(struct mdoc *, 
-				const struct regset *,
-				int, char *, int);
-static	int		  mdoc_pmacro(struct mdoc *, 
-				const struct regset *,
-				int, char *, int);
+static	int		  mdoc_ptext(struct mdoc *, int, char *, int);
+static	int		  mdoc_pmacro(struct mdoc *, int, char *, int);
 static	int		  macrowarn(struct mdoc *, int, 
 				const char *, int);
 
@@ -196,7 +192,8 @@ mdoc_free(struct mdoc *mdoc)
  * Allocate volatile and non-volatile parse resources.  
  */
 struct mdoc *
-mdoc_alloc(void *data, int pflags, mandocmsg msg)
+mdoc_alloc(const struct regset *regs, 
+		void *data, int pflags, mandocmsg msg)
 {
 	struct mdoc	*p;
 
@@ -205,6 +202,7 @@ mdoc_alloc(void *data, int pflags, mando
 	p->msg = msg;
 	p->data = data;
 	p->pflags = pflags;
+	p->regs = regs;
 
 	mdoc_hash_init();
 	mdoc_alloc1(p);
@@ -234,8 +232,7 @@ mdoc_endparse(struct mdoc *m)
  * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
  */
 int
-mdoc_parseln(struct mdoc *m, const struct regset *regs,
-		int ln, char *buf, int offs)
+mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs)
 {
 
 	if (MDOC_HALT & m->flags)
@@ -243,8 +240,8 @@ mdoc_parseln(struct mdoc *m, const struc
 
 	m->flags |= MDOC_NEWLINE;
 	return(('.' == buf[offs] || '\'' == buf[offs]) ? 
-			mdoc_pmacro(m, regs, ln, buf, offs) :
-			mdoc_ptext(m, regs, ln, buf, offs));
+			mdoc_pmacro(m, ln, buf, offs) :
+			mdoc_ptext(m, ln, buf, offs));
 }
 
 
@@ -291,8 +288,7 @@ mdoc_macro(MACRO_PROT_ARGS)
 		m->flags |= MDOC_PBODY;
 	}
 
-	return((*mdoc_macros[tok].fp)
-			(m, regs, tok, line, ppos, pos, buf));
+	return((*mdoc_macros[tok].fp)(m, tok, line, ppos, pos, buf));
 }
 
 
@@ -546,8 +542,7 @@ mdoc_node_delete(struct mdoc *m, struct 
  * control character.
  */
 static int
-mdoc_ptext(struct mdoc *m, const struct regset *regs,
-		int line, char *buf, int offs)
+mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
 {
 	char		 *c, *ws, *end;
 	struct mdoc_node *n;
@@ -578,8 +573,7 @@ mdoc_ptext(struct mdoc *m, const struct 
 			LIST_column == n->data.Bl.type) {
 		/* `Bl' is open without any children. */
 		m->flags |= MDOC_FREECOL;
-		return(mdoc_macro(m, regs, MDOC_It, 
-					line, offs, &offs, buf));
+		return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
 	}
 
 	if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
@@ -588,8 +582,7 @@ mdoc_ptext(struct mdoc *m, const struct 
 			LIST_column == n->parent->data.Bl.type) {
 		/* `Bl' has block-level `It' children. */
 		m->flags |= MDOC_FREECOL;
-		return(mdoc_macro(m, regs, MDOC_It, 
-					line, offs, &offs, buf));
+		return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
 	}
 
 	/*
@@ -699,8 +692,7 @@ macrowarn(struct mdoc *m, int ln, const 
  * character.
  */
 int
-mdoc_pmacro(struct mdoc *m, const struct regset *regs,
-		int ln, char *buf, int offs)
+mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
 {
 	enum mdoct	  tok;
 	int		  i, j, sv;
@@ -779,7 +771,7 @@ mdoc_pmacro(struct mdoc *m, const struct
 	 */
 
 	if (NULL == m->last || MDOC_It == tok || MDOC_El == tok) {
-		if ( ! mdoc_macro(m, regs, tok, ln, sv, &i, buf)) 
+		if ( ! mdoc_macro(m, tok, ln, sv, &i, buf)) 
 			goto err;
 		return(1);
 	}
@@ -795,7 +787,7 @@ mdoc_pmacro(struct mdoc *m, const struct
 	if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
 			LIST_column == n->data.Bl.type) {
 		m->flags |= MDOC_FREECOL;
-		if ( ! mdoc_macro(m, regs, MDOC_It, ln, sv, &sv, buf))
+		if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
 			goto err;
 		return(1);
 	}
@@ -811,14 +803,14 @@ mdoc_pmacro(struct mdoc *m, const struct
 			MDOC_Bl == n->parent->tok &&
 			LIST_column == n->parent->data.Bl.type) {
 		m->flags |= MDOC_FREECOL;
-		if ( ! mdoc_macro(m, regs, MDOC_It, ln, sv, &sv, buf)) 
+		if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) 
 			goto err;
 		return(1);
 	}
 
 	/* Normal processing of a macro. */
 
-	if ( ! mdoc_macro(m, regs, tok, ln, sv, &i, buf)) 
+	if ( ! mdoc_macro(m, tok, ln, sv, &i, buf)) 
 		goto err;
 
 	return(1);
Index: roff.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lroff.h -Lroff.h -u -p -r1.16 -r1.17
--- roff.h
+++ roff.h
@@ -29,10 +29,10 @@ __BEGIN_DECLS
 struct	roff;
 
 void	 	  roff_free(struct roff *);
-struct	roff	 *roff_alloc(mandocmsg, void *);
+struct	roff	 *roff_alloc(struct regset *, mandocmsg, void *);
 void		  roff_reset(struct roff *);
-enum	rofferr	  roff_parseln(struct roff *, struct regset *,
-			int, char **, size_t *, int, int *);
+enum	rofferr	  roff_parseln(struct roff *, int, 
+			char **, size_t *, int, int *);
 int		  roff_endparse(struct roff *);
 
 __END_DECLS
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -Lroff.c -Lroff.c -u -p -r1.89 -r1.90
--- roff.c
+++ roff.c
@@ -74,6 +74,7 @@ struct	roff {
 	void		*data; /* privdata for messages */
 	enum roffrule	 rstack[RSTACK_MAX]; /* stack of !`ie' rules */
 	int		 rstackpos; /* position in rstack */
+	struct regset	*regs; /* read/writable registers */
 };
 
 struct	roffnode {
@@ -87,7 +88,6 @@ struct	roffnode {
 };
 
 #define	ROFF_ARGS	 struct roff *r, /* parse ctx */ \
-			 struct regset *regs, /* registers */ \
 			 enum rofft tok, /* tok of macro */ \
 		 	 char **bufp, /* input buffer */ \
 			 size_t *szp, /* size of input buffer */ \
@@ -289,7 +289,7 @@ roff_free(struct roff *r)
 
 
 struct roff *
-roff_alloc(const mandocmsg msg, void *data)
+roff_alloc(struct regset *regs, const mandocmsg msg, void *data)
 {
 	struct roff	*r;
 
@@ -298,6 +298,7 @@ roff_alloc(const mandocmsg msg, void *da
 		return(0);
 	}
 
+	r->regs = regs;
 	r->msg = msg;
 	r->data = data;
 	r->rstackpos = -1;
@@ -308,8 +309,8 @@ roff_alloc(const mandocmsg msg, void *da
 
 
 enum rofferr
-roff_parseln(struct roff *r, struct regset *regs, int ln, 
-		char **bufp, size_t *szp, int pos, int *offs)
+roff_parseln(struct roff *r, int ln, char **bufp, 
+		size_t *szp, int pos, int *offs)
 {
 	enum rofft	 t;
 	int		 ppos;
@@ -326,8 +327,8 @@ roff_parseln(struct roff *r, struct regs
 		ROFF_DEBUG("roff: intercept scoped text: %s, [%s]\n", 
 				roffs[t].name, &(*bufp)[pos]);
 		return((*roffs[t].text)
-				(r, regs, t, bufp, 
-				 szp, ln, pos, pos, offs));
+				(r, t, bufp, szp, 
+				 ln, pos, pos, offs));
 	} else if ( ! ROFF_CTL((*bufp)[pos])) {
 		ROFF_DEBUG("roff: pass non-scoped text: [%s]\n", 
 				&(*bufp)[pos]);
@@ -345,8 +346,8 @@ roff_parseln(struct roff *r, struct regs
 		ROFF_DEBUG("roff: intercept scoped context: %s\n", 
 				roffs[t].name);
 		return((*roffs[t].sub)
-				(r, regs, t, bufp, 
-				 szp, ln, pos, pos, offs));
+				(r, t, bufp, szp, 
+				 ln, pos, pos, offs));
 	}
 
 	/*
@@ -366,8 +367,8 @@ roff_parseln(struct roff *r, struct regs
 			roffs[t].name, &(*bufp)[pos]);
 	assert(roffs[t].proc);
 	return((*roffs[t].proc)
-			(r, regs, t, bufp, 
-			 szp, ln, ppos, pos, offs));
+			(r, t, bufp, szp, 
+			 ln, ppos, pos, offs));
 }
 
 
@@ -653,8 +654,8 @@ roff_block_sub(ROFF_ARGS)
 		return(ROFF_IGN);
 
 	assert(roffs[t].proc);
-	return((*roffs[t].proc)(r, regs, t, bufp, 
-			szp, ln, ppos, pos, offs));
+	return((*roffs[t].proc)(r, t, bufp, szp, 
+				ln, ppos, pos, offs));
 }
 
 
@@ -703,8 +704,8 @@ roff_cond_sub(ROFF_ARGS)
 				return(ROFF_IGN);
 
 	assert(roffs[t].proc);
-	return((*roffs[t].proc)
-			(r, regs, t, bufp, szp, ln, ppos, pos, offs));
+	return((*roffs[t].proc)(r, t, bufp, szp, 
+				ln, ppos, pos, offs));
 }
 
 
@@ -904,11 +905,11 @@ roff_nr(ROFF_ARGS)
 	/* Process register token. */
 
 	if (0 == strcmp(key, "nS")) {
-		if ( ! roff_parse_nat(val, &regs->regs[(int)REG_nS].i))
-			regs->regs[(int)REG_nS].i = 0;
+		if ( ! roff_parse_nat(val, &r->regs->regs[(int)REG_nS].i))
+			r->regs->regs[(int)REG_nS].i = 0;
 
 		ROFF_DEBUG("roff: register nS: %d\n", 
-				regs->regs[(int)REG_nS].i);
+				r->regs->regs[(int)REG_nS].i);
 	} else
 		ROFF_DEBUG("roff: ignoring register: %s\n", key);
 
Index: mdoc_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.81 -r1.82
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -50,9 +50,7 @@ static	int	  	append_delims(struct mdoc 
 				int, int *, char *);
 static	enum mdoct	lookup(enum mdoct, const char *);
 static	enum mdoct	lookup_raw(const char *);
-static	int	  	phrase(struct mdoc *, 
-				const struct regset *,
-				int, int, char *);
+static	int	  	phrase(struct mdoc *, int, int, char *);
 static	enum mdoct 	rew_alt(enum mdoct);
 static	int	  	rew_dobreak(enum mdoct, 
 				const struct mdoc_node *);
@@ -609,7 +607,6 @@ rew_sub(enum mdoc_type t, struct mdoc *m
 	if ( ! rew_last(m, n))
 		return(0);
 
-#ifdef	UGLY
 	/*
 	 * The current block extends an enclosing block beyond a line
 	 * break.  Now that the current block ends, close the enclosing
@@ -622,7 +619,6 @@ rew_sub(enum mdoc_type t, struct mdoc *m
 		if ( ! mdoc_body_alloc(m, n->line, n->pos, n->tok))
 			return(0);
 	}
-#endif
 
 	return(1);
 }
@@ -741,7 +737,7 @@ blk_exp_close(MACRO_PROT_ARGS)
 				return(0);
 			flushed = 1;
 		}
-		if ( ! mdoc_macro(m, regs, ntok, line, lastarg, pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf))
 			return(0);
 		break;
 	}
@@ -842,7 +838,7 @@ in_line(MACRO_PROT_ARGS)
 				if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY))
 					return(0);
 			}
-			if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+			if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 				return(0);
 			if ( ! nl)
 				return(1);
@@ -938,9 +934,7 @@ blk_full(MACRO_PROT_ARGS)
 	struct mdoc_arg	 *arg;
 	struct mdoc_node *head; /* save of head macro */
 	struct mdoc_node *body; /* save of body macro */
-#ifdef	UGLY
 	struct mdoc_node *n;
-#endif
 	enum mdoc_type	  mtt;
 	enum mdoct	  ntok;
 	enum margserr	  ac, lac;
@@ -1088,7 +1082,7 @@ blk_full(MACRO_PROT_ARGS)
 			if (ARGS_PEND == ac && ARGS_PPHRASE == lac)
 				m->flags |= MDOC_PPHRASE;
 
-			if ( ! phrase(m, regs, line, la, buf))
+			if ( ! phrase(m, line, la, buf))
 				return(0);
 
 			m->flags &= ~MDOC_PPHRASE;
@@ -1103,7 +1097,7 @@ blk_full(MACRO_PROT_ARGS)
 			continue;
 		}
 
-		if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 			return(0);
 		break;
 	}
@@ -1122,7 +1116,6 @@ blk_full(MACRO_PROT_ARGS)
 	if (NULL != body)
 		goto out;
 
-#ifdef	UGLY
 	/*
 	 * If there is an open (i.e., unvalidated) sub-block requiring
 	 * explicit close-out, postpone switching the current block from
@@ -1138,7 +1131,6 @@ blk_full(MACRO_PROT_ARGS)
 			return(1);
 		}
 	}
-#endif
 
 	/* Close out scopes to remain in a consistent state. */
 
@@ -1231,7 +1223,7 @@ blk_part_imp(MACRO_PROT_ARGS)
 			continue;
 		}
 
-		if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 			return(0);
 		break;
 	}
@@ -1376,7 +1368,7 @@ blk_part_exp(MACRO_PROT_ARGS)
 			continue;
 		}
 
-		if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 			return(0);
 		break;
 	}
@@ -1495,7 +1487,7 @@ in_line_argn(MACRO_PROT_ARGS)
 			if ( ! flushed && ! rew_elem(m, tok))
 				return(0);
 			flushed = 1;
-			if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+			if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 				return(0);
 			j++;
 			break;
@@ -1601,7 +1593,7 @@ in_line_eoln(MACRO_PROT_ARGS)
 
 		if ( ! rew_elem(m, tok))
 			return(0);
-		return(mdoc_macro(m, regs, ntok, line, la, pos, buf));
+		return(mdoc_macro(m, ntok, line, la, pos, buf));
 	}
 
 	/* Close out (no delimiters). */
@@ -1620,11 +1612,11 @@ ctx_synopsis(MACRO_PROT_ARGS)
 
 	/* If we're not in the SYNOPSIS, go straight to in-line. */
 	if (SEC_SYNOPSIS != m->lastsec)
-		return(in_line(m, regs, tok, line, ppos, pos, buf));
+		return(in_line(m, tok, line, ppos, pos, buf));
 
 	/* If we're a nested call, same place. */
 	if ( ! nl)
-		return(in_line(m, regs, tok, line, ppos, pos, buf));
+		return(in_line(m, tok, line, ppos, pos, buf));
 
 	/*
 	 * XXX: this will open a block scope; however, if later we end
@@ -1632,7 +1624,7 @@ ctx_synopsis(MACRO_PROT_ARGS)
 	 * the formatting.  Be careful.
 	 */
 
-	return(blk_part_imp(m, regs, tok, line, ppos, pos, buf));
+	return(blk_part_imp(m, tok, line, ppos, pos, buf));
 }
 
 
@@ -1651,8 +1643,7 @@ obsolete(MACRO_PROT_ARGS)
  * macro is encountered.
  */
 static int
-phrase(struct mdoc *m, const struct regset *regs,
-		int line, int ppos, char *buf)
+phrase(struct mdoc *m, int line, int ppos, char *buf)
 {
 	int		 la, pos;
 	enum margserr	 ac;
@@ -1677,7 +1668,7 @@ phrase(struct mdoc *m, const struct regs
 			continue;
 		}
 
-		if ( ! mdoc_macro(m, regs, ntok, line, la, &pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, la, &pos, buf))
 			return(0);
 		return(append_delims(m, line, &pos, buf));
 	}
@@ -1722,7 +1713,7 @@ phrase_ta(MACRO_PROT_ARGS)
 			continue;
 		}
 
-		if ( ! mdoc_macro(m, regs, ntok, line, la, pos, buf))
+		if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
 			return(0);
 		return(append_delims(m, line, pos, buf));
 	}
Index: mdoc.3
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.3,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lmdoc.3 -Lmdoc.3 -u -p -r1.42 -r1.43
--- mdoc.3
+++ mdoc.3
@@ -34,7 +34,12 @@
 .Vt extern const char * const * mdoc_macronames;
 .Vt extern const char * const * mdoc_argnames;
 .Ft "struct mdoc *"
-.Fn mdoc_alloc "void *data" "int pflags" "mandocmsg msgs"
+.Fo mdoc_alloc
+.Fa "const struct regset *regs"
+.Fa "void *data"
+.Fa "int pflags"
+.Fa "mandocmsg msgs"
+.Fc
 .Ft int
 .Fn mdoc_endparse "struct mdoc *mdoc"
 .Ft void
@@ -46,7 +51,6 @@
 .Ft int
 .Fo mdoc_parseln
 .Fa "struct mdoc *mdoc"
-.Fa "const struct regset *regs"
 .Fa "int line"
 .Fa "char *buf"
 .Fc
--
 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:[~2010-06-27 15:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-27 15:52 mdocml: Downstream maintainers: this removes UGLY! I don't want 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).