Commit c2ce5476 authored by Paul Eggert's avatar Paul Eggert

Simplify use of O_BINARY

* src/callproc.c (call_process):
* src/fileio.c (write_region):
* src/filelock.c (read_lock_data):
* src/image.c (x_find_image_fd):
* src/lread.c (openp):
* src/sysdep.c (init_random, emacs_fopen):
* src/unexcw.c (unexec):
Omit unnecessary use of O_BINARY, since emacs_open now arranges
that for us.
parent 177d40de
......@@ -565,8 +565,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
{
/* Since CRLF is converted to LF within `decode_coding', we
can always open a file with binary mode. */
callproc_fd[CALLPROC_PIPEREAD] = emacs_open (tempfile,
O_RDONLY | O_BINARY, 0);
callproc_fd[CALLPROC_PIPEREAD] = emacs_open (tempfile, O_RDONLY, 0);
if (callproc_fd[CALLPROC_PIPEREAD] < 0)
{
int open_errno = errno;
......
......@@ -4804,7 +4804,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
encoded_filename = ENCODE_FILE (filename);
fn = SSDATA (encoded_filename);
open_flags = O_WRONLY | O_BINARY | O_CREAT;
open_flags = O_WRONLY | O_CREAT;
open_flags |= EQ (mustbenew, Qexcl) ? O_EXCL : !NILP (append) ? 0 : O_TRUNC;
if (NUMBERP (append))
offset = file_offset (append);
......@@ -4923,7 +4923,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
if (timespec_valid_p (modtime)
&& ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system))
{
int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0);
int desc1 = emacs_open (fn, O_WRONLY, 0);
if (desc1 >= 0)
{
struct stat st1;
......
......@@ -485,7 +485,7 @@ read_lock_data (char *lfname, char lfinfo[MAX_LFINFO + 1])
while ((nbytes = readlinkat (AT_FDCWD, lfname, lfinfo, MAX_LFINFO + 1)) < 0
&& errno == EINVAL)
{
int fd = emacs_open (lfname, O_RDONLY | O_BINARY | O_NOFOLLOW, 0);
int fd = emacs_open (lfname, O_RDONLY | O_NOFOLLOW, 0);
if (0 <= fd)
{
/* Use read, not emacs_read, since FD isn't unwind-protected. */
......
......@@ -2300,7 +2300,7 @@ x_find_image_fd (Lisp_Object file, int *pfd)
happens, e.g., under Auto Image File Mode.) 'openp'
didn't open the file, so we should, because the caller
expects that. */
fd = emacs_open (SSDATA (file_found), O_RDONLY | O_BINARY, 0);
fd = emacs_open (SSDATA (file_found), O_RDONLY, 0);
}
}
else /* fd < 0, but not -2 */
......
......@@ -1578,8 +1578,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
}
else
{
int oflags = O_RDONLY + (NILP (predicate) ? 0 : O_BINARY);
fd = emacs_open (pfn, oflags, 0);
fd = emacs_open (pfn, O_RDONLY, 0);
if (fd < 0)
{
if (errno != ENOENT)
......
......@@ -2148,7 +2148,7 @@ init_random (void)
{
bool success = false;
#ifndef WINDOWSNT
int fd = emacs_open ("/dev/urandom", O_RDONLY | O_BINARY, 0);
int fd = emacs_open ("/dev/urandom", O_RDONLY, 0);
if (0 <= fd)
{
success = emacs_read (fd, &v, sizeof v) == sizeof v;
......@@ -2328,7 +2328,6 @@ emacs_fopen (char const *file, char const *mode)
switch (*m++)
{
case '+': omode = O_RDWR; break;
case 'b': bflag = O_BINARY; break;
case 't': bflag = O_TEXT; break;
default: /* Ignore. */ break;
}
......
......@@ -275,9 +275,9 @@ unexec (const char *outfile, const char *infile)
infile = add_exe_suffix_if_necessary (infile, infile_buffer);
outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
fd_in = emacs_open (infile, O_RDONLY | O_BINARY, 0);
fd_in = emacs_open (infile, O_RDONLY, 0);
assert (fd_in >= 0);
fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT, 0755);
assert (fd_out >= 0);
for (;;)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment