From: Paul Eggert Date: Fri, 20 Feb 2015 03:20:35 +0000 (-0800) Subject: Simplify binary I/O configuration X-Git-Tag: emacs-25.0.90~2564^2~342 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3bbf5170722d9e555307259763623c74240a2555;p=emacs.git Simplify binary I/O configuration * lib-src/etags.c: Include rather than . (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 . (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. --- diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 05511164706..4ac9638102f 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,10 @@ +2015-02-20 Paul Eggert + + Simplify binary I/O configuration + * etags.c: Include rather than . + (process_file_name, analyze_regex): Use FOPEN_BINARY rather than + hard-coded "b". + 2015-02-19 Eli Zaretskii * etags.c (process_file_name) [!DOS_NT]: Use "r", not "rb" in the diff --git a/lib-src/etags.c b/lib-src/etags.c index cdac9289230..7f1875547cf 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -122,7 +122,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; #include #include #include -#include +#include #include #include #include @@ -1532,18 +1532,11 @@ process_file_name (char *file, language *lang) if (real_name == compressed_name) { char *cmd = concat (compr->command, " ", real_name); - - /* Unix implementations of 'popen' generally don't support "rb", whereas - DOS_NT needs it. */ -#ifdef DOS_NT - inf = popen (cmd, "rb"); -#else - inf = popen (cmd, "r"); -#endif + inf = popen (cmd, "r" FOPEN_BINARY); free (cmd); } else - inf = fopen (real_name, "rb"); + inf = fopen (real_name, "r" FOPEN_BINARY); if (inf == NULL) { perror (real_name); @@ -5607,7 +5600,7 @@ analyze_regex (char *regex_arg) char *regexfile = regex_arg + 1; /* regexfile is a file containing regexps, one per line. */ - regexfp = fopen (regexfile, "rb"); + regexfp = fopen (regexfile, "r" FOPEN_BINARY); if (regexfp == NULL) pfatal (regexfile); linebuffer_init (®exbuf); 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 + + Simplify binary I/O configuration + * lread.c (Fload): Prefer FOPEN_TEXT and FOPEN_BINARY to #ifdef DOS_NT. + * sysstdio.h: Add copyright notice. Include . + (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 * 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 . */ + +#include #include + 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];