From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 53bccda1; for ; Mon, 23 Feb 2015 12:25:21 -0500 (EST) Date: Mon, 23 Feb 2015 12:25:21 -0500 (EST) Message-Id: <3532311297404557896.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: texi2mdoc: Compile on Linux: define _GNU_SOURCE for memmem(3), replace X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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 #include @@ -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