Re: getline.h

2007-09-29 Thread Bruno Haible
Eric Blake wrote on 2007-08-22:
   * lib/stdio_.h (getdelim, getline): Declare.

Small improvement of the doc: Say that getline reads a line. Return not
Returns (GNU style conventions). List the identifiers in the prototype.


2007-09-29  Bruno Haible  [EMAIL PROTECTED]

* lib/stdio_.h (getdelim, getline): Add identifiers. Doc tweak.

*** lib/stdio_.h.orig   2007-09-30 05:44:01.0 +0200
--- lib/stdio_.h2007-09-30 03:19:28.0 +0200
***
*** 308,319 
  
  #if @GNULIB_GETDELIM@
  # if [EMAIL PROTECTED]@
!   /* 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
!  necessary.  Returns the number of characters read (not including
!  the null terminator), or -1 on error or EOF.  */
!   extern ssize_t getdelim (char **, size_t *, int delim, FILE *);
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef getdelim
--- 308,321 
  
  #if @GNULIB_GETDELIM@
  # if [EMAIL PROTECTED]@
! /* Read input, up to (and including) the next occurrence of DELIMITER, from
!STREAM, store it in *LINEPTR (and NUL-terminate it).
!*LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
!bytes of space.  It is realloc'd as necessary.
!Return the number of bytes read and stored at *LINEPTR (not including the
!NUL terminator), or -1 on error or EOF.  */
! extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
!FILE *stream);
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef getdelim
***
*** 329,340 
  #  define getline rpl_getline
  # endif
  # if [EMAIL PROTECTED]@ || @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
!  necessary.  Returns the number of characters read (not including
!  the null terminator), or -1 on error or EOF.  */
!   extern ssize_t getline (char **, size_t *, FILE *);
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef getline
--- 331,343 
  #  define getline rpl_getline
  # endif
  # if [EMAIL PROTECTED]@ || @REPLACE_GETLINE@
! /* Read a line, up to (and including) the next newline, from STREAM, store it
!in *LINEPTR (and NUL-terminate it).
!*LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
!bytes of space.  It is realloc'd as necessary.
!Return the number of bytes read and stored at *LINEPTR (not including the
!NUL terminator), or -1 on error or EOF.  */
! extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef getline





Re: getline.h

2007-09-09 Thread Bruno Haible
Eric Blake wrote:
 Here's what I'm committing; I think it addresses all your points.
 
 2007-08-22  Eric Blake  [EMAIL PROTECTED]
 
   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.

Thanks. Let me update the documentation: I got the list of platforms lacking
the functions from the various-symlists package [1].

[1] http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg0.html


2007-09-09  Bruno Haible  [EMAIL PROTECTED]

* doc/functions/getdelim.texi: Update list of platforms lacking the
function.
* doc/functions/getline.texi: Likewise.

--- doc/functions/getdelim.texi 23 Aug 2007 02:00:19 -  1.1
+++ doc/functions/getdelim.texi 9 Sep 2007 17:14:07 -
@@ -2,8 +2,8 @@
 @section @code{getdelim}
 @findex getdelim
 
-POSIX specification: Draft 3 of 200x; free membership at
[EMAIL PROTECTED]://www.opengroup.org/austin/} is required
+POSIX specification: Draft 3 of 200x; to access it, free membership at
[EMAIL PROTECTED]://www.opengroup.org/austin/} is required.
 
 Gnulib module: getdelim
 
@@ -11,11 +11,10 @@
 @itemize
 @item
 This function is missing on some platforms:
-mingw
-
+MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 
6.5, OSF/1 5.1, Solaris 10, mingw, Interix 3.5.
 @item
 This function is missing a declaration on some platforms:
-BeOS
+BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- doc/functions/getline.texi  23 Aug 2007 02:00:19 -  1.1
+++ doc/functions/getline.texi  9 Sep 2007 17:14:07 -
@@ -2,8 +2,8 @@
 @section @code{getline}
 @findex getline
 
-POSIX specification: Draft 3 of 200x; free membership at
[EMAIL PROTECTED]://www.opengroup.org/austin/} is required
+POSIX specification: Draft 3 of 200x; to access it, free membership at
[EMAIL PROTECTED]://www.opengroup.org/austin/} is required.
 
 Gnulib module: getline
 
@@ -11,12 +11,10 @@
 @itemize
 @item
 This function is missing on some platforms:
-mingw
-
+MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 
6.5, OSF/1 5.1, Solaris 10, mingw, Interix 3.5.
 @item
 This function is missing a declaration on some platforms:
-BeOS
-
+BeOS.
 @item
 Some platforms provide a function by this name but with the wrong
 signature, for example in -linet.





Re: getline.h

2007-08-23 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote:

 According to Eric Blake on 8/22/2007 6:04 PM:
 According to Bruno Haible on 8/22/2007 3:02 PM:
 Hi Eric,

 Thanks for working on this, and for the unit tests. The patch - excluding
 the one of getdelim.c - is nearly perfect. But I see three problems:

 Thanks for catching the nits.  Please feel free to apply patches if you
 come up with them before me.

 Here's what I'm committing; I think it addresses all your points.

 2007-08-22  Eric Blake  [EMAIL PROTECTED]

   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.

I almost wrote this:

  Even with that patch, errno may still end up being changed inappropriately
  when getdelim succeeds yet funlockfile fails.  And what about flockfile?

But then I looked it up and saw that those functions are guaranteed
not to set errno.  So that's a red herring.  Sorry about that.

Here's a patch to remove that unnecessary code, including the
errno = ENOMEM business, assuming that we'll eventually have
malloc/realloc/calloc wrappers that make mingw do the right thing:

[is this ok with you, Simon? ]

Getdelim touchup.
* lib/getdelim.c (getdelim): Don't bother to save/restore errno
around the funlockfile call, since funlockfile never sets errno.
Don't set errno upon failed realloc.

Index: lib/getdelim.c
===
RCS file: /cvsroot/gnulib/gnulib/lib/getdelim.c,v
retrieving revision 1.9
diff -u -p -r1.9 getdelim.c
--- lib/getdelim.c  23 Aug 2007 02:00:19 -  1.9
+++ lib/getdelim.c  23 Aug 2007 06:56:55 -
@@ -58,7 +58,6 @@ getdelim (char **lineptr, size_t *n, int
 {
   ssize_t result;
   size_t cur_len = 0;
-  int e; /* Preserve errno across funlockfile.  */

   if (lineptr == NULL || n == NULL || fp == NULL)
 {
@@ -75,7 +74,6 @@ getdelim (char **lineptr, size_t *n, int
   if (*lineptr == NULL)
{
  result = -1;
- e = ENOMEM;
  goto unlock_return;
}
 }
@@ -88,7 +86,6 @@ getdelim (char **lineptr, size_t *n, int
   if (i == EOF)
{
  result = -1;
- e = errno;
  break;
}

@@ -105,7 +102,7 @@ getdelim (char **lineptr, size_t *n, int
  if (cur_len + 1 = needed)
{
  result = -1;
- e = EOVERFLOW;
+ errno = EOVERFLOW;
  goto unlock_return;
}

@@ -113,7 +110,6 @@ getdelim (char **lineptr, size_t *n, int
  if (new_lineptr == NULL)
{
  result = -1;
- e = ENOMEM;
  goto unlock_return;
}

@@ -131,8 +127,7 @@ getdelim (char **lineptr, size_t *n, int
   result = cur_len ? cur_len : result;

  unlock_return:
-  funlockfile (fp);
-  if (result == -1)
-errno = e;
+  funlockfile (fp); /* doesn't set errno */
+
   return result;
 }




Re: getline.h

2007-08-23 Thread Simon Josefsson
Jim Meyering [EMAIL PROTECTED] writes:

 [is this ok with you, Simon? ]

Yes, please add it.

/Simon




Re: getline.h

2007-08-23 Thread Jim Meyering
Simon Josefsson [EMAIL PROTECTED] wrote:
 Jim Meyering [EMAIL PROTECTED] writes:
 [is this ok with you, Simon? ]

 Yes, please add it.

Committed.




Re: getline.h

2007-08-22 Thread Simon Josefsson
Eric Blake [EMAIL PROTECTED] writes:

 According to Jim Meyering on 8/19/2007 2:18 PM:
 Eric Blake [EMAIL PROTECTED] wrote:
 I could go either way, although I'm leaning toward doing it now;
 
 I agree.  Doing it now is fine.

 How about this for the patch, then?  Simon, this is your module.  The
 patch includes a couple of bug fixes in getdelim.c:

Looks fine to me, please install.  Thanks for writing a self-test!

/Simon




Re: getline.h

2007-08-22 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote:
 2007-08-21  Eric Blake  [EMAIL PROTECTED]

   Move getline and getdelim into stdio.h, per POSIX 200x.
...

Thanks for doing that.
I've adjusted coreutils accordingly:

  http://git.sv.gnu.org/gitweb/?p=coreutils.git




Re: getline.h

2007-08-22 Thread Bruno Haible
Hi Eric,

Thanks for working on this, and for the unit tests. The patch - excluding
the one of getdelim.c - is nearly perfect. But I see three problems:

1) You define the shell variable HAVE_DECL_GETDELIM depending whether the
   function exists, not whether the function is declared. But for example
   BeOS has the function but not the declaration. In this case we want
   stdio.h to provide the declaration, but there is no need for the
   function.

 --- m4/getdelim.m422 Aug 2006 17:15:28 -  1.2
 +++ m4/getdelim.m422 Aug 2007 00:04:01 -
 @@ -19,6 +20,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
  
if test $ac_cv_func_getdelim = no; then
  gl_PREREQ_GETDELIM
 +HAVE_DECL_GETDELIM=0
fi
  ])
 
How about setting HAVE_DECL_GETDELIM depending on $ac_cv_have_decl_getdelim ?

2) Likewise for getline.

 --- m4/getline.m4 22 Aug 2006 17:15:28 -  1.18
 +++ m4/getline.m4 22 Aug 2007 00:04:01 -
 @@ -60,12 +62,12 @@ AC_DEFUN([gl_FUNC_GETLINE],
  )])
fi
  
 +  if test $ac_cv_func_getline = no; then
 +HAVE_DECL_GETLINE=0
 +  fi
 +
if test $am_cv_func_working_getline = no; then

3) This fails to provide a declaration for the rpl_getline function
if @REPLACE_GETLINE@  @HAVE_DECL_GETLINE@ (e.g. on all those systems
which have a getline function which does not work: Cygwin, IRIX).

 +#if @GNULIB_GETLINE@
 +# if @REPLACE_GETLINE@
 +#  undef getline
 +#  define getline rpl_getline
 +# endif
 +# if [EMAIL PROTECTED]@
 +  ...
 +  extern ssize_t getline (char **, size_t *, FILE *);

The last #if should be:
   # if @REPLACE_GETLINE@ || [EMAIL PROTECTED]@

(as for example for the snprintf function).

4) Would you mind adding documentation files doc/function/get{line,delim}.texi
(since POSIX is being extended)? Otherwise I can do it.

Bruno





Re: getline.h

2007-08-22 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 8/22/2007 3:02 PM:
 Hi Eric,
 
 Thanks for working on this, and for the unit tests. The patch - excluding
 the one of getdelim.c - is nearly perfect. But I see three problems:

Thanks for catching the nits.  Please feel free to apply patches if you
come up with them before me.

 
 3) This fails to provide a declaration for the rpl_getline function
 if @REPLACE_GETLINE@  @HAVE_DECL_GETLINE@ (e.g. on all those systems
 which have a getline function which does not work: Cygwin, IRIX).

Actually, cygwin's getline works, as of 1.5.19 (now at 1.5.24); it passed
the test-readline.c requirements just fine.  Unless you have a countercase
where it does not work, in which case we need to beef up the test.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzM8p84KuGfSFAYARAiuOAJ90hLNFcPQLjAi9zNAQqciuutpsgQCfcroX
+VpLlnU+5OrV3iygzi3hg1c=
=mMr9
-END PGP SIGNATURE-




Re: getline.h

2007-08-22 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Eric Blake on 8/22/2007 6:04 PM:
 According to Bruno Haible on 8/22/2007 3:02 PM:
 Hi Eric,
 
 Thanks for working on this, and for the unit tests. The patch - excluding
 the one of getdelim.c - is nearly perfect. But I see three problems:
 
 Thanks for catching the nits.  Please feel free to apply patches if you
 come up with them before me.

Here's what I'm committing; I think it addresses all your points.

2007-08-22  Eric Blake  [EMAIL PROTECTED]

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.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGzOoD84KuGfSFAYARAl+dAJ9XrkZHtoiOQwJUpxWbqc3JTl+KowCWOSv6
wSAwvtfYANnM796ICFivDg==
=c4j1
-END PGP SIGNATURE-
Index: lib/getdelim.c
===
RCS file: /sources/gnulib/gnulib/lib/getdelim.c,v
retrieving revision 1.8
diff -u -p -r1.8 getdelim.c
--- lib/getdelim.c  22 Aug 2007 12:54:22 -  1.8
+++ lib/getdelim.c  23 Aug 2007 01:58:57 -
@@ -58,6 +58,7 @@ getdelim (char **lineptr, size_t *n, int
 {
   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 @@ getdelim (char **lineptr, size_t *n, int
 
   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 @@ getdelim (char **lineptr, size_t *n, int
   if (i == EOF)
{
  result = -1;
+ e = errno;
  break;
}
 
@@ -102,7 +105,7 @@ getdelim (char **lineptr, size_t *n, int
  if (cur_len + 1 = needed)
{
  result = -1;
- errno = EOVERFLOW;
+ e = EOVERFLOW;
  goto unlock_return;
}
 
@@ -110,6 +113,7 @@ getdelim (char **lineptr, size_t *n, int
  if (new_lineptr == NULL)
{
  result = -1;
+ e = ENOMEM;
  goto unlock_return;
}
 
@@ -128,5 +132,7 @@ getdelim (char **lineptr, size_t *n, int
 
  unlock_return:
   funlockfile (fp);
+  if (result == -1)
+errno = e;
   return result;
 }
Index: lib/stdio_.h
===
RCS file: /sources/gnulib/gnulib/lib/stdio_.h,v
retrieving revision 1.33
diff -u -p -r1.33 stdio_.h
--- lib/stdio_.h22 Aug 2007 12:54:22 -  1.33
+++ lib/stdio_.h23 Aug 2007 01:58:57 -
@@ -328,7 +328,7 @@ extern long rpl_ftell (FILE *fp);
 #  undef getline
 #  define getline rpl_getline
 # endif
-# if [EMAIL PROTECTED]@
+# if [EMAIL PROTECTED]@ || @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
Index: doc/gnulib.texi
===
RCS file: /sources/gnulib/gnulib/doc/gnulib.texi,v
retrieving revision 1.42
diff -u -p -r1.42 gnulib.texi
--- doc/gnulib.texi 15 Jul 2007 14:05:43 -  1.42
+++ doc/gnulib.texi 23 Aug 2007 01:58:57 -
@@ -929,6 +929,7 @@ by Gnulib.
 * getcontext::
 * getcwd::
 * getdate::
+* getdelim::
 * getegid::
 * getenv::
 * geteuid::
@@ -945,6 +946,7 @@ by Gnulib.
 * gethostid::
 * gethostname::
 * getitimer::
+* getline::
 * getlogin::
 * getlogin_r::
 * getmsg::
@@ -2047,6 +2049,7 @@ by Gnulib.
 @include functions/getcontext.texi
 @include functions/getcwd.texi
 @include functions/getdate.texi
[EMAIL PROTECTED] functions/getdelim.texi
 @include functions/getegid.texi
 @include functions/getenv.texi
 @include functions/geteuid.texi
@@ -2063,6 +2066,7 @@ by Gnulib.
 @include functions/gethostid.texi
 @include functions/gethostname.texi
 @include functions/getitimer.texi
[EMAIL PROTECTED] functions/getline.texi
 

Re: getline.h

2007-08-21 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 8/19/2007 2:18 PM:
 Eric Blake [EMAIL PROTECTED] wrote:
 I could go either way, although I'm leaning toward doing it now;
 
 I agree.  Doing it now is fine.

How about this for the patch, then?  Simon, this is your module.  The
patch includes a couple of bug fixes in getdelim.c:

It is valid on entrance for *lineptr to be non-NULL but *n to be 0 (ie.
via malloc(0)), but your implementation was leaking that memory.  Also,
your implementation failed to set errno to EOVERFLOW when it detects that
it needs to malloc more than SSIZE_MAX bytes.

2007-08-21  Eric Blake  [EMAIL PROTECTED]

Move getline and getdelim into stdio.h, per POSIX 200x.
* modules/getline (Files): Remove getline.h.
(Depends-on): Add stdio.
(configure.ac): Add module indicator.
* modules/getdelim (Files): Remove getdelim.h.
(Depends-on): Add stdio.
(configure.ac): Add module indicator.
* modules/stdio (Makefile.am): Work with new indicators.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Add new defaults.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Work with stdio needs.
* m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
* lib/getdelim.h: Delete.
* lib/getline.h: Delete.
* lib/stdio_.h (getdelim, getline): Declare.
* modules/getdelim-tests: New module.
* modules/getline-tests: Likewise.
* tests/test-getdelim.c: New file.
* tests/test-getline.c: Likewise.
* NEWS: Document the change.
* lib/getline.c: Update choice of header.
* lib/csharpcomp.c: Likewise.
* lib/getpass.c: Likewise.
* lib/javacomp.c: Likewise.
* lib/javaversion.c: Likewise.
* lib/yesno.c: Likewise.
* lib/getdelim.c: Likewise.
(getdelim): Set errno on failure, and avoid memory leak.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGy35+84KuGfSFAYARAmiLAJ9/rWVDeQe67y63aUKYkb7/0mWTbwCgwFOZ
Ye5pE0io6+dGz3cM+L/t2G0=
=t2L6
-END PGP SIGNATURE-
Index: NEWS
===
RCS file: /sources/gnulib/gnulib/NEWS,v
retrieving revision 1.29
diff -u -p -r1.29 NEWS
--- NEWS18 Aug 2007 07:16:53 -  1.29
+++ NEWS22 Aug 2007 00:04:01 -
@@ -6,6 +6,10 @@ User visible incompatible changes
 
 DateModules Changes
 
+2007-08-21  getdelim, getline
+The include file is changed from getdelim.h
+and getline.h to the POSIX 200x stdio.h.
+
 2007-08-18  idcache Now provides prototypes in idcache.h.
 
 2007-08-10  xstrtol The STRTOL_FATAL_ERROR macro is removed.
Index: lib/csharpcomp.c
===
RCS file: /sources/gnulib/gnulib/lib/csharpcomp.c,v
retrieving revision 1.8
diff -u -p -r1.8 csharpcomp.c
--- lib/csharpcomp.c9 Jun 2007 11:15:22 -   1.8
+++ lib/csharpcomp.c22 Aug 2007 00:04:01 -
@@ -30,7 +30,6 @@
 #include execute.h
 #include pipe.h
 #include wait-process.h
-#include getline.h
 #include sh-quote.h
 #include safe-read.h
 #include xmalloca.h
Index: lib/getdelim.c
===
RCS file: /sources/gnulib/gnulib/lib/getdelim.c,v
retrieving revision 1.7
diff -u -p -r1.7 getdelim.c
--- lib/getdelim.c  29 Oct 2006 21:52:55 -  1.7
+++ lib/getdelim.c  22 Aug 2007 00:04:01 -
@@ -1,5 +1,5 @@
 /* getdelim.c --- Implementation of replacement getdelim function.
-   Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006 Free
+   Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007 Free
Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
 
 #include config.h
 
-#include getdelim.h
+#include stdio.h
 
 #include limits.h
 #include stdlib.h
@@ -42,6 +42,11 @@
 # define funlockfile(x) ((void) 0)
 #endif
 
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW.  */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#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
@@ -62,10 +67,10 @@ getdelim (char **lineptr, size_t *n, int
 
   flockfile (fp);
 
-  if (*lineptr == NULL || *n == 0)
+  if (*n == 0)
 {
   *n = 120;
-  *lineptr = (char *) malloc (*n);
+  *lineptr = (char *) realloc (*lineptr, 120);
   if (*lineptr == NULL)
{
  result = -1;
@@ -97,6 +102,7 @@ getdelim (char **lineptr, size_t *n, int
  

Re: getline.h

2007-08-19 Thread Paul Eggert
Eric Blake [EMAIL PROTECTED] writes:

 I could go either way, although I'm leaning toward doing it now; I'll wait
 for anyone else to speak their mind.

I also lean towards doing it now, since I think it unlikely that
POSIX will change much before becoming official in this area,
and anyway its use in glibc stdio.h is a powerful argument.




Re: getline.h

2007-08-19 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote:
 I could go either way, although I'm leaning toward doing it now;

I agree.  Doing it now is fine.




Re: getline.h

2007-08-18 Thread Bruno Haible
Eric Blake wrote:
 Now that POSIX 200x is standardizing getline and getdelim as part of
 stdio.h, should we get rid of getline.h and beef up stdio_.h, then
 adjust all the callers (such as yesno.c) to assume this?

Hmm, can't we wait until the POSIX standard with these changes is official?
Arguments pro waiting:

  - The majority of users is looking at the newest released POSIX on the
public web of www.opengroup.org. They will be confused if gnulib
voluntarily deviates from that.

  - Decisions of a standardization comittee can anytime be changed or even
withdrawn before the next standard release, causing double work for us
if we follow the standard closely.

Arguments against waiting:

  - When the POSIX standard with these changes is released, it will take us
less time to implement the changes.

Bruno





Re: getline.h

2007-08-18 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 8/18/2007 4:36 PM:
 Eric Blake wrote:
 Now that POSIX 200x is standardizing getline and getdelim as part of
 stdio.h, should we get rid of getline.h and beef up stdio_.h, then
 adjust all the callers (such as yesno.c) to assume this?
 
 Hmm, can't we wait until the POSIX standard with these changes is official?
 Arguments pro waiting:
 
   - The majority of users is looking at the newest released POSIX on the
 public web of www.opengroup.org. They will be confused if gnulib
 voluntarily deviates from that.

True, and the drafts of 200x are only available to Austin group members
(although membership does not cost any money, so we can point people in
the right direction).

 
   - Decisions of a standardization comittee can anytime be changed or even
 withdrawn before the next standard release, causing double work for us
 if we follow the standard closely.

True, but draft 3 implemented narrowing-down rules, where only the
portions modified in draft 2 can be rejected; getline and getdelim were
pretty much untouched, meaning they have already obtained reasonable
consensus.

 
 Arguments against waiting:
 
   - When the POSIX standard with these changes is released, it will take us
 less time to implement the changes.

Another argument for making the change now:

 - Many GNU developers do their primary development with glibc headers,
where getline is already available in stdio.h; putting getline in
stdio.h instead of getline.h makes existing Linux programs easier to port.

I could go either way, although I'm leaning toward doing it now; I'll wait
for anyone else to speak their mind.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGx7SI84KuGfSFAYARAsNFAJ4giyIp6lq1RNRE6LF0LqY8gO+xhgCfYake
j4qAh0evlw5/ED4rWXe9p9o=
=z70d
-END PGP SIGNATURE-