<pre style='margin:0'>
Rainer Müller (raimue) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/3440d0b7c8d20a84cd64dac84e38128b10947be2">https://github.com/macports/macports-base/commit/3440d0b7c8d20a84cd64dac84e38128b10947be2</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3440d0b7c8d20a84cd64dac84e38128b10947be2
</span>Author: Rainer Müller <raimue@macports.org>
AuthorDate: Mon Apr 2 13:20:39 2018 +0200
<span style='display:block; white-space:pre;color:#404040;'> pextlib: Add getline for legacy systems
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Include an implementation of getline for old systems that do not provide
</span><span style='display:block; white-space:pre;color:#404040;'> it in their libc. On macOS, getline should be available as of 10.7 Lion.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This implementation is based on NetBSD's nbcompat library:
</span><span style='display:block; white-space:pre;color:#404040;'> http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/pkgtools/libnbcompat/
</span>---
configure | 2 +-
configure.ac | 2 +-
src/config.h.in | 9 +++--
src/pextlib1.0/Makefile.in | 3 +-
src/pextlib1.0/fgetln.c | 78 -------------------------------------------
src/pextlib1.0/getdelim.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
src/pextlib1.0/getdelim.h | 10 ++++++
src/pextlib1.0/getline.c | 49 +++++++++++++++++++++++++++
src/pextlib1.0/getline.h | 10 ++++++
src/pextlib1.0/system.c | 5 ++-
10 files changed, 164 insertions(+), 87 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/configure b/configure
</span><span style='display:block; white-space:pre;color:#808080;'>index 6c2f847..de6c09c 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/configure
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/configure
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -7127,7 +7127,7 @@ done
</span>
# Checks for library functions.
for ac_func in OSAtomicCompareAndSwap32 OSAtomicCompareAndSwap64 \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- OSAtomicCompareAndSwapPtr __getdirentries64 clearenv copyfile fgetln \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ OSAtomicCompareAndSwapPtr __getdirentries64 clearenv copyfile getline getdelim \
</span> flock fls kqueue posix_spawn setmode strlcat \
strlcpy sysctlbyname
do :
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/configure.ac b/configure.ac
</span><span style='display:block; white-space:pre;color:#808080;'>index eff4b08..c9e3a8b 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/configure.ac
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/configure.ac
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -236,7 +236,7 @@ AC_CHECK_HEADERS([crt_externs.h err.h fcntl.h libkern/OSAtomic.h libproc.h limit
</span>
# Checks for library functions.
AC_CHECK_FUNCS([OSAtomicCompareAndSwap32 OSAtomicCompareAndSwap64 \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- OSAtomicCompareAndSwapPtr __getdirentries64 clearenv copyfile fgetln \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ OSAtomicCompareAndSwapPtr __getdirentries64 clearenv copyfile getline getdelim \
</span> flock fls kqueue posix_spawn setmode strlcat \
strlcpy sysctlbyname])
AC_SUBST([ac_cv_func_strlcat])
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/config.h.in b/src/config.h.in
</span><span style='display:block; white-space:pre;color:#808080;'>index 6836714..1f99675 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/config.h.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/config.h.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -50,9 +50,6 @@
</span> /* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Define to 1 if you have the `fgetln' function. */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef HAVE_FGETLN
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> /* Define to 1 if you have the `flock' function. */
#undef HAVE_FLOCK
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -72,6 +69,12 @@
</span> CoreFoundation framework */
#undef HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Define to 1 if you have the `getdelim' function. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef HAVE_GETDELIM
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Define to 1 if you have the `getline' function. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef HAVE_GETLINE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/Makefile.in b/src/pextlib1.0/Makefile.in
</span><span style='display:block; white-space:pre;color:#808080;'>index 5124f9e..bee9482 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -8,7 +8,8 @@ OBJS= \
</span> adv-flock.o \
base32cmd.o \
curl.o \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- fgetln.o \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ getdelim.o \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ getline.o \
</span> filemap.o \
fs-traverse.o \
md5cmd.o \
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/fgetln.c b/src/pextlib1.0/fgetln.c
</span>deleted file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index c0d8862..0000000
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/fgetln.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,78 +0,0 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* $NetBSD: fgetln.c,v 1.3 2002/01/31 19:23:14 tv Exp $ */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Copyright 1999 Luke Mewburn <lukem@netbsd.org>.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * All rights reserved.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Redistribution and use in source and binary forms, with or without
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * modification, are permitted provided that the following conditions
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * are met:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * 1. Redistributions of source code must retain the above copyright
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * notice, this list of conditions and the following disclaimer.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * 2. Redistributions in binary form must reproduce the above copyright
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * notice, this list of conditions and the following disclaimer in the
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * documentation and/or other materials provided with the distribution.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * 3. The name of the author may not be used to endorse or promote products
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * derived from this software without specific prior written permission.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <config.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern int xxx_so_this_isnt_empty;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if !HAVE_FGETLN
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <string.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define BUFCHUNKS BUFSIZ
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-char *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-fgetln(FILE *fp, size_t *len)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-{
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- static char *buf;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- static size_t bufsize;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- size_t buflen;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- char curbuf[BUFCHUNKS];
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- char *p;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (buf == NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- bufsize = BUFCHUNKS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- buf = (char *)malloc(bufsize);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (buf == NULL)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *buf = '\0';
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- buflen = 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- while ((p = fgets(curbuf, sizeof(curbuf), fp)) != NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- size_t l;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- l = strlen(p);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (bufsize < buflen + l) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- bufsize += BUFCHUNKS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if ((buf = (char *)realloc(buf, bufsize)) == NULL)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- strcpy(buf + buflen, p);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- buflen += l;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (p[l - 1] == '\n')
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- break;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (p == NULL && *buf == '\0')
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return (NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *len = strlen(buf);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return (buf);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/getdelim.c b/src/pextlib1.0/getdelim.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..816a0e7
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/getdelim.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,83 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* $NetBSD: getdelim.c,v 1.2 2015/12/25 20:12:46 joerg Exp $ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* NetBSD-src: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This code is derived from software contributed to The NetBSD Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * by Christos Zoulas.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Redistribution and use in source and binary forms, with or without
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * modification, are permitted provided that the following conditions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * are met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 1. Redistributions of source code must retain the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 2. Redistributions in binary form must reproduce the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer in the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * documentation and/or other materials provided with the distribution.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * POSSIBILITY OF SUCH DAMAGE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETDELIM
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "getdelim.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char *ptr, *eptr;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (*buf == NULL || *bufsiz == 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *bufsiz = BUFSIZ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ((*buf = malloc(*bufsiz)) == NULL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for (ptr = *buf, eptr = *buf + *bufsiz;;) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int c = fgetc(fp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (c == -1) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (feof(fp)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ssize_t diff = (ssize_t)(ptr - *buf);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (diff != 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *ptr = '\0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return diff;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *ptr++ = c;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (c == delimiter) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *ptr = '\0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ptr - *buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (ptr + 2 >= eptr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char *nbuf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ size_t nbufsiz = *bufsiz * 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ssize_t d = ptr - *buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *buf = nbuf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *bufsiz = nbufsiz;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ eptr = nbuf + nbufsiz;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ptr = nbuf + d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/getdelim.h b/src/pextlib1.0/getdelim.h
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..254ecf4
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/getdelim.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,10 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _GETDELIM_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _GETDELIM_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETDELIM
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t getdelim(char **, size_t *, int, FILE *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _GETDELIM_H */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/getline.c b/src/pextlib1.0/getline.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..1253371
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/getline.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,49 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* $NetBSD: getline.c,v 1.2 2015/12/25 20:12:46 joerg Exp $ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* NetBSD-src: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This code is derived from software contributed to The NetBSD Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * by Christos Zoulas.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Redistribution and use in source and binary forms, with or without
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * modification, are permitted provided that the following conditions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * are met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 1. Redistributions of source code must retain the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 2. Redistributions in binary form must reproduce the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer in the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * documentation and/or other materials provided with the distribution.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * POSSIBILITY OF SUCH DAMAGE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETLINE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETDELIM
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "getdelim.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "getline.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+getline(char **buf, size_t *bufsiz, FILE *fp)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return getdelim(buf, bufsiz, '\n', fp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/getline.h b/src/pextlib1.0/getline.h
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..3900e6d
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/getline.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,10 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _GETLINE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _GETLINE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETLINE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ssize_t getline(char **, size_t *, FILE *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _GETLINE_H */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/system.c b/src/pextlib1.0/system.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 4813ccd..4ef61c7 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/system.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/system.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -37,7 +37,6 @@
</span>
#ifndef __APPLE__
/* required for fdopen(3)/seteuid(2), among others */
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* hides fgetln(3) on OS X */
</span> #define _XOPEN_SOURCE 600
#endif
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -72,8 +71,8 @@
</span> extern char **environ;
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if !HAVE_FGETLN
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-char *fgetln(FILE *stream, size_t *len);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if !HAVE_GETLINE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "getline.h"
</span> #endif
#ifndef _PATH_DEVNULL
</pre><pre style='margin:0'>
</pre>