Remove fcntl.h includes throughout.

* fhandler.h: Move fcntl.h include here.
(fhandler_base::set_flags): Accept supplied_bin argument.  Make non-inlined.
* dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc.
(reset_to_open_binmode): Use set_flags.
* cygwin.din (open): Avoid newlib wrapper.
(read): Ditto.
(unlink): Ditto.
(write): Ditto.
* fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument.  Make
binmode decisions here.
(fhandler_base::open): Avoid using pc if it is NULL.  Eliminate binmode logic.
Just call set_flags with binmode argument.
(fhandler_base::init): Call set_flags with binmode argument.
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::init): Force binary on open.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here.
Let it happen in base class.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open.  Set return
value appropriately if unable to open.
* fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before
open_status.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (path_conv::check): Avoid checking for extension when error or
directory.
(set_flags): Set PATH_TEXT explicitly, when appropriate.
(mount_info::conv_to_win32_path): Use set_flags() to set path flags.
* path.h (PATH_TEXT): New enum.
(path_conv::binmode): Return appropriate constant based on binmode.
* pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
* syscalls.cc (setmode_helper): Make debugging message a little clearer.
(setmode): Set binmode via set_flags.
This commit is contained in:
Christopher Faylor
2002-06-05 01:42:28 +00:00
parent 915d66ce9e
commit e35f391fa5
33 changed files with 157 additions and 146 deletions

View File

@ -52,7 +52,6 @@ details. */
#include <stdlib.h>
#include <sys/mount.h>
#include <mntent.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
@ -803,7 +802,7 @@ out:
if (saw_symlinks)
set_has_symlinks ();
if (!error && !(path_flags & PATH_ALL_EXEC))
if (!error && !isdir () && !(path_flags & PATH_ALL_EXEC))
{
const char *p = strchr (path, '\0') - 4;
if (p >= path &&
@ -1342,6 +1341,14 @@ mount_info::init ()
from_registry ();
}
static void
set_flags (unsigned *flags, unsigned val)
{
*flags = val;
if (!(*flags & PATH_BINARY))
*flags = PATH_TEXT;
}
/* conv_to_win32_path: Ensure src_path is a pure Win32 path and store
the result in win32_path.
@ -1404,7 +1411,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
return rc;
}
*flags = set_flags_from_win32_path (dst);
set_flags (flags, (unsigned) set_flags_from_win32_path (dst));
goto out;
}
@ -1433,7 +1440,6 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
if (rc)
{
debug_printf ("%d = conv_to_win32_path (%s)", rc, src_path);
*flags = 0;
return rc;
}
}
@ -1468,7 +1474,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
}
else if (cygdrive_win32_path (pathbuf, dst, unit))
{
*flags = cygdrive_flags;
set_flags (flags, (unsigned) cygdrive_flags);
goto out;
}
else if (mount_table->cygdrive_len > 1)
@ -1506,10 +1512,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
}
if (i >= nmounts)
{
backslashify (pathbuf, dst, 0); /* just convert */
*flags = PATH_BINARY; /* Default to binmode */
}
backslashify (pathbuf, dst, 0); /* just convert */
else
{
int n;
@ -1538,7 +1541,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
dst[n++] = '\\';
strcpy (dst + n, p);
backslashify (dst, dst, 0);
*flags = mi->flags;
set_flags (flags, (unsigned) mi->flags);
}
if (!isvirtual_dev (devn))