source@mandoc.bsd.lv
 help / color / Atom feed
* docbook2mdoc: provide a simple function to generate a text node
@ 2019-04-28 15:32 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-28 15:32 UTC (permalink / raw)
  To: source

Log Message:
-----------
provide a simple function to generate a text node

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c
        node.c
        node.h
        parse.c

Revision Data
-------------
Index: node.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -Lnode.c -Lnode.c -u -p -r1.24 -r1.25
--- node.c
+++ node.c
@@ -261,6 +261,17 @@ pnode_alloc(struct pnode *np)
 	return n;
 }
 
+struct pnode *
+pnode_alloc_text(struct pnode *np, const char *text)
+{
+	struct pnode	*n;
+
+	n = pnode_alloc(np);
+	n->node = NODE_TEXT;
+	n->b = xstrdup(text);
+	return n;
+}
+
 /*
  * Recursively free a node (NULL is ok).
  */
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.139 -r1.140
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -898,9 +898,7 @@ pnode_printrefentry(struct format *f, st
 		nc = pnode_alloc(match);
 		nc->node = NODE_TITLE;
 		nc->flags |= NFLAG_SPC;
-		nc = pnode_alloc(nc);
-		nc->node = NODE_TEXT;
-		nc->b = xstrdup("AUTHORS");
+		nc = pnode_alloc_text(nc, "AUTHORS");
 		nc->flags |= NFLAG_SPC;
 		if (later == NULL)
 			TAILQ_INSERT_TAIL(&n->childq, match, child);
Index: node.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/node.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -Lnode.h -Lnode.h -u -p -r1.33 -r1.34
--- node.h
+++ node.h
@@ -261,6 +261,7 @@ const char	*pnode_name(enum nodeid);
 enum nodeclass	 pnode_class(enum nodeid);
 
 struct pnode	*pnode_alloc(struct pnode *);
+struct pnode	*pnode_alloc_text(struct pnode *, const char *);
 void		 pnode_unlink(struct pnode *);
 void		 pnode_unlinksub(struct pnode *);
 enum attrval	 pnode_getattr(struct pnode *, enum attrkey);
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -Lparse.c -Lparse.c -u -p -r1.53 -r1.54
--- parse.c
+++ parse.c
@@ -361,10 +361,8 @@ pnode_closetext(struct parse *p, int che
 
 	/* Move the last word into its own node, for use with .Pf. */
 
-	n = pnode_alloc(p->cur);
-	n->node = NODE_TEXT;
+	n = pnode_alloc_text(p->cur, last_word);
 	n->flags |= NFLAG_SPC;
-	n->b = xstrdup(last_word);
 }
 
 static void
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 15:32 docbook2mdoc: provide a simple function to generate a text node schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git