GNU bug report logs - #18006
Simplify via set_binary_mode

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Sat, 12 Jul 2014 20:54:02 UTC

Severity: wishlist

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 18006 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 18006 <at> debbugs.gnu.org
Subject: Re: bug#18006: Simplify via set_binary_mode
Date: Tue, 15 Jul 2014 17:37:40 +0300
> Date: Mon, 14 Jul 2014 13:16:06 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 18006 <at> 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  <eggert <at> 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".

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?




This bug report was last modified 11 years and 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.