source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Third step towards parser unification: Replace struct mdoc_meta
@ 2015-04-02 23:48 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-04-02 23:48 UTC (permalink / raw)
  To: source

Log Message:
-----------
Third step towards parser unification:
Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta.
Written of the train from London to Exeter on the way to p2k15.

Modified Files:
--------------
    mdocml:
        libman.h
        libmdoc.h
        man.c
        man.h
        man_html.c
        man_term.c
        man_validate.c
        mandoc_headers.3
        mandocdb.c
        mdoc.c
        mdoc.h
        mdoc_html.c
        mdoc_man.c
        mdoc_term.c
        roff.h
        term.c
        term.h

Revision Data
-------------
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.240
retrieving revision 1.241
diff -Lmdoc.c -Lmdoc.c -u -p -r1.240 -r1.241
--- mdoc.c
+++ mdoc.c
@@ -7,9 +7,9 @@
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -102,7 +102,7 @@ mdoc_node(const struct mdoc *mdoc)
 	return(mdoc->first);
 }
 
-const struct mdoc_meta *
+const struct roff_meta *
 mdoc_meta(const struct mdoc *mdoc)
 {
 
@@ -134,7 +134,7 @@ static void
 mdoc_alloc1(struct mdoc *mdoc)
 {
 
-	memset(&mdoc->meta, 0, sizeof(struct mdoc_meta));
+	memset(&mdoc->meta, 0, sizeof(mdoc->meta));
 	mdoc->flags = 0;
 	mdoc->lastnamed = mdoc->lastsec = SEC_NONE;
 	mdoc->last = mandoc_calloc(1, sizeof(*mdoc->last));
Index: roff.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lroff.h -Lroff.h -u -p -r1.29 -r1.30
--- roff.h
+++ roff.h
@@ -104,3 +104,14 @@ struct	roff_node {
 	enum roff_sec	  sec;     /* Current named section. */
 	enum mdoc_endbody end;     /* BODY */
 };
+
+struct	roff_meta {
+	char		 *msec;    /* Manual section, usually a digit. */
+	char		 *vol;     /* Manual volume title. */
+	char		 *os;      /* Operating system. */
+	char		 *arch;    /* Machine architecture. */
+	char		 *title;   /* Manual title, usually CAPS. */
+	char		 *name;    /* Leading manual name. */
+	char		 *date;    /* Normalized date. */
+	int		  hasbody; /* Document is not empty. */
+};
Index: mandoc_headers.3
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc_headers.3,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.5 -r1.6
--- mandoc_headers.3
+++ mandoc_headers.3
@@ -121,6 +121,7 @@ Provides
 .Vt enum mdoc_endbody ,
 .Vt enum roff_sec ,
 .Vt enum roff_type ,
+.Vt struct roff_meta ,
 and
 .Vt struct roff_node .
 .Pp
@@ -154,7 +155,6 @@ Provides
 .Vt enum mdoc_list ,
 .Vt enum mdoc_auth ,
 .Vt enum mdoc_font ,
-.Vt struct mdoc_meta ,
 .Vt struct mdoc_argv ,
 .Vt struct mdoc_arg ,
 .Vt struct mdoc_bd ,
@@ -188,9 +188,7 @@ Requires
 for
 .Vt enum roff_type .
 .Pp
-Provides
-.Vt struct man_meta
-and the functions
+Provides the functions
 .Fn man_*
 described in
 .Xr mandoc 3 .
@@ -226,11 +224,16 @@ are included, the same file should not i
 Requires
 .In sys/types.h
 for
-.Vt size_t
-and
+.Vt size_t ,
 .Qq Pa mandoc.h
 for
-.Vt enum mandocerr .
+.Vt enum mandocerr ,
+and
+.Qq Pa roff.h
+for
+.Vt struct roff_meta
+and
+.Vt struct roff_node .
 .Pp
 Provides
 .Vt enum rofferr ,
@@ -297,7 +300,9 @@ or
 Requires
 .Qq Pa roff.h
 for
-.Vt struct roff_node.
+.Vt struct roff_meta
+and
+.Vt struct roff_node .
 .Pp
 Provides
 .Vt enum man_next ,
@@ -420,6 +425,10 @@ and
 .Vt struct eqn
 from
 .Pa mandoc.h
+and
+.Vt struct roff_meta
+from
+.Qq Pa roff.h
 as opaque types for function prototypes.
 .Pp
 When this header is included, the same file should not include
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.315
retrieving revision 1.316
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.315 -r1.316
--- mdoc_term.c
+++ mdoc_term.c
@@ -43,7 +43,7 @@ struct	termpair {
 
 #define	DECL_ARGS struct termp *p, \
 		  struct termpair *pair, \
-		  const struct mdoc_meta *meta, \
+		  const struct roff_meta *meta, \
 		  struct roff_node *n
 
 struct	termact {
@@ -58,8 +58,8 @@ static	void	  print_bvspace(struct termp
 			const struct roff_node *);
 static	void	  print_mdoc_node(DECL_ARGS);
 static	void	  print_mdoc_nodelist(DECL_ARGS);
-static	void	  print_mdoc_head(struct termp *, const void *);
-static	void	  print_mdoc_foot(struct termp *, const void *);
+static	void	  print_mdoc_head(struct termp *, const struct roff_meta *);
+static	void	  print_mdoc_foot(struct termp *, const struct roff_meta *);
 static	void	  synopsis_pre(struct termp *,
 			const struct roff_node *);
 
@@ -253,7 +253,7 @@ static	const struct termact termacts[MDO
 void
 terminal_mdoc(void *arg, const struct mdoc *mdoc)
 {
-	const struct mdoc_meta	*meta;
+	const struct roff_meta	*meta;
 	struct roff_node	*n;
 	struct termp		*p;
 
@@ -407,13 +407,10 @@ print_mdoc_node(DECL_ARGS)
 }
 
 static void
-print_mdoc_foot(struct termp *p, const void *arg)
+print_mdoc_foot(struct termp *p, const struct roff_meta *meta)
 {
-	const struct mdoc_meta *meta;
 	size_t sz;
 
-	meta = (const struct mdoc_meta *)arg;
-
 	term_fontrepl(p, TERMFONT_NONE);
 
 	/*
@@ -459,13 +456,10 @@ print_mdoc_foot(struct termp *p, const v
 }
 
 static void
-print_mdoc_head(struct termp *p, const void *arg)
+print_mdoc_head(struct termp *p, const struct roff_meta *meta)
 {
-	const struct mdoc_meta	*meta;
 	char			*volume, *title;
 	size_t			 vollen, titlen;
-
-	meta = (const struct mdoc_meta *)arg;
 
 	/*
 	 * The header is strange.  It has three components, which are
Index: libmdoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libmdoc.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.98 -r1.99
--- libmdoc.h
+++ libmdoc.h
@@ -40,7 +40,7 @@ struct	mdoc {
 	struct roff_node *last; /* the last node parsed */
 	struct roff_node *first; /* the first node parsed */
 	struct roff_node *last_es; /* the most recent Es node */
-	struct mdoc_meta  meta; /* document meta-data */
+	struct roff_meta  meta; /* document meta-data */
 	enum roff_sec	  lastnamed;
 	enum roff_sec	  lastsec;
 	struct roff	 *roff;
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.111
retrieving revision 1.112
diff -Lterm.h -Lterm.h -u -p -r1.111 -r1.112
--- term.h
+++ term.h
@@ -1,15 +1,15 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -38,9 +38,10 @@ enum	termfont {
 
 #define	TERM_MAXMARGIN	  100000 /* FIXME */
 
+struct	roff_meta;
 struct	termp;
 
-typedef void	(*term_margin)(struct termp *, const void *);
+typedef void	(*term_margin)(struct termp *, const struct roff_meta *);
 
 struct	termp_tbl {
 	int		  width;	/* width in fixed chars */
@@ -117,7 +118,7 @@ void		  term_vspace(struct termp *);
 void		  term_word(struct termp *, const char *);
 void		  term_flushln(struct termp *);
 void		  term_begin(struct termp *, term_margin,
-			term_margin, const void *);
+			term_margin, const struct roff_meta *);
 void		  term_end(struct termp *);
 
 void		  term_setwidth(struct termp *, const char *);
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -Lterm.c -Lterm.c -u -p -r1.245 -r1.246
--- term.c
+++ term.c
@@ -7,9 +7,9 @@
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -49,7 +49,7 @@ term_free(struct termp *p)
 
 void
 term_begin(struct termp *p, term_margin head,
-		term_margin foot, const void *arg)
+		term_margin foot, const struct roff_meta *arg)
 {
 
 	p->headf = head;
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.90 -r1.91
--- mdoc_man.c
+++ mdoc_man.c
@@ -30,7 +30,7 @@
 #include "out.h"
 #include "main.h"
 
-#define	DECL_ARGS const struct mdoc_meta *meta, struct roff_node *n
+#define	DECL_ARGS const struct roff_meta *meta, struct roff_node *n
 
 struct	manact {
 	int		(*cond)(DECL_ARGS); /* DON'T run actions */
@@ -547,7 +547,7 @@ man_man(void *arg, const struct man *man
 void
 man_mdoc(void *arg, const struct mdoc *mdoc)
 {
-	const struct mdoc_meta *meta;
+	const struct roff_meta *meta;
 	struct roff_node *n;
 
 	meta = mdoc_meta(mdoc);
Index: man_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_html.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -Lman_html.c -Lman_html.c -u -p -r1.114 -r1.115
--- man_html.c
+++ man_html.c
@@ -37,7 +37,7 @@
 
 #define	INDENT		  5
 
-#define	MAN_ARGS	  const struct man_meta *man, \
+#define	MAN_ARGS	  const struct roff_meta *man, \
 			  const struct roff_node *n, \
 			  struct mhtml *mh, \
 			  struct html *h
@@ -348,8 +348,8 @@ man_root_post(MAN_ARGS)
 	PAIR_CLASS_INIT(&tag, "foot-os");
 	print_otag(h, TAG_TD, 1, &tag);
 
-	if (man->source)
-		print_text(h, man->source);
+	if (man->os)
+		print_text(h, man->os);
 	print_tagq(h, t);
 }
 
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -Lman_term.c -Lman_term.c -u -p -r1.172 -r1.173
--- man_term.c
+++ man_term.c
@@ -49,7 +49,7 @@ struct	mtermp {
 #define	DECL_ARGS	  struct termp *p, \
 			  struct mtermp *mt, \
 			  struct roff_node *n, \
-			  const struct man_meta *meta
+			  const struct roff_meta *meta
 
 struct	termact {
 	int		(*pre)(DECL_ARGS);
@@ -60,8 +60,10 @@ struct	termact {
 
 static	void		  print_man_nodelist(DECL_ARGS);
 static	void		  print_man_node(DECL_ARGS);
-static	void		  print_man_head(struct termp *, const void *);
-static	void		  print_man_foot(struct termp *, const void *);
+static	void		  print_man_head(struct termp *,
+				const struct roff_meta *);
+static	void		  print_man_foot(struct termp *,
+				const struct roff_meta *);
 static	void		  print_bvspace(struct termp *,
 				const struct roff_node *, int);
 
@@ -139,7 +141,7 @@ void
 terminal_man(void *arg, const struct man *man)
 {
 	struct termp		*p;
-	const struct man_meta	*meta;
+	const struct roff_meta	*meta;
 	struct roff_node	*n;
 	struct mtermp		 mt;
 
@@ -1012,13 +1014,11 @@ print_man_nodelist(DECL_ARGS)
 }
 
 static void
-print_man_foot(struct termp *p, const void *arg)
+print_man_foot(struct termp *p, const struct roff_meta *meta)
 {
-	const struct man_meta	*meta;
 	char			*title;
 	size_t			 datelen, titlen;
 
-	meta = (const struct man_meta *)arg;
 	assert(meta->title);
 	assert(meta->msec);
 	assert(meta->date);
@@ -1030,8 +1030,8 @@ print_man_foot(struct termp *p, const vo
 
 	/*
 	 * Temporary, undocumented option to imitate mdoc(7) output.
-	 * In the bottom right corner, use the source instead of
-	 * the title.
+	 * In the bottom right corner, use the operating system
+	 * instead of the title.
 	 */
 
 	if ( ! p->mdocstyle) {
@@ -1041,14 +1041,14 @@ print_man_foot(struct termp *p, const vo
 		}
 		mandoc_asprintf(&title, "%s(%s)",
 		    meta->title, meta->msec);
-	} else if (meta->source) {
-		title = mandoc_strdup(meta->source);
+	} else if (meta->os) {
+		title = mandoc_strdup(meta->os);
 	} else {
 		title = mandoc_strdup("");
 	}
 	datelen = term_strlen(p, meta->date);
 
-	/* Bottom left corner: manual source. */
+	/* Bottom left corner: operating system. */
 
 	p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
 	p->trailspace = 1;
@@ -1056,8 +1056,8 @@ print_man_foot(struct termp *p, const vo
 	p->rmargin = p->maxrmargin > datelen ?
 	    (p->maxrmargin + term_len(p, 1) - datelen) / 2 : 0;
 
-	if (meta->source)
-		term_word(p, meta->source);
+	if (meta->os)
+		term_word(p, meta->os);
 	term_flushln(p);
 
 	/* At the bottom in the middle: manual date. */
@@ -1084,14 +1084,12 @@ print_man_foot(struct termp *p, const vo
 }
 
 static void
-print_man_head(struct termp *p, const void *arg)
+print_man_head(struct termp *p, const struct roff_meta *meta)
 {
-	const struct man_meta	*meta;
 	const char		*volume;
 	char			*title;
 	size_t			 vollen, titlen;
 
-	meta = (const struct man_meta *)arg;
 	assert(meta->title);
 	assert(meta->msec);
 
Index: man.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -Lman.h -Lman.h -u -p -r1.71 -r1.72
--- man.h
+++ man.h
@@ -56,15 +56,6 @@
 #define	MAN_ll  37
 #define	MAN_MAX 38
 
-struct	man_meta {
-	char		*msec; /* `TH' section (1, 3p, etc.) */
-	char		*date; /* `TH' normalised date */
-	char		*vol; /* `TH' volume */
-	char		*title; /* `TH' title (e.g., FOO) */
-	char		*source; /* `TH' source (e.g., GNU) */
-	int		 hasbody; /* document is not empty */
-};
-
 /* Names of macros. */
 extern	const char *const *man_macronames;
 
@@ -73,7 +64,7 @@ __BEGIN_DECLS
 struct	man;
 
 const struct roff_node *man_node(const struct man *);
-const struct man_meta *man_meta(const struct man *);
+const struct roff_meta *man_meta(const struct man *);
 const struct mparse   *man_mparse(const struct man *);
 void man_deroff(char **, const struct roff_node *);
 
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_validate.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lman_validate.c -Lman_validate.c -u -p -r1.115 -r1.116
--- man_validate.c
+++ man_validate.c
@@ -305,16 +305,16 @@ post_TH(CHKARGS)
 
 	free(man->meta.title);
 	free(man->meta.vol);
-	free(man->meta.source);
+	free(man->meta.os);
 	free(man->meta.msec);
 	free(man->meta.date);
 
 	man->meta.title = man->meta.vol = man->meta.date =
-	    man->meta.msec = man->meta.source = NULL;
+	    man->meta.msec = man->meta.os = NULL;
 
 	nb = n;
 
-	/* ->TITLE<- MSEC DATE SOURCE VOL */
+	/* ->TITLE<- MSEC DATE OS VOL */
 
 	n = n->child;
 	if (n && n->string) {
@@ -336,7 +336,7 @@ post_TH(CHKARGS)
 		    nb->line, nb->pos, "TH");
 	}
 
-	/* TITLE ->MSEC<- DATE SOURCE VOL */
+	/* TITLE ->MSEC<- DATE OS VOL */
 
 	if (n)
 		n = n->next;
@@ -348,7 +348,7 @@ post_TH(CHKARGS)
 		    nb->line, nb->pos, "TH %s", man->meta.title);
 	}
 
-	/* TITLE MSEC ->DATE<- SOURCE VOL */
+	/* TITLE MSEC ->DATE<- OS VOL */
 
 	if (n)
 		n = n->next;
@@ -364,14 +364,14 @@ post_TH(CHKARGS)
 		    n ? n->pos : nb->pos, "TH");
 	}
 
-	/* TITLE MSEC DATE ->SOURCE<- VOL */
+	/* TITLE MSEC DATE ->OS<- VOL */
 
 	if (n && (n = n->next))
-		man->meta.source = mandoc_strdup(n->string);
+		man->meta.os = mandoc_strdup(n->string);
 	else if (man->defos != NULL)
-		man->meta.source = mandoc_strdup(man->defos);
+		man->meta.os = mandoc_strdup(man->defos);
 
-	/* TITLE MSEC DATE SOURCE ->VOL<- */
+	/* TITLE MSEC DATE OS ->VOL<- */
 	/* If missing, use the default VOL name for MSEC. */
 
 	if (n && (n = n->next))
@@ -446,8 +446,8 @@ post_UC(CHKARGS)
 			p = bsd_versions[0];
 	}
 
-	free(man->meta.source);
-	man->meta.source = mandoc_strdup(p);
+	free(man->meta.os);
+	man->meta.os = mandoc_strdup(p);
 }
 
 static void
@@ -485,8 +485,8 @@ post_AT(CHKARGS)
 			p = unix_versions[0];
 	}
 
-	free(man->meta.source);
-	man->meta.source = mandoc_strdup(p);
+	free(man->meta.os);
+	man->meta.os = mandoc_strdup(p);
 }
 
 static void
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.189 -r1.190
--- mandocdb.c
+++ mandocdb.c
@@ -130,7 +130,7 @@ enum	stmt {
 	STMT__MAX
 };
 
-typedef	int (*mdoc_fp)(struct mpage *, const struct mdoc_meta *,
+typedef	int (*mdoc_fp)(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
 
 struct	mdoc_handler {
@@ -156,28 +156,28 @@ static	void	 mpages_free(void);
 static	void	 mpages_merge(struct mparse *);
 static	void	 names_check(void);
 static	void	 parse_cat(struct mpage *, int);
-static	void	 parse_man(struct mpage *, const struct man_meta *,
+static	void	 parse_man(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	void	 parse_mdoc(struct mpage *, const struct mdoc_meta *,
+static	void	 parse_mdoc(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_body(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_head(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_head(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Fd(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
 static	void	 parse_mdoc_fname(struct mpage *, const struct roff_node *);
-static	int	 parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Fn(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Fo(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Fo(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Nd(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Nd(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Nm(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Nm(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Sh(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Sh(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_Xr(struct mpage *, const struct mdoc_meta *,
+static	int	 parse_mdoc_Xr(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
 static	void	 putkey(const struct mpage *, char *, uint64_t);
 static	void	 putkeys(const struct mpage *, char *, size_t, uint64_t);
@@ -1443,7 +1443,7 @@ putmdockey(const struct mpage *mpage,
 }
 
 static void
-parse_man(struct mpage *mpage, const struct man_meta *meta,
+parse_man(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 	const struct roff_node *head, *body;
@@ -1569,7 +1569,7 @@ parse_man(struct mpage *mpage, const str
 }
 
 static void
-parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1602,7 +1602,7 @@ parse_mdoc(struct mpage *mpage, const st
 }
 
 static int
-parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fd(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 	char		*start, *end;
@@ -1667,7 +1667,7 @@ parse_mdoc_fname(struct mpage *mpage, co
 }
 
 static int
-parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fn(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1684,7 +1684,7 @@ parse_mdoc_Fn(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Fo(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1698,7 +1698,7 @@ parse_mdoc_Fo(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 	char	*cp;
@@ -1718,7 +1718,7 @@ parse_mdoc_Xr(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Nd(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1728,7 +1728,7 @@ parse_mdoc_Nd(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Nm(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1750,7 +1750,7 @@ parse_mdoc_Nm(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_Sh(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1758,7 +1758,7 @@ parse_mdoc_Sh(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_head(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
@@ -1766,7 +1766,7 @@ parse_mdoc_head(struct mpage *mpage, con
 }
 
 static int
-parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
+parse_mdoc_body(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
 
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.228 -r1.229
--- mdoc_html.c
+++ mdoc_html.c
@@ -35,7 +35,7 @@
 
 #define	INDENT		 5
 
-#define	MDOC_ARGS	  const struct mdoc_meta *meta, \
+#define	MDOC_ARGS	  const struct roff_meta *meta, \
 			  struct roff_node *n, \
 			  struct html *h
 
Index: mdoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.h,v
retrieving revision 1.138
retrieving revision 1.139
diff -Lmdoc.h -Lmdoc.h -u -p -r1.138 -r1.139
--- mdoc.h
+++ mdoc.h
@@ -172,16 +172,6 @@ enum	mdocargt {
 	MDOC_ARG_MAX
 };
 
-struct	mdoc_meta {
-	char		 *msec; /* `Dt' section (1, 3p, etc.) */
-	char		 *vol; /* `Dt' volume (implied) */
-	char		 *arch; /* `Dt' arch (i386, etc.) */
-	char		 *date; /* `Dd' normalised date */
-	char		 *title; /* `Dt' title (FOO, etc.) */
-	char		 *os; /* `Os' system (OpenBSD, etc.) */
-	char		 *name; /* leading `Nm' name */
-};
-
 /*
  * An argument to a macro (multiple values = `-column xxx yyy').
  */
@@ -295,7 +285,7 @@ __BEGIN_DECLS
 struct	mdoc;
 
 const struct roff_node *mdoc_node(const struct mdoc *);
-const struct mdoc_meta *mdoc_meta(const struct mdoc *);
+const struct roff_meta *mdoc_meta(const struct mdoc *);
 void mdoc_deroff(char **, const struct roff_node *);
 
 __END_DECLS
Index: libman.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libman.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -Llibman.h -Llibman.h -u -p -r1.69 -r1.70
--- libman.h
+++ libman.h
@@ -33,7 +33,7 @@ struct	man {
 	enum man_next	 next; /* where to put the next node */
 	struct roff_node *last; /* the last parsed node */
 	struct roff_node *first; /* the first parsed node */
-	struct man_meta	 meta; /* document meta-data */
+	struct roff_meta meta; /* document meta-data */
 	struct roff	*roff;
 };
 
Index: man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -Lman.c -Lman.c -u -p -r1.151 -r1.152
--- man.c
+++ man.c
@@ -69,7 +69,7 @@ man_node(const struct man *man)
 	return(man->first);
 }
 
-const struct man_meta *
+const struct roff_meta *
 man_meta(const struct man *man)
 {
 
@@ -136,7 +136,7 @@ man_free1(struct man *man)
 	if (man->first)
 		man_node_delete(man, man->first);
 	free(man->meta.title);
-	free(man->meta.source);
+	free(man->meta.os);
 	free(man->meta.date);
 	free(man->meta.vol);
 	free(man->meta.msec);
@@ -146,7 +146,7 @@ static void
 man_alloc1(struct man *man)
 {
 
-	memset(&man->meta, 0, sizeof(struct man_meta));
+	memset(&man->meta, 0, sizeof(man->meta));
 	man->flags = 0;
 	man->last = mandoc_calloc(1, sizeof(*man->last));
 	man->first = man->last;
--
 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:[~2015-04-02 23:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02 23:48 mdocml: Third step towards parser unification: Replace struct mdoc_meta schwarze

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).