Ito Kazumitsu wrote:
Casey Marshall wrote.
I meant the curly braces, the #if..#endif is appropriate.
The source code now looks like this. What is the preferred way of
writing this?
if (ioctl (fd, FIONREAD, &avail) == -1)
{
#if defined(ENOTTY) && defined(HAVE_FSTAT)
if (errno == ENOTTY)
{
if ((fstat (fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode))
{
n = lseek (fd, 0, SEEK_CUR);
if (n != -1)
{
avail = statBuffer.st_size - n;
return avail;
}
}
}
#endif
JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
Perhaps:
if ((errno == ENOTTY)
&& (fstat (fd, &statBuffer) == 0)
&& S_ISREG (statBuffer.st_mode))
{
.
.
.
}
David Daney