diff options
| author | Paul Eggert | 2014-07-14 12:23:18 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-07-14 12:23:18 -0700 |
| commit | ba1ed52f0c2c7fd15fe1feadabfd0af88e19b4c3 (patch) | |
| tree | 5ef95ac07de2a856369957a7ac047b9f58b78594 /lib-src/hexl.c | |
| parent | 091adafaac52ff409790728af63cab19bd52fc8f (diff) | |
| download | emacs-ba1ed52f0c2c7fd15fe1feadabfd0af88e19b4c3.tar.gz emacs-ba1ed52f0c2c7fd15fe1feadabfd0af88e19b4c3.zip | |
Use binary-io module, O_BINARY, and "b" flag.
* admin/merge-gnulib (GNULIB_MODULES): Add binary-io. It was already
present implicitly; this just makes the dependence explicit.
* lib-src/etags.c, lib-src/hexl.c, lib-src/make-docfile.c:
Include binary-io.h instead of fcntl.h and/or io.h.
(main): Use set_binary_mode or SET_BINARY
in place of handcrafted code.
* lib-src/etags.c (main) [DOS_NT]:
* lib-src/movemail.c (main) [WINDOWSNT]:
Don't mess with _fmode.
* lib-src/etags.c (main, process_file_name, analyse_regex):
Use fopen/popen's "b" flag instead.
* lib-src/movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY
instead.
* src/callproc.c (create_temp_file): Use mkostemp's O_BINARY flag.
* src/emacs.c [MSDOS]:
* src/emacs.c (main) [DOS_NT]: Don't mess with _fmode.
(main) [MSDOS]: Use SET_BINARY instead of setmode.
* src/minibuf.c: Include binary-io.h instead of fcntl.h.
(read_minibuf_noninteractive):
Use set_binary_mode instead of handcrafted code.
Don't call emacs_set_tty if emacs_get_tty failed.
* src/sysdep.c, src/systty.h (emacs_get_tty): Return int, not void.
* src/sysdep.c (emacs_open, emacs_pipe): Use O_BINARY.
* src/w32.c (pipe2): Adjust eassert to include O_BINARY.
Fixes: debbugs:18006
Diffstat (limited to 'lib-src/hexl.c')
| -rw-r--r-- | lib-src/hexl.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/lib-src/hexl.c b/lib-src/hexl.c index 9e21ddf9de6..51744ab08a2 100644 --- a/lib-src/hexl.c +++ b/lib-src/hexl.c | |||
| @@ -24,15 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | 24 | ||
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <ctype.h> | 26 | #include <ctype.h> |
| 27 | #ifdef DOS_NT | 27 | |
| 28 | #include <fcntl.h> | 28 | #include <binary-io.h> |
| 29 | #if __DJGPP__ >= 2 | ||
| 30 | #include <io.h> | ||
| 31 | #endif | ||
| 32 | #endif | ||
| 33 | #ifdef WINDOWSNT | ||
| 34 | #include <io.h> | ||
| 35 | #endif | ||
| 36 | 29 | ||
| 37 | #define DEFAULT_GROUPING 0x01 | 30 | #define DEFAULT_GROUPING 0x01 |
| 38 | #define DEFAULT_BASE 16 | 31 | #define DEFAULT_BASE 16 |
| @@ -155,20 +148,12 @@ main (int argc, char **argv) | |||
| 155 | 148 | ||
| 156 | if (un_flag) | 149 | if (un_flag) |
| 157 | { | 150 | { |
| 158 | char buf[18]; | 151 | SET_BINARY (fileno (stdout)); |
| 159 | 152 | ||
| 160 | #ifdef DOS_NT | ||
| 161 | #if (__DJGPP__ >= 2) || (defined WINDOWSNT) | ||
| 162 | if (!isatty (fileno (stdout))) | ||
| 163 | setmode (fileno (stdout), O_BINARY); | ||
| 164 | #else | ||
| 165 | (stdout)->_flag &= ~_IOTEXT; /* print binary */ | ||
| 166 | _setmode (fileno (stdout), O_BINARY); | ||
| 167 | #endif | ||
| 168 | #endif | ||
| 169 | for (;;) | 153 | for (;;) |
| 170 | { | 154 | { |
| 171 | register int i, c = 0, d; | 155 | int i, c = 0, d; |
| 156 | char buf[18]; | ||
| 172 | 157 | ||
| 173 | #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) | 158 | #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) |
| 174 | 159 | ||
| @@ -210,15 +195,7 @@ main (int argc, char **argv) | |||
| 210 | } | 195 | } |
| 211 | else | 196 | else |
| 212 | { | 197 | { |
| 213 | #ifdef DOS_NT | 198 | SET_BINARY (fileno (fp)); |
| 214 | #if (__DJGPP__ >= 2) || (defined WINDOWSNT) | ||
| 215 | if (!isatty (fileno (fp))) | ||
| 216 | setmode (fileno (fp), O_BINARY); | ||
| 217 | #else | ||
| 218 | (fp)->_flag &= ~_IOTEXT; /* read binary */ | ||
| 219 | _setmode (fileno (fp), O_BINARY); | ||
| 220 | #endif | ||
| 221 | #endif | ||
| 222 | address = 0; | 199 | address = 0; |
| 223 | string[0] = ' '; | 200 | string[0] = ' '; |
| 224 | string[17] = '\0'; | 201 | string[17] = '\0'; |