From: Robert Pluim Date: Thu, 2 Apr 2020 15:52:01 +0000 (+0200) Subject: Make make-{network,serial}-process handle :coding nil consistently X-Git-Tag: emacs-28.0.90~7667 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d08e81ce5a19a0394c2efbdfeb4ebb246d609635;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index 91729e4aaec..fa333640548 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/src/process.c b/src/process.c index 07881d6c5d3..e6d18fbaad2 100644 --- a/src/process.c +++ b/src/process.c @@ -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); } diff --git a/test/lisp/net/network-stream-tests.el b/test/lisp/net/network-stream-tests.el index 28686547a44..7a982548ae1 100644 --- a/test/lisp/net/network-stream-tests.el +++ b/test/lisp/net/network-stream-tests.el @@ -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