source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* texi2mdoc: Allow @value in the settitle block as found in GMP.
@ 2015-03-01 13:40 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-03-01 13:40 UTC (permalink / raw)
  To: source

Log Message:
-----------
Allow @value in the settitle block as found in GMP.

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

Revision Data
-------------
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lextern.h -Lextern.h -u -p -r1.21 -r1.22
--- extern.h
+++ extern.h
@@ -444,7 +444,7 @@ void	texifilepop(struct texi *);
 void	teximacro(struct texi *, const char *);
 void	teximacroclose(struct texi *);
 void	teximacroopen(struct texi *, const char *);
-void	teximdocopen(struct texi *);
+void	teximdocopen(struct texi *, size_t *);
 void	teximdocclose(struct texi *, int);
 void 	texipunctuate(struct texi *, size_t *);
 void	texiputbuf(struct texi *p, size_t, size_t);
@@ -453,7 +453,7 @@ void	texiputchars(struct texi *, const c
 void	texivspace(struct texi *);
 void	texiwarn(const struct texi *, const char *, ...)
 		__attribute__((format(printf, 2, 3)));
-void	texisplice(struct texi *, const char *, size_t, size_t *);
+void	texisplice(struct texi *, const char *, size_t, size_t);
 
 void	valueadd(struct texi *, char *, char *);
 const char *
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -Lmain.c -Lmain.c -u -p -r1.55 -r1.56
--- main.c
+++ main.c
@@ -990,6 +990,8 @@ dotitle(struct texi *p, enum texicmd cmd
 	start = end = *pos;
 	while (end < BUFSZ(p) && '\n' != BUF(p)[end])
 		end++;
+	if (end < BUFSZ(p))
+		end++;
 	advanceeoln(p, pos, 1);
 	free(p->subtitle);
 	p->subtitle = malloc(end - start + 1);
@@ -1410,7 +1412,7 @@ dovalue(struct texi *p, enum texicmd cmd
 			texiputchar(p, ' ');
 		p->seenws = 0;
 		if (NULL != (cp = valueblookup(p, pos)))
-			texisplice(p, cp, strlen(cp), pos);
+			texisplice(p, cp, strlen(cp), *pos);
 		else
 			texiputchars(p, "{No value}");
 	} else if (TEXICMD_IFCLEAR == cmd) {
@@ -1577,7 +1579,7 @@ dosection(struct texi *p, enum texicmd c
 
 	if (0 == sec && NULL != p->chapters) {
 		teximdocclose(p, 0);
-		teximdocopen(p);
+		teximdocopen(p, pos);
 	}
 
 	teximacroopen(p, sects[sec]);
@@ -1594,7 +1596,7 @@ dotop(struct texi *p, enum texicmd cmd, 
 		texierr(p, "@top command while ignoring");
 
 	if (NULL == p->chapters)
-		teximdocopen(p);
+		teximdocopen(p, pos);
 	dosection(p, cmd, pos);
 }
 
@@ -1752,7 +1754,8 @@ doend(struct texi *p, enum texicmd cmd, 
 	while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos])
 		advance(p, pos);
 
-	texiwarn(p, "unexpected \"end\": %.*s", (int)(*pos - start), &BUF(p)[start]);
+	texiwarn(p, "unexpected \"end\": %.*s", 
+		(int)(*pos - start), &BUF(p)[start]);
 	advanceeoln(p, pos, 1);
 }
 
@@ -1899,7 +1902,7 @@ main(int argc, char *argv[])
 	}
 
 	texiexit(&texi);
-	return(EXIT_FAILURE);
+	exit(EXIT_SUCCESS);
 usage:
 	fprintf(stderr, "usage: %s [-Cdir] [-Idirs] [file]\n", progname);
 	return(EXIT_FAILURE);
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lutil.c -Lutil.c -u -p -r1.20 -r1.21
--- util.c
+++ util.c
@@ -472,7 +472,7 @@ texiexecmacro(struct texi *p, struct tex
 	aasz = asz < m->argsz ? asz : m->argsz;
 
 	if (0 == aasz) {
-		texisplice(p, m->value, valsz, pos);
+		texisplice(p, m->value, valsz, *pos);
 		return;
 	}
 
@@ -535,7 +535,7 @@ texiexecmacro(struct texi *p, struct tex
 		i = end;
 	}
 
-	texisplice(p, val, strlen(val), pos);
+	texisplice(p, val, strlen(val), *pos);
 
 	for (i = 0; i < asz; i++)
 		free(args[i]);
@@ -927,7 +927,7 @@ parseeof(struct texi *p)
 }
 
 void
-texisplice(struct texi *p, const char *buf, size_t sz, size_t *pos)
+texisplice(struct texi *p, const char *buf, size_t sz, size_t pos)
 {
 	char		*cp;
 	struct texifile	*f;
@@ -944,8 +944,8 @@ texisplice(struct texi *p, const char *b
 	}
 
 	f->insplice += sz;
-	memmove(f->map + *pos + sz, f->map + *pos, f->mapsz - *pos);
-	memcpy(f->map + *pos, buf, sz);
+	memmove(f->map + pos + sz, f->map + pos, f->mapsz - pos);
+	memcpy(f->map + pos, buf, sz);
 	f->mapsz += sz;
 }
 
@@ -1405,7 +1405,7 @@ teximdocclose(struct texi *p, int last)
  * Otherwise just print the mdoc(7) prologue.
  */
 void
-teximdocopen(struct texi *p)
+teximdocopen(struct texi *p, size_t *pos)
 {
 	const char	*cp;
 	time_t		 t;
@@ -1445,10 +1445,14 @@ teximdocopen(struct texi *p)
 		texiputchar(p, *cp);
 	teximacroclose(p);
 	teximacroopen(p, "Nd");
-	if (NULL != p->subtitle)
-		for (cp = p->subtitle; '\0' != *cp; cp++)
-			texiputchar(p, *cp);
-	else
+	/*
+	 * The subtitle `Nd' can consist of arbitrary macros, so paste
+	 * it and parse to the end of the line.
+	 */
+	if (NULL != p->subtitle) {
+		texisplice(p, p->subtitle, strlen(p->subtitle), *pos);
+		parseeoln(p, pos);
+	} else
 		texiputchars(p, "Unknown description");
 	teximacroclose(p);
 	p->seenvs = 1;
--
 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-01 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 13:40 texi2mdoc: Allow @value in the settitle block as found in GMP 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).