2017-02-23 17:14:06 +00:00
|
|
|
/* Binary mode I/O.
|
2024-01-02 01:47:10 +00:00
|
|
|
Copyright 2017-2024 Free Software Foundation, Inc.
|
2017-02-23 17:14:06 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
This file is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
License, or (at your option) any later version.
|
2017-02-23 17:14:06 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
This file is distributed in the hope that it will be useful,
|
2017-02-23 17:14:06 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
GNU Lesser General Public License for more details.
|
2017-02-23 17:14:06 +00:00
|
|
|
|
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'.
* .gitignore: Add lib/malloc/*.gl.h.
* admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h
directly from Gnulib, without worrying about Gnulib modules,
as these files are special cases.
(AVOIDED_MODULES): Remove malloc-posix.
* lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4:
* m4/year2038.m4: New files, copied from Gnulib.
* lib/malloca.c, lib/malloca.h:
* m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4:
Remove. These are either no longer present in Gnulib, or are no
longer needed by modules that Emacs uses.
* oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first;
needed for new Gnulib.
* src/xmenu.c: Call emacs_abort, not abort.
2021-10-04 19:11:39 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2017-09-13 09:07:03 +00:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
2017-02-23 17:14:06 +00:00
|
|
|
|
2013-07-09 17:16:21 +00:00
|
|
|
#include <config.h>
|
2017-02-23 17:14:06 +00:00
|
|
|
|
2013-07-09 17:16:21 +00:00
|
|
|
#define BINARY_IO_INLINE _GL_EXTERN_INLINE
|
|
|
|
#include "binary-io.h"
|
2017-02-23 17:14:06 +00:00
|
|
|
|
|
|
|
#if defined __DJGPP__ || defined __EMX__
|
|
|
|
# include <unistd.h>
|
|
|
|
|
|
|
|
int
|
2019-06-06 15:56:03 +00:00
|
|
|
set_binary_mode (int fd, int mode)
|
2017-02-23 17:14:06 +00:00
|
|
|
{
|
|
|
|
if (isatty (fd))
|
2019-06-06 15:56:03 +00:00
|
|
|
/* If FD refers to a console (not a pipe, not a regular file),
|
|
|
|
O_TEXT is the only reasonable mode, both on input and on output.
|
|
|
|
Silently ignore the request. If we were to return -1 here,
|
|
|
|
all programs that use xset_binary_mode would fail when run
|
|
|
|
with console input or console output. */
|
|
|
|
return O_TEXT;
|
2017-02-23 17:14:06 +00:00
|
|
|
else
|
2019-06-06 15:56:03 +00:00
|
|
|
return __gl_setmode (fd, mode);
|
2017-02-23 17:14:06 +00:00
|
|
|
}
|
2019-06-06 15:56:03 +00:00
|
|
|
|
2017-02-23 17:14:06 +00:00
|
|
|
#endif
|