]> code.delx.au - gnu-emacs/commitdiff
Simplify use of O_BINARY
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 14 Apr 2016 16:47:18 +0000 (09:47 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 14 Apr 2016 16:48:36 +0000 (09:48 -0700)
* 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
src/fileio.c
src/filelock.c
src/image.c
src/lread.c
src/sysdep.c
src/unexcw.c

index 8578556b6955de7bf1dca18a498e59048e5d369e..3a40626de48b49e7a5e8ed88d8190de7703078d7 100644 (file)
@@ -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;
index 0a14d64456bba823f70ed386ffb52c8e88fce429..78cc66d7a41820e55cfdc03b8b27ca4e13a2e548 100644 (file)
@@ -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;
index c58484a639b2cd613524bb28d6b3e32a797c51c4..6db6daa3bba9a7c5bfba88ed3c3cb8a4cf3dedfb 100644 (file)
@@ -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.  */
index 867450567c2953d917a358bd8bdca2fbc45bc1ff..2a7c2ccc82df672c47f597a62d98742b8e1c71ac 100644 (file)
@@ -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 */
index 91469230b7e9910b52e75cf04f2ee5dcb4a4b9cb..fedfcb807c82026d2c510c47085ab97c2661df70 100644 (file)
@@ -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)
index 1e3b9f12128a1f54e30a9c0e3f4f9478b01b4fe3..3faa696d89ff9b391197bc8cf223430052f6d67f 100644 (file)
@@ -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;
       }
index 399e2c34ddad25fda12848f119757cdbef1561d6..ea678dd4c25e792a9c755ab4bd287ef893b56f5a 100644 (file)
@@ -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 (;;)
     {