[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err a
From: |
Bruno Haible |
Subject: |
Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2 |
Date: |
Sat, 25 May 2019 15:41:04 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-145-generic; KDE/5.18.0; x86_64; ; ) |
KO Myung-Hun wrote:
> * lib/binary-io.c (__gl_setmode_check) [__EMX__]: Remove __EMX__ guard.
> * lib/binary-io.h (__gl_setmode_check) [__EMX__]: Remove __EMX__ guard.
> (set_binary_mode) [__EMX__]: Override mode with O_TEXT if tty.
According to the EMX documentation of the setmode function
------------------------------------------------------------------------------
#include <io.h> [PC]
#include <fcntl.h>
int setmode (int handle, int mode);
Change the text/binary mode of a file handle. MODE must be either
O_BINARY or O_TEXT.
Note: Use _fsetmode() to change the mode of a stream.
Return value:
If there's an error, setmode() returns -1 and sets errno to EBADF
or EINVAL otherwise setmode() returns the previous mode, that is,
O_BINARY or O_TEXT.
See also: _fsetmode(), open()
------------------------------------------------------------------------------
your proposed patch has the following effect:
BEFORE:
sets mode to return value
set_binary_mode on tty --- -1, errno=EINVAL
set_binary_mode on regular file fails --- -1, errno=EBADF or
EINVAL
set_binary_mode on regular file succeeds mode previous mode
AFTER:
sets mode to return value
set_binary_mode on tty O_TEXT previous mode
set_binary_mode on regular file fails --- -1, errno=EBADF or
EINVAL
set_binary_mode on regular file succeeds mode previous mode
Changing a function to *silently* do a different thing than what it was
requested to do? This is not good. The previous behaviour, to set an error
indicator, is better.
> Setting stdin/out/err to binary mode is allowed on OS/2. But it's not
> useful, because it generates stair-output hard to read.
On a tty, the existing code will refrain from invoking setmode. So no
stair-output in this case.
On a regular file, it depends on your text viewer. Emacs surely doesn't
produce stair-cased rendering of a file.
> Instead, let's set them to text mode all the time.
>
> This fixes that tee always crashes at startup if stdin or stdout
> are not piped.
1) I don't see why the proposed patch would fix a crash. It only
changes the way output is rendered outside of the program.
2) The proper place to do such changes is the 'tee' program.
Bruno
- [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/24
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/24
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2,
Bruno Haible <=
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/28
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/29
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/29
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/29