On Wednesday, August 24, 2005 at 13:20, Bruno Haible wrote: > > Here's what getdelim in Gnulib returns: > > >=0, errno undefined, feof (getc returned EOF, reached end of file) > > >=0, errno!=0, ferror (getc returned EOF, read failed) > > Actually I think the glibc doc means that -1 is returned if EOF or read > failure occurs before the first character is read. If it occurs after > some non-empty string is already read, this non-empty string is returned.
Well, the current Gnulib implementation doesn't behave that way. It will return 0 if the first call to getc fails (for whatever reason - error or EOF). AFAIK, the correct way to test getline/getdelim for errors in the current implementation is: errno = 0; if (getline(..., fh) <= 0) if (ferror(fh) || errno != 0) { perror("getline"); } else if (feof(fh)) { /* handle EOF */ } else { errno = ENOMEM; perror("getline"); } } I believe the GNU libc documentation needs to be fixed. Regards, Oskar Liljeblad ([EMAIL PROTECTED]) _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib