aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-02-19 19:20:35 -0800
committerPaul Eggert2015-02-19 19:21:32 -0800
commit3bbf5170722d9e555307259763623c74240a2555 (patch)
tree853912d230255ec479567a7feb0cb9d0506e9de4 /src
parent12ab9571935d79c69ffab0fb1ea3f6e20f475860 (diff)
downloademacs-3bbf5170722d9e555307259763623c74240a2555.tar.gz
emacs-3bbf5170722d9e555307259763623c74240a2555.zip
Simplify binary I/O configuration
* lib-src/etags.c: Include <sysstdio.h> rather than <stdio.h>. (process_file_name, analyze_regex): Use FOPEN_BINARY rather than hard-coded "b". * src/lread.c (Fload): Prefer FOPEN_TEXT and FOPEN_BINARY to #ifdef DOS_NT. * src/sysstdio.h: Add copyright notice. Include <fcntl.h>. (FOPEN_BINARY, FOPEN_TEXT): New macros. * src/xfaces.c (Fx_load_color_file): Use FOPEN_TEXT, since POSIX doesn't guarantee that "t" will work.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/lread.c11
-rw-r--r--src/sysstdio.h29
-rw-r--r--src/xfaces.c2
4 files changed, 41 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 38af1d83a6d..1126dde7450 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12015-02-20 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify binary I/O configuration
4 * lread.c (Fload): Prefer FOPEN_TEXT and FOPEN_BINARY to #ifdef DOS_NT.
5 * sysstdio.h: Add copyright notice. Include <fcntl.h>.
6 (FOPEN_BINARY, FOPEN_TEXT): New macros.
7 * xfaces.c (Fx_load_color_file): Use FOPEN_TEXT, since POSIX
8 doesn't guarantee that "t" will work.
9
12015-02-19 Eli Zaretskii <eliz@gnu.org> 102015-02-19 Eli Zaretskii <eliz@gnu.org>
2 11
3 * keyboard.c (read_char): Make sure this_single_command_key_start 12 * keyboard.c (read_char): Make sure this_single_command_key_start
diff --git a/src/lread.c b/src/lread.c
index b42849fc414..ae175296ddb 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1033,13 +1033,9 @@ Return t if the file exists and loads successfully. */)
1033 bool compiled = 0; 1033 bool compiled = 0;
1034 Lisp_Object handler; 1034 Lisp_Object handler;
1035 bool safe_p = 1; 1035 bool safe_p = 1;
1036 const char *fmode = "r"; 1036 const char *fmode = "r" FOPEN_TEXT;
1037 int version; 1037 int version;
1038 1038
1039#ifdef DOS_NT
1040 fmode = "rt";
1041#endif /* DOS_NT */
1042
1043 CHECK_STRING (file); 1039 CHECK_STRING (file);
1044 1040
1045 /* If file name is magic, call the handler. */ 1041 /* If file name is magic, call the handler. */
@@ -1223,10 +1219,7 @@ Return t if the file exists and loads successfully. */)
1223 compiled = 1; 1219 compiled = 1;
1224 1220
1225 efound = ENCODE_FILE (found); 1221 efound = ENCODE_FILE (found);
1226 1222 fmode = "r" FOPEN_BINARY;
1227#ifdef DOS_NT
1228 fmode = "rb";
1229#endif /* DOS_NT */
1230 1223
1231 /* openp already checked for newness, no point doing it again. 1224 /* openp already checked for newness, no point doing it again.
1232 FIXME would be nice to get a message when openp 1225 FIXME would be nice to get a message when openp
diff --git a/src/sysstdio.h b/src/sysstdio.h
index e9dfb696059..c97c4f883fc 100644
--- a/src/sysstdio.h
+++ b/src/sysstdio.h
@@ -1,2 +1,31 @@
1/* Standard I/O for Emacs.
2
3Copyright 2013-2015 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#include <fcntl.h>
1#include <stdio.h> 21#include <stdio.h>
22
2extern FILE *emacs_fopen (char const *, char const *); 23extern FILE *emacs_fopen (char const *, char const *);
24
25#if O_BINARY
26# define FOPEN_BINARY "b"
27# define FOPEN_TEXT "t"
28#else
29# define FOPEN_BINARY ""
30# define FOPEN_TEXT ""
31#endif
diff --git a/src/xfaces.c b/src/xfaces.c
index d0fe8726cbb..fcfdbc0ee4f 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -6187,7 +6187,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6187 abspath = Fexpand_file_name (filename, Qnil); 6187 abspath = Fexpand_file_name (filename, Qnil);
6188 6188
6189 block_input (); 6189 block_input ();
6190 fp = emacs_fopen (SSDATA (abspath), "rt"); 6190 fp = emacs_fopen (SSDATA (abspath), "r" FOPEN_TEXT);
6191 if (fp) 6191 if (fp)
6192 { 6192 {
6193 char buf[512]; 6193 char buf[512];