emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c2ce547: Simplify use of O_BINARY


From: Paul Eggert
Subject: [Emacs-diffs] master c2ce547: Simplify use of O_BINARY
Date: Thu, 14 Apr 2016 16:48:39 +0000

branch: master
commit c2ce5476dcde1ab9a7651a4c8a7b29a398b435ce
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/callproc.c |    3 +--
 src/fileio.c   |    4 ++--
 src/filelock.c |    2 +-
 src/image.c    |    2 +-
 src/lread.c    |    3 +--
 src/sysdep.c   |    3 +--
 src/unexcw.c   |    4 ++--
 7 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/callproc.c b/src/callproc.c
index 8578556..3a40626 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -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;
diff --git a/src/fileio.c b/src/fileio.c
index 0a14d64..78cc66d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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;
diff --git a/src/filelock.c b/src/filelock.c
index c58484a..6db6daa 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -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.  */
diff --git a/src/image.c b/src/image.c
index 8674505..2a7c2cc 100644
--- a/src/image.c
+++ b/src/image.c
@@ -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 */
diff --git a/src/lread.c b/src/lread.c
index 9146923..fedfcb8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -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)
diff --git a/src/sysdep.c b/src/sysdep.c
index 1e3b9f1..3faa696 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -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;
       }
diff --git a/src/unexcw.c b/src/unexcw.c
index 399e2c3..ea678dd 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -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 (;;)
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]