Thanks for reporting that. I installed into Gnulib the attached
somewhat-more-elaborate patch, which should fix the problem.
>From 62dac84a8a9ce9cee76736e493a8ff8bcd71229d Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 17 Aug 2016 15:01:50 -0700
Subject: [PATCH] getdelim: remove dependency on realloc-posix
* lib/canonicalize-lgpl.c (alloc_failed)
[!FUNC_REALPATH_WORKS || defined _LIBC]: New function,
(__realpath) [!FUNC_REALPATH_WORKS || defined _LIBC]: Use it.
Use __set_errno where needed, for consistency.
* lib/getdelim.c (alloc_failed): New function.
(getdelim): Use it.
* modules/getdelim (Depends-on): Remove realloc-posix.
---
ChangeLog | 10 ++++++++++
lib/canonicalize-lgpl.c | 27 +++++++++++++++++----------
lib/getdelim.c | 12 ++++++++++++
modules/getdelim | 1 -
4 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 07b0047..e899eb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-08-16 Paul Eggert <egg...@cs.ucla.edu>
+
+ getdelim: remove dependency on realloc-posix
+ * lib/canonicalize-lgpl.c (alloc_failed)
+ [!FUNC_REALPATH_WORKS || defined _LIBC]: New function,
+ (__realpath) [!FUNC_REALPATH_WORKS || defined _LIBC]: Use it.
+ Use __set_errno where needed, for consistency.
+ * lib/getdelim.c (alloc_failed): New function.
+ (getdelim): Use it.
+
2016-08-09 Assaf Gordon <assafgor...@gmail.com>
parse-datetime: add optional debug printing
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 1d0bf65..da83da3 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -84,6 +84,17 @@
#endif
#if !FUNC_REALPATH_WORKS || defined _LIBC
+
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the malloc or realloc modules; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Return the canonical absolute name of file NAME. A canonical name
does not contain any ".", ".." components nor any repeated path
separators ('/') or symlinks. All path components must exist. If
@@ -135,9 +146,7 @@ __realpath (const char *name, char *resolved)
rpath = malloc (path_max);
if (rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'malloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
return NULL;
}
}
@@ -238,9 +247,7 @@ __realpath (const char *name, char *resolved)
new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL)
{
- /* It's easier to set errno to ENOMEM than to rely on the
- 'realloc-posix' gnulib module. */
- errno = ENOMEM;
+ alloc_failed ();
goto error;
}
rpath = new_rpath;
@@ -278,7 +285,7 @@ __realpath (const char *name, char *resolved)
buf = malloca (path_max);
if (!buf)
{
- errno = ENOMEM;
+ alloc_failed ();
goto error;
}
@@ -287,7 +294,7 @@ __realpath (const char *name, char *resolved)
{
int saved_errno = errno;
freea (buf);
- errno = saved_errno;
+ __set_errno (saved_errno);
goto error;
}
buf[n] = '\0';
@@ -298,7 +305,7 @@ __realpath (const char *name, char *resolved)
if (!extra_buf)
{
freea (buf);
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
}
@@ -370,7 +377,7 @@ error:
freea (extra_buf);
if (resolved == NULL)
free (rpath);
- errno = saved_errno;
+ __set_errno (saved_errno);
}
return NULL;
}
diff --git a/lib/getdelim.c b/lib/getdelim.c
index 68a6f34..706c2ed 100644
--- a/lib/getdelim.c
+++ b/lib/getdelim.c
@@ -47,6 +47,16 @@
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
#endif
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the realloc module; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
NULL), pointing to *N characters of space. It is realloc'ed as
@@ -74,6 +84,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, *n);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
@@ -111,6 +122,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
diff --git a/modules/getdelim b/modules/getdelim
index e84558c..ee71165 100644
--- a/modules/getdelim
+++ b/modules/getdelim
@@ -9,7 +9,6 @@ Depends-on:
stdio
extensions
stdint [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
-realloc-posix [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
errno [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1]
configure.ac:
--
2.5.5