source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* texi2mdoc: Properly use natural ordering for the navigation section.
@ 2015-03-12 10:45 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-03-12 10:45 UTC (permalink / raw)
  To: source

Log Message:
-----------
Properly use natural ordering for the navigation section.

Modified Files:
--------------
    texi2mdoc:
        extern.h
        main.c
        util.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -Lmain.c -Lmain.c -u -p -r1.67 -r1.68
--- main.c
+++ main.c
@@ -134,6 +134,10 @@ static	const struct texitok __texitoks[T
 	{ dodefindex, "defindex", 8 }, /* TEXICMD_DEFINDEX */
 	{ dodefn, "defmac", 6 }, /* TEXICMD_DEFMAC */
 	{ dodefn, "defmacx", 7 }, /* TEXICMD_DEFMACX */
+	{ dodefn, "defop", 5 }, /* TEXICMD_DEFOP */
+	{ dodefn, "defopx", 6 }, /* TEXICMD_DEFOPX */
+	{ dodefn, "defopt", 6 }, /* TEXICMD_DEFOPT */
+	{ dodefn, "defoptx", 7 }, /* TEXICMD_DEFOPTX */
 	{ dodefn, "deftp", 5 }, /* TEXICMD_DEFTP */
 	{ dodefn, "deftpx", 6 }, /* TEXICMD_DEFTPX */
 	{ dodefn, "deftypefn", 9 }, /* TEXICMD_DEFTYPEFN */
@@ -152,7 +156,7 @@ static	const struct texitok __texitoks[T
 	{ dodefn, "defvarx", 7 }, /* TEXICMD_DEFVARX */
 	{ dodefn, "defvr", 5 }, /* TEXICMD_DEFVR */
 	{ dodefn, "defvrx", 6 }, /* TEXICMD_DEFVRX */
-	{ domenu, "detailmenu", 10 }, /* TEXICMD_DETAILMENU */
+	{ doignblock, "detailmenu", 10 }, /* TEXICMD_DETAILMENU */
 	{ doinline, "dfn", 3 }, /* TEXICMD_DFN */
 	{ dosymbol, "DH", 2 }, /* TEXICMD_DH */
 	{ dosymbol, "dh", 2 }, /* TEXICMD_DHSMALL */
@@ -393,6 +397,8 @@ dodefn(struct texi *p, enum texicmd cmd,
 	switch (cmd) {
 	case (TEXICMD_DEFFN):
 	case (TEXICMD_DEFMAC):
+	case (TEXICMD_DEFOP):
+	case (TEXICMD_DEFOPT):
 	case (TEXICMD_DEFTP):
 	case (TEXICMD_DEFTYPEFN):
 	case (TEXICMD_DEFTYPEFUN):
@@ -429,6 +435,10 @@ dodefn(struct texi *p, enum texicmd cmd,
 	case (TEXICMD_DEFMACX):
 		texiputchars(p, "Macro");
 		break;
+	case (TEXICMD_DEFOPT):
+	case (TEXICMD_DEFOPTX):
+		texiputchars(p, "User Option");
+		break;
 	case (TEXICMD_DEFTYPEVAR):
 	case (TEXICMD_DEFTYPEVARX):
 	case (TEXICMD_DEFVAR):
@@ -471,6 +481,8 @@ dodefn(struct texi *p, enum texicmd cmd,
 		teximacroclose(p);
 		teximacro(p, "Fc");
 		break;
+	case (TEXICMD_DEFOP):
+	case (TEXICMD_DEFOPX):
 	case (TEXICMD_DEFTYPEFUN):
 	case (TEXICMD_DEFTYPEFUNX):
 	case (TEXICMD_DEFTYPEFN):
@@ -500,6 +512,8 @@ dodefn(struct texi *p, enum texicmd cmd,
 			/* Spin. */ ;
 		teximacroclose(p);
 		break;
+	case (TEXICMD_DEFOPT):
+	case (TEXICMD_DEFOPTX):
 	case (TEXICMD_DEFVAR):
 	case (TEXICMD_DEFVARX):
 	case (TEXICMD_DEFVR):
@@ -531,6 +545,8 @@ dodefn(struct texi *p, enum texicmd cmd,
 		switch (peekcmd(p, *pos)) {
 		case (TEXICMD_DEFFNX):
 		case (TEXICMD_DEFMACX):
+		case (TEXICMD_DEFOPX):
+		case (TEXICMD_DEFOPTX):
 		case (TEXICMD_DEFTPX):
 		case (TEXICMD_DEFTYPEFNX):
 		case (TEXICMD_DEFTYPEFUNX):
@@ -662,7 +678,7 @@ doignblock(struct texi *p, enum texicmd 
 		"@%s", texitoks[cmd].tok);
 	assert(ssz < sizeof(start));
 	esz = snprintf(end, sizeof(end), 
-		"@end %s\n", texitoks[cmd].tok);
+		"@end %s", texitoks[cmd].tok);
 	assert(esz < sizeof(end));
 	stack = 1;
 
@@ -846,16 +862,25 @@ docopying(struct texi *p, enum texicmd c
 	}
 
 	term = memmem(&BUF(p)[*pos], BUFSZ(p) - *pos, end, endsz);
-	if (NULL == term) {
-		texiwarn(p, "unterminated \"%s\"", texitoks[cmd].tok);
-		endpos = BUFSZ(p);
-	} else
+	if (NULL == term)
+		texierr(p, "unterminated \"%s\"", texitoks[cmd].tok);
+	else
 		endpos = *pos + (size_t)(term - &BUF(p)[*pos]);
 
-	assert(endpos <= BUFSZ(p));
+	if (endpos == *pos) {
+		advanceeoln(p, pos, 1);
+		return;
+	}
+
+	assert(endpos < BUFSZ(p) && endpos > *pos);
 	assert('\n' == BUF(p)[*pos]);
 	advance(p, pos);
 
+	if (*pos == BUFSZ(p)) {
+		texiwarn(p, "unterminated \"%s\"", texitoks[cmd].tok);
+		return;
+	}
+
 	p->copying = malloc(endpos - *pos + 1);
 	p->copyingsz = endpos - *pos;
 	memcpy(p->copying, &BUF(p)[*pos], p->copyingsz);
@@ -1487,6 +1512,7 @@ doprintindex(struct texi *p, enum texicm
 	size_t	 i, j, start, end, len;
 #if HAVE_INDEX
 	char	*cp;
+	char	 buf[PATH_MAX];
 #endif
 
 	while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
@@ -1535,22 +1561,19 @@ doprintindex(struct texi *p, enum texicm
 			texiputchars(p, "\"idx");
 			texiputchars(p, p->indexs[i].name);
 			cp = p->indexs[i].index[j].term;
-			while ('\n' != *cp) {
-				assert('\0' != *cp);
+			while ('\n' != *cp)
 				texiputchar(p, *cp++);
-			}
 			texiputchars(p, "\" \"");
 			p->literal++;
 		} else {
 			teximacroopen(p, "Xr");
-			texiputchars(p, p->nodes[p->indexs[i].index[j].chapter]);
-			texiputchars(p, " 7 \"idx");
+			snprintf(buf, sizeof(buf), "%s-%zd 7 \"idx",
+				p->chapters, p->indexs[i].index[j].chapter);
+			texiputchars(p, buf);
 			texiputchars(p, p->indexs[i].name);
 			cp = p->indexs[i].index[j].term;
-			while ('\n' != *cp) {
-				assert('\0' != *cp);
+			while ('\n' != *cp)
 				texiputchar(p, *cp++);
-			}
 			texiputchars(p, "\" \"");
 			p->literal++;
 		}
@@ -1574,33 +1597,55 @@ static void
 donode(struct texi *p, enum texicmd cmd, size_t *pos)
 {
 	int	 sv = p->seenvs;
+	char	 fname[PATH_MAX];
+	size_t	 end, start;
 
-	if (NULL != p->chapters) {
-		advanceeoln(p, pos, 1);
-		if (0 == p->chapnum)
-			p->ign--;
+	if (0 == p->nodesz++)
+		p->ign--;
+
+	/* Grab our node name. */
+	while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
+		advance(p, pos);
+	start = *pos;
+	while (*pos < BUFSZ(p)) {
+		if (BUF(p)[*pos] == ',')
+			break;
+		else if (BUF(p)[*pos] == '\n')
+			break;
+		advance(p, pos);
+	}
+	if (*pos == BUFSZ(p)) {
+		texiwarn(p, "unexpected EOF");
+		return;
+	}
+	end = *pos;
+	advanceeoln(p, pos, 1);
+
+	if (NULL != p->chapters)
 		teximdocclose(p, 0);
+
+	/* Cache our node name. */
+	p->nodecur = texicache(p, &BUF(p)[start], end - start);
+
+	if (NULL != p->chapters) {
+		snprintf(fname, sizeof(fname), 
+			"%s-%zd.7", p->chapters, p->nodecur);
+		p->outfile = fopen(fname, "w");
+		if (NULL == p->outfile)
+			texiabort(p, fname);
 		teximdocopen(p, pos);
-	} else {
-#if HAVE_INDEX
+	} else if (p->nodesz > 1) {
+		/* Otherwise, mark our index. */
 		p->seenvs = -1;
+#if HAVE_INDEX
 		teximacroopen(p, "Ix");
 		texiputchars(p, "node");
-		while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
-			advance(p, pos);
-		while (*pos < BUFSZ(p)) {
-			if (BUF(p)[*pos] == ',')
-				break;
-			else if (BUF(p)[*pos] == '\n')
-				break;
-			texiputchar(p, BUF(p)[*pos]);
-			advance(p, pos);
-		}
+		texiputchars(p, p->nodecache[p->nodecur].name);
 		teximacroclose(p);
 #endif
-		advanceeoln(p, pos, 1);
 		p->seenvs = sv;
-	}
+	} else
+		teximdocopen(p, pos);
 }
 
 /*
@@ -1611,7 +1656,11 @@ donode(struct texi *p, enum texicmd cmd,
 static void
 domenu(struct texi *p, enum texicmd cmd, size_t *pos)
 {
-	size_t	 start, end, sv;
+	size_t		 nodename, entryname;
+	size_t		 nodenameend, entrynameend, i;
+	ssize_t	 	 ppos, lastppos;
+	char		 buf[PATH_MAX];
+	enum texicmd	 tcmd;
 
 	advanceeoln(p, pos, 1);
 
@@ -1631,6 +1680,7 @@ domenu(struct texi *p, enum texicmd cmd,
 			break;
 	}
 
+	lastppos = -1;
 	texivspace(p);
 	teximacro(p, "Bl -tag -width Ds -compact");
 	while (*pos < BUFSZ(p)) {
@@ -1646,9 +1696,13 @@ domenu(struct texi *p, enum texicmd cmd,
 		while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
 			advance(p, pos);
 		if ('*' != BUF(p)[*pos]) {
-			if (TEXICMD_END == peeklinecmd(p, *pos))
+			tcmd = peeklinecmd(p, *pos);
+			if (TEXICMD_END == tcmd)
 				break;
-			parseeoln(p, pos);
+			else if (TEXICMD_COMMENT == tcmd) 
+				advanceeoln(p, pos, 1);
+			else
+				parseeoln(p, pos);
 			continue;
 		} 
 
@@ -1656,23 +1710,21 @@ domenu(struct texi *p, enum texicmd cmd,
 		advance(p, pos);
 		while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
 			advance(p, pos);
-		start = sv = *pos;
+		entryname = *pos;
 		while (*pos < BUFSZ(p) && ':' != BUF(p)[*pos])
 			advance(p, pos);
-		end = *pos;
+		entrynameend = *pos;
 		advance(p, pos);
 
+		p->seenvs = 0;
+		teximacroopen(p, "It");
 		if (*pos == BUFSZ(p)) {
 			texiwarn(p, "bad menu syntax");
 			break;
 		} else if (':' != BUF(p)[*pos]) {
 			while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
 				advance(p, pos);
-			teximacroopen(p, "It");
-#ifdef HAVE_INDEX
-			teximacroopen(p, "Lkx");
-			texiputchars(p, "\"node");
-#endif
+			nodename = *pos;
 			while (*pos < BUFSZ(p)) {
 				switch (BUF(p)[*pos]) {
 				case ('\t'):
@@ -1690,38 +1742,53 @@ domenu(struct texi *p, enum texicmd cmd,
 					}
 					/* FALLTHROUGH */
 				default:
-					texiputchar(p, BUF(p)[*pos]);
 					advance(p, pos);
 					continue;
 				}
 				advance(p, pos);
 				break;
 			}
-#ifdef HAVE_INDEX
-			texiputchars(p, "\" \"");
-			for (start = sv; start < end; start++)
-				texiputchar(p, BUF(p)[start]);
-			texiputchar(p, '"');
-#endif
+			nodenameend = *pos;
 		} else {
 			advance(p, pos);
-			p->seenvs = 0;
-			teximacroopen(p, "It");
+			nodename = entryname;
+			nodenameend = entrynameend;
+		}
+		ppos = texicache(p, &BUF(p)[nodename], 
+			nodenameend - nodename);
+		if (-1 != lastppos)
+			p->nodecache[lastppos].next = ppos;
+		p->nodecache[ppos].prev = lastppos;
+		p->nodecache[ppos].up = p->nodecur;
+		lastppos = ppos;
 #ifdef HAVE_INDEX
+		if (NULL == p->chapters) {
 			teximacroopen(p, "Lkx");
 			texiputchars(p, "\"node");
-			for (start = sv; start < end; start++)
-				texiputchar(p, BUF(p)[start]);
+			for (i = nodename; i < nodenameend; i++)
+				texiputchar(p, BUF(p)[i]);
 			texiputchars(p, "\" \"");
-#endif
-			for (start = sv; start < end; start++)
-				texiputchar(p, BUF(p)[start]);
-#ifdef HAVE_INDEX
-			texiputchar(p, '"');
-#endif
+			for (i = entryname; i < entrynameend; i++)
+				texiputchar(p, BUF(p)[i]);
+			texiputchars(p, "\"");
+			teximacroclose(p);
+		} else {
+			snprintf(buf, sizeof(buf), 
+				"%s-%zd 7 ", p->chapters, ppos);
+			teximacroopen(p, "Xr");
+			texiputchars(p, buf);
+			texiputchars(p, "\"node");
+			for (i = nodename; i < nodenameend; i++)
+				texiputchar(p, BUF(p)[i]);
+			texiputchars(p, "\" \"");
+			for (i = entryname; i < entrynameend; i++)
+				texiputchar(p, BUF(p)[i]);
+			texiputchars(p, "\"");
+			teximacroclose(p);
 		}
-#ifdef HAVE_INDEX
-		teximacroclose(p);
+#else
+		for (i = entryname; i < entrynameend; i++)
+			texiputchar(p, BUF(p)[i]);
 #endif
 		teximacroclose(p);
 	}
@@ -2155,10 +2222,8 @@ doindex(struct texi *p, enum texicmd cmd
 		advance(p, pos);
 
 	start = *pos;
-	while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) {
-		assert('\0' != BUF(p)[*pos]);
+	while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos])
 		advance(p, pos);
-	}
 
 	if (*pos == BUFSZ(p)) {
 		texiwarn(p, "unexpected EOF");
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lextern.h -Lextern.h -u -p -r1.28 -r1.29
--- extern.h
+++ extern.h
@@ -85,6 +85,10 @@ enum	texicmd {
 	TEXICMD_DEFINDEX,
 	TEXICMD_DEFMAC,
 	TEXICMD_DEFMACX,
+	TEXICMD_DEFOP,
+	TEXICMD_DEFOPX,
+	TEXICMD_DEFOPT,
+	TEXICMD_DEFOPTX,
 	TEXICMD_DEFTP,
 	TEXICMD_DEFTPX,
 	TEXICMD_DEFTYPEFN,
@@ -379,7 +383,7 @@ struct	teximacro {
  */
 struct	texiterm {
 	char		*term;
-	size_t		 chapter;
+	ssize_t		 chapter;
 };
 
 /*
@@ -393,13 +397,19 @@ struct	texidex {
 	size_t		  indexsz;
 };
 
+struct	texinode {
+	char		 *name;
+	ssize_t		  up;
+	ssize_t		  prev;
+	ssize_t		  next;
+};
+
 /*
  * The main parse structure.
  * This keeps any necessary information handy.
  */
 struct	texi {
 	const char	 *chapters; /* are we splitting chapters */
-	size_t		  chapnum; /* current chapter node */
 	char		**dirs; /* texi directories */
 	size_t		  dirsz; /* number of texi directories */
 	FILE		 *outfile; /* current output stream */
@@ -421,8 +431,10 @@ struct	texi {
 	size_t		  macrosz; /* entries in macros */
 	char		 *copying; /* the @copying block */
 	size_t		  copyingsz; /* length of @copying */
-	char		**nodes;
-	size_t		  nodesz;
+	struct texinode	 *nodecache; /* index of node names */
+	size_t		  nodecachesz; /* nodes in nodecache */
+	size_t		  nodesz; /* parsing node (sequential) */
+	ssize_t		  nodecur; /* parsing node (cache position) */
 	/*
 	 * The following control what we output to the screen.
 	 * The complexity is required to accomodate for mdoc(7).
@@ -460,6 +472,7 @@ void	parsefile(struct texi *, const char
 int	parselinearg(struct texi *, size_t *);
 void	parseeoln(struct texi *, size_t *);
 void	parseto(struct texi *, size_t *, const char *);
+void	parsesingle(struct texi *, size_t *);
 
 void	texiabort(struct texi *, const char *)
 		__attribute__((noreturn));
@@ -469,6 +482,7 @@ enum texicmd
 	peekcmd(const struct texi *, size_t);
 enum texicmd
 	peeklinecmd(const struct texi *, size_t);
+ssize_t	texicache(struct texi *, const char *, size_t);
 void	texierr(struct texi *, const char *, ...)
 		__attribute__((format(printf, 2, 3)))
 		__attribute__((noreturn));
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -Lutil.c -Lutil.c -u -p -r1.31 -r1.32
--- util.c
+++ util.c
@@ -155,7 +155,7 @@ texindex(struct texi *p, const char *tok
 		texiabort(p, NULL);
 
 	/* Add term to term array. */
-	p->indexs[i].index[isz].chapter = p->nodesz - 1;
+	p->indexs[i].index[isz].chapter = p->nodecur;
 	p->indexs[i].index[isz].term = malloc(sz + 1);
 	if (NULL == p->indexs[i].index[isz].term)
 		texiabort(p, NULL);
@@ -169,10 +169,8 @@ texindex(struct texi *p, const char *tok
 	texiputchars(p, "idx");
 	texiputchars(p, p->indexs[i].name);
 	cp = p->indexs[i].index[isz].term;
-	while ('\n' != *cp) {
-		assert('\0' != *cp);
+	while ('\n' != *cp)
 		texiputchar(p, *cp++);
-	}
 	teximacroclose(p);
 #endif
 	p->indexs[i].indexsz++;
@@ -246,7 +244,7 @@ texiexit(struct texi *p)
 	for (i = 0; i < p->valsz; i++) 
 		texivaluefree(&p->vals[i]);
 
-	free(p->nodes);
+	free(p->nodecache);
 	free(p->macros);
 	free(p->vals);
 	free(p->indexs);
@@ -1130,7 +1128,7 @@ peekcmd(const struct texi *p, size_t pos
  * Parse a single word or command.
  * This will return immediately at the EOF.
  */
-static void
+void
 parsesingle(struct texi *p, size_t *pos)
 {
 	size_t		  end, sv;
@@ -1647,15 +1645,16 @@ teximdocclose(struct texi *p, int last)
 {
 	char	 buf[PATH_MAX];
 
-	if (NULL == p->chapters || 0 == p->chapnum)
+	if (NULL == p->chapters || 1 == p->nodesz)
 		return;
 
 	teximacro(p, "Sh INFO NAVIGATION");
 
 	/* Print a reference to the "top" node. */
-	if (p->chapnum > 1) {
+	if (-1 != p->nodecache[p->nodecur].up) {
 		texiputchars(p, "Top node,");
-		snprintf(buf, sizeof(buf), "%s-1 7", p->chapters);
+		snprintf(buf, sizeof(buf), "%s-%zd 7", 
+			p->chapters, p->nodecache[p->nodecur].up);
 		p->seenvs = 0;
 		teximacroopen(p, "Xr ");
 		texiputchars(p, buf);
@@ -1663,11 +1662,10 @@ teximdocclose(struct texi *p, int last)
 		teximacroclose(p);
 	}
 
-	/* Print a reference to the previous node. */
-	if (p->chapnum > 2) {
+	if (-1 != p->nodecache[p->nodecur].prev) {
 		texiputchars(p, "previous node,");
-		snprintf(buf, sizeof(buf),
-			"%s-%zu 7", p->chapters, p->chapnum - 1);
+		snprintf(buf, sizeof(buf), "%s-%zd 7", 
+			p->chapters, p->nodecache[p->nodecur].prev);
 		p->seenvs = 0;
 		teximacroopen(p, "Xr ");
 		texiputchars(p, buf);
@@ -1676,14 +1674,10 @@ teximdocclose(struct texi *p, int last)
 		teximacroclose(p);
 	} 
 
-	/* Print a reference to the next node. */
-	if ( ! last) {
-		if (1 == p->chapnum)
-			texiputchars(p, "Next node,");
-		else
-			texiputchars(p, "next node,");
-		snprintf(buf, sizeof(buf),
-			"%s-%zu 7", p->chapters, p->chapnum + 1);
+	if (-1 != p->nodecache[p->nodecur].next) {
+		texiputchars(p, "next node,");
+		snprintf(buf, sizeof(buf), "%s-%zd 7",
+			p->chapters, p->nodecache[p->nodecur].next);
 		p->seenvs = 0;
 		teximacroopen(p, "Xr ");
 		texiputchars(p, buf);
@@ -1691,12 +1685,48 @@ teximdocclose(struct texi *p, int last)
 	}
 
 	fclose(p->outfile);
+	p->outfile = NULL;
+}
+
+ssize_t
+texicache(struct texi *p, const char *buf, size_t sz)
+{
+	size_t i;
+
+	for (i = 0; i < p->nodecachesz; i++) {
+		if (sz != strlen(p->nodecache[i].name))
+			continue;
+		if (strncmp(buf, p->nodecache[i].name, sz))
+			continue;
+		break;
+	}
+	if (i < p->nodecachesz)
+		return(i);
+	if (NULL == buf)
+		return(-1);
+	p->nodecache = realloc
+		(p->nodecache, 
+		 (p->nodecachesz + 1) * sizeof(struct texinode));
+	if (NULL == p->nodecache)
+		texiabort(p, NULL);
+	p->nodecache[p->nodecachesz].name = malloc(sz + 1);
+	if (NULL == p->nodecache[p->nodecachesz].name)
+		texiabort(p, NULL);
+	memcpy(p->nodecache[p->nodecachesz].name, buf, sz);
+	p->nodecache[p->nodecachesz].name[sz] = '\0';
+	p->nodecache[p->nodecachesz].up =
+		p->nodecache[p->nodecachesz].next =
+		p->nodecache[p->nodecachesz].prev = -1;
+	p->nodecachesz++;
+	return(p->nodecachesz - 1);
 }
 
 /*
- * Open a mdoc(7) context.
- * If we're printing chapters, then open the outfile here, too.
- * Otherwise just print the mdoc(7) prologue.
+ * Here we print our standard mdoc(7) prologue.
+ * We use the title set with @settitle for the `Nd' description
+ * and the source document filename (the first one as invoked on
+ * the command line) for the title.
+ * The date is set to the current date.
  */
 void
 teximdocopen(struct texi *p, size_t *pos)
@@ -1704,34 +1734,7 @@ teximdocopen(struct texi *p, size_t *pos
 	const char	*cp;
 	time_t		 t;
 	char		 date[32];
-	char	 	 fname[PATH_MAX];
 
-	if (NULL != p->chapters) {
-		p->chapnum++;
-		snprintf(fname, sizeof(fname), "%s-%zu", 
-			p->chapters, p->chapnum);
-		p->nodes = realloc(p->nodes,
-			(p->nodesz + 1) * sizeof(char *));
-		if (NULL == p->nodes)
-			texiabort(p, NULL);
-		p->nodes[p->nodesz] = strdup(fname);
-		if (NULL == p->nodes[p->nodesz])
-			texiabort(p, NULL);
-		p->nodesz++;
-		snprintf(fname, sizeof(fname), "%s-%zu.7", 
-			p->chapters, p->chapnum);
-		p->outfile = fopen(fname, "w");
-		if (NULL == p->outfile)
-			texiabort(p, fname);
-	}
-
-	/*
-	 * Here we print our standard mdoc(7) prologue.
-	 * We use the title set with @settitle for the `Nd' description
-	 * and the source document filename (the first one as invoked on
-	 * the command line) for the title.
-	 * The date is set to the current date.
-	 */
 	t = time(NULL);
 	strftime(date, sizeof(date), "%F", localtime(&t));
 
--
 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-03-12 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 10:45 texi2mdoc: Properly use natural ordering for the navigation section 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).