From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#18006: Simplify via set_binary_mode Date: Sat, 12 Jul 2014 22:28:56 -0700 Organization: UCLA Computer Science Department Message-ID: <53C21918.9020001@cs.ucla.edu> References: <53C1A00C.6050906@cs.ucla.edu> <837g3hanzp.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040807030205030802040909" X-Trace: ger.gmane.org 1405229427 5257 80.91.229.3 (13 Jul 2014 05:30:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Jul 2014 05:30:27 +0000 (UTC) Cc: 18006@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 13 07:30: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 1X6CMd-0006P0-Da for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Jul 2014 07:30:19 +0200 Original-Received: from localhost ([::1]:51220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6CMc-000382-OM for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Jul 2014 01:30:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6CMT-00035Y-Cv for bug-gnu-emacs@gnu.org; Sun, 13 Jul 2014 01:30:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6CMN-0003LR-Q2 for bug-gnu-emacs@gnu.org; Sun, 13 Jul 2014 01:30:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6CMN-0003Jw-M8 for bug-gnu-emacs@gnu.org; Sun, 13 Jul 2014 01:30:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X6CMM-0004B9-Rb for bug-gnu-emacs@gnu.org; Sun, 13 Jul 2014 01:30:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Jul 2014 05:30: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.140522935215950 (code B ref 18006); Sun, 13 Jul 2014 05:30:02 +0000 Original-Received: (at 18006) by debbugs.gnu.org; 13 Jul 2014 05:29:12 +0000 Original-Received: from localhost ([127.0.0.1]:53410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X6CLX-00049B-AV for submit@debbugs.gnu.org; Sun, 13 Jul 2014 01:29:12 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:37808) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X6CLT-00048u-GC for 18006@debbugs.gnu.org; Sun, 13 Jul 2014 01:29:09 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 8CEB6A60009; Sat, 12 Jul 2014 22:29:01 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m2qwKBwtDRq8; Sat, 12 Jul 2014 22:28:57 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 1E684A60008; Sat, 12 Jul 2014 22:28:57 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <837g3hanzp.fsf@gnu.org> 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:91490 Archived-At: This is a multi-part message in MIME format. --------------040807030205030802040909 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > . in some places, we want all file I/O to be in binary mode; Gnulib > doesn't support that The Emacs code can continue to use _fmode as before; that part won't be simplified, but one step at a time. > . some of the code needs to switch a file descriptor to binary or > text mode only when the descriptor is or isn't connected to a > terminal device; Gnulib is ambivalent about that (it always does > that for MSDOS, and never for Windows) binary-io has two interfaces; one (set_binary_mode) always does it, on all platforms; the other (SET_BINARY) deliberately has no effect on __DJGPP__ when isatty returns nonzero. Emacs can use either interface, as it needs. Should SET_BINARY also should have no effect on MS-Windows when isatty returns nonzero? If so, I suppose we can change SET_BINARY to do that. > . AFAIK, Gnulib's binary-io also replaces isatty It doesn't, so this shouldn't be a problem. (Emacs already uses binary-io, by the way; if this were a problem I expect we'd already have run into it.) > . we don't want in Emacs the msvc-nothrow wrappers for library > functions binary-io doesn't do that either. >> /* Don't put CRs in the DOC file. */ >> -#ifdef MSDOS >> - _fmode = O_BINARY; >> -#if 0 /* Suspicion is that this causes hanging. >> - So instead we require people to use -o on MSDOS. */ >> - (stdout)->_flag &= ~_IOTEXT; >> - _setmode (fileno (stdout), O_BINARY); >> -#endif >> - outfile = 0; >> -#endif /* MSDOS */ >> -#ifdef WINDOWSNT >> - _fmode = O_BINARY; >> - _setmode (fileno (stdout), O_BINARY); >> -#endif /* WINDOWSNT */ >> + set_binary_mode (fileno (stdout), O_BINARY); > > This is wrong: setting _fmode affects all I/O, input and output, not > just stdout. Gnulib's binary-io doesn't have the equivalent > functionality. If setting _fmode affects all I/O, why does the WINDOWSNT code bother to call _setmode? Conversely, why does make-docfile.c need to set _fmode, if the intent is "Don't put CRs in the DOC file"; shouldn't it suffice to call _setmode on stdout? > This logic is flawed: if emacs_get_tty failed, then emacs_set_tty > should not be called as well. I was just copying the existing logic. But it's easy to fix while we're at it; revised patch attached. > This will not work with Windows isatty, because it doesn't return 1 > when fd is connected to a console. Thanks, I also tried to address that in the attached patch. --------------040807030205030802040909 Content-Type: text/plain; charset=UTF-8; name="binary-io.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="binary-io.patch" PT09IG1vZGlmaWVkIGZpbGUgJ2FkbWluL0NoYW5nZUxvZycKLS0tIGFkbWluL0NoYW5nZUxv ZwkyMDE0LTA2LTMwIDAwOjAxOjUxICswMDAwCisrKyBhZG1pbi9DaGFuZ2VMb2cJMjAxNC0w Ny0xMiAyMDo1Njo1MSArMDAwMApAQCAtMSwzICsxLDkgQEAKKzIwMTQtMDctMTIgIFBhdWwg RWdnZXJ0ICA8ZWdnZXJ0QGNzLnVjbGEuZWR1PgorCisJVXNlIGJpbmFyeS1pbyBtb2R1bGUg KEJ1ZyMxODAwNikuCisJKiBtZXJnZS1nbnVsaWIgKEdOVUxJQl9NT0RVTEVTKTogQWRkIGJp bmFyeS1pby4gIEl0IHdhcyBhbHJlYWR5CisJcHJlc2VudCBpbXBsaWNpdGx5OyB0aGlzIGp1 c3QgbWFrZXMgdGhlIGRlcGVuZGVuY2UgZXhwbGlja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