From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18006: Simplify via set_binary_mode Date: Tue, 15 Jul 2014 17:37:40 +0300 Message-ID: <83egxm8z7v.fsf@gnu.org> References: <53C1A00C.6050906@cs.ucla.edu> <837g3hanzp.fsf@gnu.org> <53C21918.9020001@cs.ucla.edu> <8338e59u9u.fsf@gnu.org> <53C33C6A.6060601@cs.ucla.edu> <83pph87ype.fsf@gnu.org> <53C43A86.4070303@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1405435109 15952 80.91.229.3 (15 Jul 2014 14:38:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jul 2014 14:38:29 +0000 (UTC) Cc: 18006@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 15 16:38:19 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X73s3-0003tB-Iy for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Jul 2014 16:38:19 +0200 Original-Received: from localhost ([::1]:35035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73s3-0006Ki-6k for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Jul 2014 10:38:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73rt-0006Bg-Jc for bug-gnu-emacs@gnu.org; Tue, 15 Jul 2014 10:38:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X73rm-0003N7-Sp for bug-gnu-emacs@gnu.org; Tue, 15 Jul 2014 10:38:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73rm-0003MZ-Q8 for bug-gnu-emacs@gnu.org; Tue, 15 Jul 2014 10:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X73rm-0003qZ-Ec for bug-gnu-emacs@gnu.org; Tue, 15 Jul 2014 10:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Jul 2014 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18006 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18006-submit@debbugs.gnu.org id=B18006.140543506214755 (code B ref 18006); Tue, 15 Jul 2014 14:38:02 +0000 Original-Received: (at 18006) by debbugs.gnu.org; 15 Jul 2014 14:37:42 +0000 Original-Received: from localhost ([127.0.0.1]:55733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X73rO-0003pp-1d for submit@debbugs.gnu.org; Tue, 15 Jul 2014 10:37:41 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:33521) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X73rI-0003pU-NK for 18006@debbugs.gnu.org; Tue, 15 Jul 2014 10:37:36 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0N8R00L00CG9ZY00@a-mtaout23.012.net.il> for 18006@debbugs.gnu.org; Tue, 15 Jul 2014 17:37:26 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N8R00LFPCMDZP10@a-mtaout23.012.net.il>; Tue, 15 Jul 2014 17:37:26 +0300 (IDT) In-reply-to: <53C43A86.4070303@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:91563 Archived-At: > Date: Mon, 14 Jul 2014 13:16:06 -0700 > From: Paul Eggert > CC: 18006@debbugs.gnu.org > > 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. Thanks. The lib-src part looks OK to me. > --- 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 > > + 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". This part doesn't look right. If we don't use "rt", then when emacs_fopen calls emacs_open, the latter will interpret the lack of "t" as a sign to use the default binary mode, which is not what we want. I think we can fix this in one of 2 ways: either (a) let emacs_fopen start with O_TEXT in bmode by default, at least on DOS_NT platforms; or (b) change emacs_open back to not apply O_BINARY by default, and instead use "rb", "wb", and O_BINARY in all the places except those that use "rt" or "wt" now. I like the latter alternative better, because the former makes emacs_fopen and emacs_open use 2 different defaults (text vs binary), which is contrary to intuition and easy to forget. WDYT?