Mercurial > hg > octave-nkf > gnulib-hg
changeset 9164:e945561759a5
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.
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 23 Aug 2007 02:00:18 +0000 |
parents | 576f6b643ca3 |
children | ef74805fd7e0 |
files | ChangeLog doc/functions/getdelim.texi doc/functions/getline.texi doc/gnulib.texi lib/getdelim.c lib/stdio_.h m4/getdelim.m4 m4/getline.m4 |
diffstat | 8 files changed, 91 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +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.
new file mode 100644 --- /dev/null +++ b/doc/functions/getdelim.texi @@ -0,0 +1,23 @@ +@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
new file mode 100644 --- /dev/null +++ b/doc/functions/getline.texi @@ -0,0 +1,27 @@ +@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
--- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -1,5 +1,5 @@ \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 @@ -7,7 +7,7 @@ @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}), @@ -929,6 +929,7 @@ * getcontext:: * getcwd:: * getdate:: +* getdelim:: * getegid:: * getenv:: * geteuid:: @@ -945,6 +946,7 @@ * gethostid:: * gethostname:: * getitimer:: +* getline:: * getlogin:: * getlogin_r:: * getmsg:: @@ -2047,6 +2049,7 @@ @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 @@ -2063,6 +2066,7 @@ @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
--- a/lib/getdelim.c +++ b/lib/getdelim.c @@ -58,6 +58,7 @@ { ssize_t result; size_t cur_len = 0; + int e; /* Preserve errno across funlockfile. */ if (lineptr == NULL || n == NULL || fp == NULL) { @@ -67,13 +68,14 @@ 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; } } @@ -86,6 +88,7 @@ if (i == EOF) { result = -1; + e = errno; break; } @@ -102,7 +105,7 @@ if (cur_len + 1 >= needed) { result = -1; - errno = EOVERFLOW; + e = EOVERFLOW; goto unlock_return; } @@ -110,6 +113,7 @@ if (new_lineptr == NULL) { result = -1; + e = ENOMEM; goto unlock_return; } @@ -128,5 +132,7 @@ unlock_return: funlockfile (fp); + if (result == -1) + errno = e; return result; }
--- a/lib/stdio_.h +++ b/lib/stdio_.h @@ -328,7 +328,7 @@ # 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
--- a/m4/getdelim.m4 +++ b/m4/getdelim.m4 @@ -6,7 +6,7 @@ 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], [ @@ -15,11 +15,14 @@ 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 ])
--- a/m4/getline.m4 +++ b/m4/getline.m4 @@ -7,7 +7,7 @@ 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 @@ -20,7 +20,7 @@ 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, @@ -62,13 +62,13 @@ )]) 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