[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read-file
From: |
Paul Eggert |
Subject: |
Re: read-file |
Date: |
Fri, 16 Jun 2006 11:18:57 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Simon Josefsson <address@hidden> writes:
> + if (buf)
> + buf[size] = '\0';
The file reading code returns NULL if the file was empty? But the
comments makes it sound like it will return xstrdup (""), and that
would be more consistent. You might also add a test case, to read
from /dev/null.
> + if (out)
> + rc = fclose (stream);
> + else
> + {
> + /* On failure, preserve the original errno value. */
> + int save_errno = errno;
> + rc = fclose (stream);
> + errno = save_errno;
> + }
> +
> + if (rc != 0)
> + {
> + int save_errno = errno;
> + free (out);
> + errno = save_errno;
> + return NULL;
> + }
The following replacement code is a bit clearer, at least to my eyes:
save_errno = errno;
if (fclose (stream) != 0)
{
if (out)
{
save_errno = errno;
free (out);
}
errno = save_errno;
return NULL;
}
- read-file (was: strfile), Simon Josefsson, 2006/06/16
- Re: [bug-gnulib] read-file (was: strfile), Bruno Haible, 2006/06/16
- Re: read-file,
Paul Eggert <=
- Re: read-file, Aaron Stone, 2006/06/16
- Re: read-file, Simon Josefsson, 2006/06/16
- Re: read-file, Larry Jones, 2006/06/16
- Re: read-file, Simon Josefsson, 2006/06/16
- Re: read-file, Larry Jones, 2006/06/16
- Re: read-file, Paul Eggert, 2006/06/19
Re: read-file, Simon Josefsson, 2006/06/16