diff options
| author | Paul Eggert | 2016-04-14 09:47:18 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-14 09:48:36 -0700 |
| commit | c2ce5476dcde1ab9a7651a4c8a7b29a398b435ce (patch) | |
| tree | 5efd7c2437eb94e2878c312c59b7ba4e5d8c75c3 /src | |
| parent | 177d40de6bddf26c28f065927cd439281e56b325 (diff) | |
| download | emacs-c2ce5476dcde1ab9a7651a4c8a7b29a398b435ce.tar.gz emacs-c2ce5476dcde1ab9a7651a4c8a7b29a398b435ce.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 3 | ||||
| -rw-r--r-- | src/fileio.c | 4 | ||||
| -rw-r--r-- | src/filelock.c | 2 | ||||
| -rw-r--r-- | src/image.c | 2 | ||||
| -rw-r--r-- | src/lread.c | 3 | ||||
| -rw-r--r-- | src/sysdep.c | 3 | ||||
| -rw-r--r-- | src/unexcw.c | 4 |
7 files changed, 9 insertions, 12 deletions
diff --git a/src/callproc.c b/src/callproc.c index 8578556b695..3a40626de48 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -565,8 +565,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 565 | { | 565 | { |
| 566 | /* Since CRLF is converted to LF within `decode_coding', we | 566 | /* Since CRLF is converted to LF within `decode_coding', we |
| 567 | can always open a file with binary mode. */ | 567 | can always open a file with binary mode. */ |
| 568 | callproc_fd[CALLPROC_PIPEREAD] = emacs_open (tempfile, | 568 | callproc_fd[CALLPROC_PIPEREAD] = emacs_open (tempfile, O_RDONLY, 0); |
| 569 | O_RDONLY | O_BINARY, 0); | ||
| 570 | if (callproc_fd[CALLPROC_PIPEREAD] < 0) | 569 | if (callproc_fd[CALLPROC_PIPEREAD] < 0) |
| 571 | { | 570 | { |
| 572 | int open_errno = errno; | 571 | int open_errno = errno; |
diff --git a/src/fileio.c b/src/fileio.c index 0a14d64456b..78cc66d7a41 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4804,7 +4804,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 4804 | 4804 | ||
| 4805 | encoded_filename = ENCODE_FILE (filename); | 4805 | encoded_filename = ENCODE_FILE (filename); |
| 4806 | fn = SSDATA (encoded_filename); | 4806 | fn = SSDATA (encoded_filename); |
| 4807 | open_flags = O_WRONLY | O_BINARY | O_CREAT; | 4807 | open_flags = O_WRONLY | O_CREAT; |
| 4808 | open_flags |= EQ (mustbenew, Qexcl) ? O_EXCL : !NILP (append) ? 0 : O_TRUNC; | 4808 | open_flags |= EQ (mustbenew, Qexcl) ? O_EXCL : !NILP (append) ? 0 : O_TRUNC; |
| 4809 | if (NUMBERP (append)) | 4809 | if (NUMBERP (append)) |
| 4810 | offset = file_offset (append); | 4810 | offset = file_offset (append); |
| @@ -4923,7 +4923,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 4923 | if (timespec_valid_p (modtime) | 4923 | if (timespec_valid_p (modtime) |
| 4924 | && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) | 4924 | && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) |
| 4925 | { | 4925 | { |
| 4926 | int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0); | 4926 | int desc1 = emacs_open (fn, O_WRONLY, 0); |
| 4927 | if (desc1 >= 0) | 4927 | if (desc1 >= 0) |
| 4928 | { | 4928 | { |
| 4929 | struct stat st1; | 4929 | struct stat st1; |
diff --git a/src/filelock.c b/src/filelock.c index c58484a639b..6db6daa3bba 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -485,7 +485,7 @@ read_lock_data (char *lfname, char lfinfo[MAX_LFINFO + 1]) | |||
| 485 | while ((nbytes = readlinkat (AT_FDCWD, lfname, lfinfo, MAX_LFINFO + 1)) < 0 | 485 | while ((nbytes = readlinkat (AT_FDCWD, lfname, lfinfo, MAX_LFINFO + 1)) < 0 |
| 486 | && errno == EINVAL) | 486 | && errno == EINVAL) |
| 487 | { | 487 | { |
| 488 | int fd = emacs_open (lfname, O_RDONLY | O_BINARY | O_NOFOLLOW, 0); | 488 | int fd = emacs_open (lfname, O_RDONLY | O_NOFOLLOW, 0); |
| 489 | if (0 <= fd) | 489 | if (0 <= fd) |
| 490 | { | 490 | { |
| 491 | /* Use read, not emacs_read, since FD isn't unwind-protected. */ | 491 | /* Use read, not emacs_read, since FD isn't unwind-protected. */ |
diff --git a/src/image.c b/src/image.c index 867450567c2..2a7c2ccc82d 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2300,7 +2300,7 @@ x_find_image_fd (Lisp_Object file, int *pfd) | |||
| 2300 | happens, e.g., under Auto Image File Mode.) 'openp' | 2300 | happens, e.g., under Auto Image File Mode.) 'openp' |
| 2301 | didn't open the file, so we should, because the caller | 2301 | didn't open the file, so we should, because the caller |
| 2302 | expects that. */ | 2302 | expects that. */ |
| 2303 | fd = emacs_open (SSDATA (file_found), O_RDONLY | O_BINARY, 0); | 2303 | fd = emacs_open (SSDATA (file_found), O_RDONLY, 0); |
| 2304 | } | 2304 | } |
| 2305 | } | 2305 | } |
| 2306 | else /* fd < 0, but not -2 */ | 2306 | else /* fd < 0, but not -2 */ |
diff --git a/src/lread.c b/src/lread.c index 91469230b7e..fedfcb807c8 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1578,8 +1578,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1578 | } | 1578 | } |
| 1579 | else | 1579 | else |
| 1580 | { | 1580 | { |
| 1581 | int oflags = O_RDONLY + (NILP (predicate) ? 0 : O_BINARY); | 1581 | fd = emacs_open (pfn, O_RDONLY, 0); |
| 1582 | fd = emacs_open (pfn, oflags, 0); | ||
| 1583 | if (fd < 0) | 1582 | if (fd < 0) |
| 1584 | { | 1583 | { |
| 1585 | if (errno != ENOENT) | 1584 | if (errno != ENOENT) |
diff --git a/src/sysdep.c b/src/sysdep.c index 1e3b9f12128..3faa696d89f 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2148,7 +2148,7 @@ init_random (void) | |||
| 2148 | { | 2148 | { |
| 2149 | bool success = false; | 2149 | bool success = false; |
| 2150 | #ifndef WINDOWSNT | 2150 | #ifndef WINDOWSNT |
| 2151 | int fd = emacs_open ("/dev/urandom", O_RDONLY | O_BINARY, 0); | 2151 | int fd = emacs_open ("/dev/urandom", O_RDONLY, 0); |
| 2152 | if (0 <= fd) | 2152 | if (0 <= fd) |
| 2153 | { | 2153 | { |
| 2154 | success = emacs_read (fd, &v, sizeof v) == sizeof v; | 2154 | success = emacs_read (fd, &v, sizeof v) == sizeof v; |
| @@ -2328,7 +2328,6 @@ emacs_fopen (char const *file, char const *mode) | |||
| 2328 | switch (*m++) | 2328 | switch (*m++) |
| 2329 | { | 2329 | { |
| 2330 | case '+': omode = O_RDWR; break; | 2330 | case '+': omode = O_RDWR; break; |
| 2331 | case 'b': bflag = O_BINARY; break; | ||
| 2332 | case 't': bflag = O_TEXT; break; | 2331 | case 't': bflag = O_TEXT; break; |
| 2333 | default: /* Ignore. */ break; | 2332 | default: /* Ignore. */ break; |
| 2334 | } | 2333 | } |
diff --git a/src/unexcw.c b/src/unexcw.c index 399e2c34dda..ea678dd4c25 100644 --- a/src/unexcw.c +++ b/src/unexcw.c | |||
| @@ -275,9 +275,9 @@ unexec (const char *outfile, const char *infile) | |||
| 275 | infile = add_exe_suffix_if_necessary (infile, infile_buffer); | 275 | infile = add_exe_suffix_if_necessary (infile, infile_buffer); |
| 276 | outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer); | 276 | outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer); |
| 277 | 277 | ||
| 278 | fd_in = emacs_open (infile, O_RDONLY | O_BINARY, 0); | 278 | fd_in = emacs_open (infile, O_RDONLY, 0); |
| 279 | assert (fd_in >= 0); | 279 | assert (fd_in >= 0); |
| 280 | fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755); | 280 | fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT, 0755); |
| 281 | assert (fd_out >= 0); | 281 | assert (fd_out >= 0); |
| 282 | for (;;) | 282 | for (;;) |
| 283 | { | 283 | { |