discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: discuss@mdocml.bsd.lv
Subject: Re: texi2mdoc
Date: Mon, 23 Feb 2015 18:31:22 +0100	[thread overview]
Message-ID: <54EB63EA.4080702@bsd.lv> (raw)
In-Reply-To: <20150223165627.GA13719@k8>

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

Sviatoslav,

Oh Linux... not only does it not have strlcat(3) (replaced with a simple 
string copy) or memmem(3) (found with _GNU_SOURCE), but the dirname(3) 
is all weird.  Does the enclosed patch (against the website version) fix 
all this for you?

(There are another two nits fixed in this, as my Linux box has GMP 
against which I could test...)

Thanks for testing it out!

As for the 403... Ingo, the httpd.conf defines "/snapshots/" as 
accepting directory listings.  Should texi2mdoc (and, as I'm seeing, 
pod2mdoc and docbook2mdoc) also have their snap directories also accept 
listings?

Best,

Kristaps

[-- Attachment #2: linux.patch --]
[-- Type: text/plain, Size: 3757 bytes --]

? build
? config.texi
? examples
? files.txt
? files2.txt
? gcc-vers.texi
? gdb-cfg.texi
? intdoc.texi
? linux.patch
? out
? texi2mdoc
? texi2mdoc.dSYM
? afl/dict
? afl/out
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -p -r1.36 -r1.37
--- main.c	23 Feb 2015 15:23:44 -0000	1.36
+++ main.c	23 Feb 2015 17:24:51 -0000	1.37
@@ -1,4 +1,4 @@
-/*	$Id: main.c,v 1.36 2015/02/23 15:23:44 kristaps Exp $ */
+/*	$Id: main.c,v 1.37 2015/02/23 17:24:51 kristaps Exp $ */
 /*
  * Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -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 -u -p -r1.10 -r1.11
--- util.c	23 Feb 2015 15:09:09 -0000	1.10
+++ util.c	23 Feb 2015 17:24:51 -0000	1.11
@@ -1,4 +1,4 @@
-/*	$Id: util.c,v 1.10 2015/02/23 15:09:09 kristaps Exp $ */
+/*	$Id: util.c,v 1.11 2015/02/23 17:24:51 kristaps Exp $ */
 /*
  * Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -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 *) *

  reply	other threads:[~2015-02-23 17:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23 15:31 texi2mdoc Kristaps Dzonsons
2015-02-23 16:56 ` texi2mdoc Svyatoslav Mishyn
2015-02-23 17:31   ` Kristaps Dzonsons [this message]
2015-02-23 18:13     ` texi2mdoc Ingo Schwarze
2015-02-23 18:17     ` texi2mdoc Svyatoslav Mishyn
2015-02-25 15:17       ` texi2mdoc Kristaps Dzonsons
2015-02-25 17:23         ` texi2mdoc Svyatoslav Mishyn
2015-02-25 19:50           ` texi2mdoc Kristaps Dzonsons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54EB63EA.4080702@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=discuss@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).