source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: texi2mdoc: Compile on Linux: define _GNU_SOURCE for memmem(3), replace
Date: Mon, 23 Feb 2015 12:25:21 -0500 (EST)	[thread overview]
Message-ID: <3532311297404557896.enqueue@fantadrom.bsd.lv> (raw)

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

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3532311297404557896.enqueue@fantadrom.bsd.lv \
    --to=kristaps@mdocml.bsd.lv \
    --cc=source@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).