source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* texi2mdoc: Compile on Linux: define _GNU_SOURCE for memmem(3), replace
@ 2015-02-23 17:25 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-02-23 17:25 UTC (permalink / raw)
  To: source

Log Message:
-----------
Compile on Linux: define _GNU_SOURCE for memmem(3), replace strlcat(3) with
a manual copy (ok: it's just a single usage and not worth a compat), and
fix dirname(3) usage.
While here, fix a GMP manual that was puking on .Pp in an @example.

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

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lmain.c -Lmain.c -u -p -r1.36 -r1.37
--- main.c
+++ main.c
@@ -14,6 +14,9 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* memmem */
+#endif
 #include <sys/mman.h>
 #include <sys/stat.h>
 
@@ -1355,7 +1358,10 @@ dosp(struct texi *p, enum texicmd cmd, 
 	const char *buf, size_t sz, size_t *pos)
 {
 
-	texivspace(p);
+	if (p->literal)
+		texiputchar(p, '\n');
+	else
+		texivspace(p);
 	/* FIXME: ignore and parseeoln. */
 	advanceeoln(p, buf, sz, pos, 1);
 }
@@ -1631,7 +1637,7 @@ main(int argc, char *argv[])
 {
 	struct texi	 texi;
 	int		 c;
-	char		*path, *dir;
+	char		*dirpath, *dir, *ccp;
 	const char	*progname, *Idir, *cp;
 
 	progname = strrchr(argv[0], '/');
@@ -1656,13 +1662,11 @@ main(int argc, char *argv[])
 	if (0 == (argc -= optind))
 		goto usage;
 
-	if (NULL == (path = strdup(argv[0])))
+	if (NULL == (dirpath = strdup(argv[0])))
 		texiabort(&texi, NULL);
-	else if (NULL == (dir = dirname(path)))
+	if (NULL == (dir = dirname(dirpath)))
 		texiabort(&texi, NULL);
 
-	free(path);
-
 	if (NULL != (cp = strrchr(argv[0], '/'))) 
 		texi.title = strdup(cp + 1);
 	else
@@ -1670,11 +1674,12 @@ main(int argc, char *argv[])
 
 	if (NULL == texi.title)
 		texiabort(&texi, NULL);
-	else if (NULL != (path = strchr(texi.title, '.')))
-		*path = '\0';
+	else if (NULL != (ccp = strchr(texi.title, '.')))
+		*ccp = '\0';
 
 	texi.ign = 1;
 	texi.dirs = parsedirs(&texi, dir, Idir, &texi.dirsz);
+	free(dirpath);
 	parsefile(&texi, argv[0], 1);
 	/* We shouldn't get here. */
 	texiexit(&texi);
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lutil.c -Lutil.c -u -p -r1.10 -r1.11
--- util.c
+++ util.c
@@ -421,10 +421,11 @@ static void
 texiexecmacro(struct texi *p, struct teximacro *m,
 	const char *buf, size_t sz, size_t *pos)
 {
-	size_t	  valsz, realsz, aasz, asz, 
-		  ssz, i, j, k, start, end;
-	char	 *val;
-	char	**args;
+	size_t		  valsz, realsz, aasz, asz, 
+			   ssz, i, j, k, start, end;
+	char		 *val;
+	char		**args;
+	const char	 *cp;
 
 	args = argparse(p, buf, sz, pos, &asz, m->argsz);
 	if (asz != m->argsz)
@@ -494,7 +495,10 @@ texiexecmacro(struct texi *p, struct tex
 				texiabort(p, NULL);
 		}
 
-		j = strlcat(val, args[k], valsz + 1);
+		for (cp = args[k]; '\0' != *cp; cp++) 
+			val[j++] = *cp;
+
+		val[j] = '\0';
 		i = end;
 	}
 
@@ -1221,8 +1225,6 @@ argparse(struct texi *p, const char *buf
 		/* Test for zero-length '{  }'. */
 		if (start == end && '}' == buf[*pos] && 0 == *argsz)
 			break;
-		if (start == end)
-			texierr(p, "zero-length argument");
 		/* FIXME: use reallocarray. */
 		args = realloc
 			(args, sizeof(char *) *
--
 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-02-23 17:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 17:25 texi2mdoc: Compile on Linux: define _GNU_SOURCE for memmem(3), replace 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).