+2007-08-22 Eric Blake <ebb9@byu.net>
+
+ Getline touchups.
+ * lib/getdelim.c (getdelim): Revert regression that required *n to
+ be 0 when *lineptr is NULL. Preserve errno across funlockfile.
+ * m4/getdelim.m4 (gl_FUNC_GETDELIM): Check for declaration of
+ getdelim, rather than whether implementation is missing.
+ * m4/getline.m4 (gl_FUNC_GETLINE): Likewise for getline.
+ * lib/stdio_.h (getline): Also declare if replacement is
+ required.
+ * doc/functions/getdelim.texi: New file.
+ * doc/functions/getline.texi: Likewise.
+ * doc/gnulib.texi (Function Substitutes): Add new files.
+ Reported by Bruno Haible.
+
2007-08-22 Ludovic Courtès <ludo@gnu.org>
* users.txt: Add Guile.
--- /dev/null
+@node getdelim
+@section @code{getdelim}
+@findex getdelim
+
+POSIX specification: Draft 3 of 200x; free membership at
+@url{http://www.opengroup.org/austin/} is required
+
+Gnulib module: getdelim
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This function is missing on some platforms:
+mingw
+
+@item
+This function is missing a declaration on some platforms:
+BeOS
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
--- /dev/null
+@node getline
+@section @code{getline}
+@findex getline
+
+POSIX specification: Draft 3 of 200x; free membership at
+@url{http://www.opengroup.org/austin/} is required
+
+Gnulib module: getline
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This function is missing on some platforms:
+mingw
+
+@item
+This function is missing a declaration on some platforms:
+BeOS
+
+@item
+Some platforms provide a function by this name but with the wrong
+signature, for example in -linet.
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
\input texinfo @c -*-texinfo-*-
-@comment $Id: gnulib.texi,v 1.42 2007-07-15 14:05:43 karl Exp $
+@comment $Id: gnulib.texi,v 1.43 2007-08-23 02:00:19 ericb Exp $
@comment %**start of header
@setfilename gnulib.info
@settitle GNU Gnulib
@syncodeindex pg cp
@comment %**end of header
-@set UPDATED $Date: 2007-07-15 14:05:43 $
+@set UPDATED $Date: 2007-08-23 02:00:19 $
@copying
This manual is for GNU Gnulib (updated @value{UPDATED}),
* getcontext::
* getcwd::
* getdate::
+* getdelim::
* getegid::
* getenv::
* geteuid::
* gethostid::
* gethostname::
* getitimer::
+* getline::
* getlogin::
* getlogin_r::
* getmsg::
@include functions/getcontext.texi
@include functions/getcwd.texi
@include functions/getdate.texi
+@include functions/getdelim.texi
@include functions/getegid.texi
@include functions/getenv.texi
@include functions/geteuid.texi
@include functions/gethostid.texi
@include functions/gethostname.texi
@include functions/getitimer.texi
+@include functions/getline.texi
@include functions/getlogin.texi
@include functions/getlogin_r.texi
@include functions/getmsg.texi
{
ssize_t result;
size_t cur_len = 0;
+ int e; /* Preserve errno across funlockfile. */
if (lineptr == NULL || n == NULL || fp == NULL)
{
flockfile (fp);
- if (*n == 0)
+ if (*lineptr == NULL || *n == 0)
{
*n = 120;
- *lineptr = (char *) realloc (*lineptr, 120);
+ *lineptr = (char *) realloc (*lineptr, *n);
if (*lineptr == NULL)
{
result = -1;
+ e = ENOMEM;
goto unlock_return;
}
}
if (i == EOF)
{
result = -1;
+ e = errno;
break;
}
if (cur_len + 1 >= needed)
{
result = -1;
- errno = EOVERFLOW;
+ e = EOVERFLOW;
goto unlock_return;
}
if (new_lineptr == NULL)
{
result = -1;
+ e = ENOMEM;
goto unlock_return;
}
unlock_return:
funlockfile (fp);
+ if (result == -1)
+ errno = e;
return result;
}
# undef getline
# define getline rpl_getline
# endif
-# if !@HAVE_DECL_GETLINE@
+# if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
/* Read up to (and including) a newline 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
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-AC_PREREQ(2.52)
+AC_PREREQ([2.60])
AC_DEFUN([gl_FUNC_GETDELIM],
[
dnl Persuade glibc <stdio.h> to declare getdelim().
AC_REQUIRE([AC_GNU_SOURCE])
- AC_REPLACE_FUNCS(getdelim)
- AC_CHECK_DECLS_ONCE(getdelim)
+ AC_REPLACE_FUNCS([getdelim])
+ AC_CHECK_DECLS_ONCE([getdelim])
if test $ac_cv_func_getdelim = no; then
gl_PREREQ_GETDELIM
+ fi
+
+ if test $ac_cv_have_decl_getdelim = no; then
HAVE_DECL_GETDELIM=0
fi
])
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-AC_PREREQ(2.52)
+AC_PREREQ([2.60])
dnl See if there's a working, system-supplied version of the getline function.
dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
dnl Persuade glibc <stdio.h> to declare getline().
AC_REQUIRE([AC_GNU_SOURCE])
- AC_CHECK_DECLS([getline])
+ AC_CHECK_DECLS_ONCE([getline])
gl_getline_needs_run_time_check=no
AC_CHECK_FUNC(getline,
)])
fi
- if test $ac_cv_func_getline = no; then
+ if test $ac_cv_have_decl_getline = no; then
HAVE_DECL_GETLINE=0
fi
if test $am_cv_func_working_getline = no; then
REPLACE_GETLINE=1
- AC_LIBOBJ(getline)
+ AC_LIBOBJ([getline])
gl_PREREQ_GETLINE
fi