aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/fileio.c50
2 files changed, 57 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 898c10a48e1..40d8b267d84 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12015-01-15 Eli Zaretskii <eliz@gnu.org>
2
3 * fileio.c: Include binary-io.h.
4 (Fset_binary_mode): New function.
5 (syms_of_fileio): Defsubr it.
6 (syms_of_fileio) <Qstdin, Qstdout, Qstderr>: DEFSYM them.
7
12015-01-15 Teodor Zlatanov <tzz@lifelogs.com> 82015-01-15 Teodor Zlatanov <tzz@lifelogs.com>
2 9
3 * gnutls.c (init_gnutls_functions): Import gnutls_x509_crt_check_issuer. 10 * gnutls.c (init_gnutls_functions): Import gnutls_x509_crt_check_issuer.
diff --git a/src/fileio.c b/src/fileio.c
index 6c443c91db7..dc67a00ed2a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -86,6 +86,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86#include <careadlinkat.h> 86#include <careadlinkat.h>
87#include <stat-time.h> 87#include <stat-time.h>
88 88
89#include <binary-io.h>
90
89#ifdef HPUX 91#ifdef HPUX
90#include <netio.h> 92#include <netio.h>
91#endif 93#endif
@@ -5754,6 +5756,48 @@ before any other event (mouse or keypress) is handled. */)
5754 return Qnil; 5756 return Qnil;
5755} 5757}
5756 5758
5759
5760DEFUN ("set-binary-mode", Fset_binary_mode, Sset_binary_mode, 2, 2, 0,
5761 doc: /* Switch STREAM to binary I/O mode or text I/O mode.
5762STREAM can be one of the symbols `stdin', `stdout', or `stderr'.
5763If MODE is non-nil, switch STREAM to binary mode, otherwise switch
5764it to text mode.
5765
5766As a side effect, this function flushes any pending STREAM's data.
5767
5768Value is the previous value of STREAM's I/O mode, nil for text mode,
5769non-nil for binary mode.
5770
5771On MS-Windows and MS-DOS, binary mode is needed to read or write
5772arbitrary binary data, and for disabling translation between CR-LF
5773pairs and a single newline character. Examples include generation
5774of text files with Unix-style end-of-line format using `princ' in
5775batch mode, with standard output redirected to a file.
5776
5777On Posix systems, this function always returns non-nil, and has no
5778effect except for flushing STREAM's data. */)
5779 (Lisp_Object stream, Lisp_Object mode)
5780{
5781 FILE *fp = NULL;
5782 int binmode;
5783
5784 CHECK_SYMBOL (stream);
5785 if (EQ (stream, Qstdin))
5786 fp = stdin;
5787 else if (EQ (stream, Qstdout))
5788 fp = stdout;
5789 else if (EQ (stream, Qstderr))
5790 fp = stderr;
5791 else
5792 xsignal2 (Qerror, build_string ("unsupported stream"), stream);
5793
5794 binmode = NILP (mode) ? O_TEXT : O_BINARY;
5795 if (fp != stdin)
5796 fflush (fp);
5797
5798 return (set_binary_mode (fileno (fp), binmode) == O_BINARY) ? Qt : Qnil;
5799}
5800
5757void 5801void
5758init_fileio (void) 5802init_fileio (void)
5759{ 5803{
@@ -6040,6 +6084,10 @@ This includes interactive calls to `delete-file' and
6040 DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); 6084 DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name");
6041 DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); 6085 DEFSYM (Qget_buffer_window_list, "get-buffer-window-list");
6042 6086
6087 DEFSYM (Qstdin, "stdin");
6088 DEFSYM (Qstdout, "stdout");
6089 DEFSYM (Qstderr, "stderr");
6090
6043 defsubr (&Sfind_file_name_handler); 6091 defsubr (&Sfind_file_name_handler);
6044 defsubr (&Sfile_name_directory); 6092 defsubr (&Sfile_name_directory);
6045 defsubr (&Sfile_name_nondirectory); 6093 defsubr (&Sfile_name_nondirectory);
@@ -6089,6 +6137,8 @@ This includes interactive calls to `delete-file' and
6089 6137
6090 defsubr (&Snext_read_file_uses_dialog_p); 6138 defsubr (&Snext_read_file_uses_dialog_p);
6091 6139
6140 defsubr (&Sset_binary_mode);
6141
6092#ifdef HAVE_SYNC 6142#ifdef HAVE_SYNC
6093 defsubr (&Sunix_sync); 6143 defsubr (&Sunix_sync);
6094#endif 6144#endif