summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-02-19 19:20:35 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-02-19 19:21:32 -0800
commit3bbf5170722d9e555307259763623c74240a2555 (patch)
tree853912d230255ec479567a7feb0cb9d0506e9de4 /src
parent12ab9571935d79c69ffab0fb1ea3f6e20f475860 (diff)
downloademacs-3bbf5170722d9e555307259763623c74240a2555.tar.gz
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 @@
+2015-02-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ Simplify binary I/O configuration
+ * lread.c (Fload): Prefer FOPEN_TEXT and FOPEN_BINARY to #ifdef DOS_NT.
+ * sysstdio.h: Add copyright notice. Include <fcntl.h>.
+ (FOPEN_BINARY, FOPEN_TEXT): New macros.
+ * xfaces.c (Fx_load_color_file): Use FOPEN_TEXT, since POSIX
+ doesn't guarantee that "t" will work.
+
2015-02-19 Eli Zaretskii <eliz@gnu.org>
* 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. */)
bool compiled = 0;
Lisp_Object handler;
bool safe_p = 1;
- const char *fmode = "r";
+ const char *fmode = "r" FOPEN_TEXT;
int version;
-#ifdef DOS_NT
- fmode = "rt";
-#endif /* DOS_NT */
-
CHECK_STRING (file);
/* If file name is magic, call the handler. */
@@ -1223,10 +1219,7 @@ Return t if the file exists and loads successfully. */)
compiled = 1;
efound = ENCODE_FILE (found);
-
-#ifdef DOS_NT
- fmode = "rb";
-#endif /* DOS_NT */
+ fmode = "r" FOPEN_BINARY;
/* openp already checked for newness, no point doing it again.
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 @@
+/* Standard I/O for Emacs.
+
+Copyright 2013-2015 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <fcntl.h>
#include <stdio.h>
+
extern FILE *emacs_fopen (char const *, char const *);
+
+#if O_BINARY
+# define FOPEN_BINARY "b"
+# define FOPEN_TEXT "t"
+#else
+# define FOPEN_BINARY ""
+# define FOPEN_TEXT ""
+#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. */)
abspath = Fexpand_file_name (filename, Qnil);
block_input ();
- fp = emacs_fopen (SSDATA (abspath), "rt");
+ fp = emacs_fopen (SSDATA (abspath), "r" FOPEN_TEXT);
if (fp)
{
char buf[512];