Make make-{network,serial}-process handle :coding nil consistently

The handling of :coding nil was different between
make-{network,serial}-process and make-{pipe}process.  Now they all
handle :coding nil as if :coding had not been specified.

* process.c (Fmake_serial_process)
(set_network_socket_coding_system): Use plist-get to check if
:coding has been specified instead of plist-member, to ensure that
":coding nil" does not override coding-system-for-{read,write}.

* network-stream-tests.el (check-network-process-coding-system-bind)
(check-network-process-coding-system-no-override)
(check-network-process-coding-system-override): New tests.

* etc/NEWS: Describe change in make-network-process and
make-serial-process :coding behavior.
This commit is contained in:
Robert Pluim 2020-04-02 17:52:01 +02:00
parent 463f635171
commit d08e81ce5a
3 changed files with 68 additions and 10 deletions

View file

@ -317,6 +317,16 @@ optional argument specifying whether to follow symbolic links.
** 'parse-time-string' can now parse ISO 8601 format strings,
such as "2020-01-15T16:12:21-08:00".
---
** 'make-network-process', 'make-serial-process' :coding behavior change.
Previously, passing ":coding nil" to either of these functions would
override any non-nil binding for 'coding-system-for-read' and
'coding-system-for-write'. For consistency with 'make-process' and
'make-pipe-process', passing ":coding nil" is now ignored. No code in
Emacs depended on the previous behavior; if you really want the
process' coding-system to be nil, use 'set-process-coding-system'
after the process has been created, or pass in ":coding '(nil nil)".
* Changes in Emacs 28.1 on Non-Free Operating Systems

View file

@ -3188,14 +3188,12 @@ usage: (make-serial-process &rest ARGS) */)
BUF_ZV_BYTE (XBUFFER (buffer)));
}
tem = Fplist_member (contact, QCcoding);
if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem))))
tem = Qnil;
tem = Fplist_get (contact, QCcoding);
val = Qnil;
if (!NILP (tem))
{
val = XCAR (XCDR (tem));
val = tem;
if (CONSP (val))
val = XCAR (val);
}
@ -3209,7 +3207,7 @@ usage: (make-serial-process &rest ARGS) */)
val = Qnil;
if (!NILP (tem))
{
val = XCAR (XCDR (tem));
val = tem;
if (CONSP (val))
val = XCDR (val);
}
@ -3244,16 +3242,14 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
Lisp_Object coding_systems = Qt;
Lisp_Object val;
tem = Fplist_member (contact, QCcoding);
if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem))))
tem = Qnil; /* No error message (too late!). */
tem = Fplist_get (contact, QCcoding);
/* Setup coding systems for communicating with the network stream. */
/* Qt denotes we have not yet called Ffind_operation_coding_system. */
if (!NILP (tem))
{
val = XCAR (XCDR (tem));
val = tem;
if (CONSP (val))
val = XCAR (val);
}
@ -3287,7 +3283,7 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
if (!NILP (tem))
{
val = XCAR (XCDR (tem));
val = tem;
if (CONSP (val))
val = XCDR (val);
}

View file

@ -724,4 +724,56 @@
44777
(vector :nowait t))))
(ert-deftest check-network-process-coding-system-bind ()
"Check that binding coding-system-for-{read,write} works."
(let* ((coding-system-for-read 'binary)
(coding-system-for-write 'utf-8-unix)
(server
(make-network-process
:name "server"
:server t
:noquery t
:family 'ipv4
:service t
:host 'local))
(coding (process-coding-system server)))
(should (eq (car coding) 'binary))
(should (eq (cdr coding) 'utf-8-unix))
(delete-process server)))
(ert-deftest check-network-process-coding-system-no-override ()
"Check that coding-system-for-{read,write} is not overridden by :coding nil."
(let* ((coding-system-for-read 'binary)
(coding-system-for-write 'utf-8-unix)
(server
(make-network-process
:name "server"
:server t
:noquery t
:family 'ipv4
:service t
:coding nil
:host 'local))
(coding (process-coding-system server)))
(should (eq (car coding) 'binary))
(should (eq (cdr coding) 'utf-8-unix))
(delete-process server)))
(ert-deftest check-network-process-coding-system-override ()
"Check that :coding non-nil overrides coding-system-for-{read,write}."
(let* ((coding-system-for-read 'binary)
(coding-system-for-write 'utf-8-unix)
(server
(make-network-process
:name "server"
:server t
:noquery t
:family 'ipv4
:service t
:coding 'georgian-academy
:host 'local))
(coding (process-coding-system server)))
(should (eq (car coding) 'georgian-academy))
(should (eq (cdr coding) 'georgian-academy))
(delete-process server)))
;;; network-stream-tests.el ends here