From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 18006@debbugs.gnu.org
Subject: bug#18006: Simplify via set_binary_mode
Date: Mon, 14 Jul 2014 13:16:06 -0700 [thread overview]
Message-ID: <53C43A86.4070303@cs.ucla.edu> (raw)
In-Reply-To: <83pph87ype.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
Eli Zaretskii wrote:
> Otherwise, the patch looks good to me.
Thanks; I installed it after fixing things up as per your comments.
Your explanation of _fmode led me to find a minor porting bug.
Fx_load_color_file [!HAVE_X_WINDOWS] uses fopen with "rt"; unlike "rb"
this isn't specified by POSIX and a web search suggests that it does
fail on a few older platforms. Emacs no longer modifies _fmode so "r"
should suffice now anyway. Also, there are two other places where some
"rt"-related simplifications can be done. Proposed further patch attached.
[-- Attachment #2: binary-io.patch --]
[-- Type: text/plain, Size: 3239 bytes --]
=== modified file 'lib-src/ChangeLog'
--- lib-src/ChangeLog 2014-07-14 19:23:18 +0000
+++ lib-src/ChangeLog 2014-07-14 19:46:54 +0000
@@ -1,5 +1,9 @@
2014-07-14 Paul Eggert <eggert@cs.ucla.edu>
+ Use "b" flag more consistently; avoid "t" (Bug#18006).
+ * make-docfile.c (READ_TEXT): Remove; all uses replaced by "r".
+ (READ_BINARY): Remove; all uses replaced by "rb".
+
Use binary-io module, O_BINARY, and "b" flag (Bug#18006).
* etags.c, hexl.c, make-docfile.c:
Include binary-io.h instead of fcntl.h and/or io.h.
=== modified file 'lib-src/make-docfile.c'
--- lib-src/make-docfile.c 2014-07-14 19:23:18 +0000
+++ lib-src/make-docfile.c 2014-07-14 19:46:54 +0000
@@ -55,12 +55,8 @@
Similarly, msdos defines this as sys_chdir, but we're not linking with the
file where that function is defined. */
#undef chdir
-#define READ_TEXT "rt"
-#define READ_BINARY "rb"
#define IS_SLASH(c) ((c) == '/' || (c) == '\\' || (c) == ':')
#else /* not DOS_NT */
-#define READ_TEXT "r"
-#define READ_BINARY "r"
#define IS_SLASH(c) ((c) == '/')
#endif /* not DOS_NT */
@@ -216,11 +212,11 @@
if (!generate_globals)
put_filename (filename);
if (len > 4 && !strcmp (filename + len - 4, ".elc"))
- return scan_lisp_file (filename, READ_BINARY);
+ return scan_lisp_file (filename, "rb");
else if (len > 3 && !strcmp (filename + len - 3, ".el"))
- return scan_lisp_file (filename, READ_TEXT);
+ return scan_lisp_file (filename, "r");
else
- return scan_c_file (filename, READ_TEXT);
+ return scan_c_file (filename, "r");
}
static void
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2014-07-14 19:23:18 +0000
+++ src/ChangeLog 2014-07-14 19:46:54 +0000
@@ -1,5 +1,10 @@
2014-07-14 Paul Eggert <eggert@cs.ucla.edu>
+ Use "b" flag more consistently; avoid "t" (Bug#18006).
+ * lread.c (Fload) [DOS_NT]:
+ * xfaces.c (Fx_load_color_file) [!HAVE_X_WINDOWS]:
+ No longer need to use "rt" instead of "r".
+
Use binary-io module, O_BINARY, and "b" flag (Bug#18006).
* callproc.c (create_temp_file): Use mkostemp's O_BINARY flag.
* emacs.c [MSDOS]:
=== modified file 'src/lread.c'
--- src/lread.c 2014-07-02 03:26:19 +0000
+++ src/lread.c 2014-07-14 19:46:54 +0000
@@ -1061,10 +1061,6 @@
const char *fmode = "r";
int version;
-#ifdef DOS_NT
- fmode = "rt";
-#endif /* DOS_NT */
-
CHECK_STRING (file);
/* If file name is magic, call the handler. */
@@ -1169,7 +1165,7 @@
Tramp does not catch `load' operations for such files, so we
end up with a nil as the `load' handler above. If we would
continue with fd = -2, we will behave wrongly, and in
- particular try reading a .elc file in the "rt" mode instead
+ particular try reading a .elc file in the "r" mode instead
of "rb". See bug #9311 for the results. To work around
this, we try to open the file locally, and go with that if it
succeeds. */
=== modified file 'src/xfaces.c'
--- src/xfaces.c 2014-07-07 23:33:05 +0000
+++ src/xfaces.c 2014-07-14 19:46:54 +0000
@@ -6256,7 +6256,7 @@
abspath = Fexpand_file_name (filename, Qnil);
block_input ();
- fp = emacs_fopen (SSDATA (abspath), "rt");
+ fp = emacs_fopen (SSDATA (abspath), "r");
if (fp)
{
char buf[512];
next prev parent reply other threads:[~2014-07-14 20:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-12 20:52 bug#18006: Simplify via set_binary_mode Paul Eggert
2014-07-13 4:20 ` Eli Zaretskii
2014-07-13 5:28 ` Paul Eggert
2014-07-13 15:02 ` Eli Zaretskii
2014-07-14 2:11 ` Paul Eggert
2014-07-14 15:21 ` Eli Zaretskii
2014-07-14 20:16 ` Paul Eggert [this message]
2014-07-15 14:37 ` Eli Zaretskii
2014-07-15 19:39 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53C43A86.4070303@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=18006@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.