aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Pluim2020-04-02 17:52:01 +0200
committerRobert Pluim2020-04-03 14:45:49 +0200
commitd08e81ce5a19a0394c2efbdfeb4ebb246d609635 (patch)
tree765bef42ad5bf8278eebb654571f87cbfb4b352f
parent463f635171683ae3b6907f156305f12fc58ca68e (diff)
downloademacs-d08e81ce5a19a0394c2efbdfeb4ebb246d609635.tar.gz
emacs-d08e81ce5a19a0394c2efbdfeb4ebb246d609635.zip
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.
-rw-r--r--etc/NEWS10
-rw-r--r--src/process.c16
-rw-r--r--test/lisp/net/network-stream-tests.el52
3 files changed, 68 insertions, 10 deletions
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.
317** 'parse-time-string' can now parse ISO 8601 format strings, 317** 'parse-time-string' can now parse ISO 8601 format strings,
318such as "2020-01-15T16:12:21-08:00". 318such as "2020-01-15T16:12:21-08:00".
319 319
320---
321** 'make-network-process', 'make-serial-process' :coding behavior change.
322Previously, passing ":coding nil" to either of these functions would
323override any non-nil binding for 'coding-system-for-read' and
324'coding-system-for-write'. For consistency with 'make-process' and
325'make-pipe-process', passing ":coding nil" is now ignored. No code in
326Emacs depended on the previous behavior; if you really want the
327process' coding-system to be nil, use 'set-process-coding-system'
328after the process has been created, or pass in ":coding '(nil nil)".
329
320 330
321* Changes in Emacs 28.1 on Non-Free Operating Systems 331* Changes in Emacs 28.1 on Non-Free Operating Systems
322 332
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) */)
3188 BUF_ZV_BYTE (XBUFFER (buffer))); 3188 BUF_ZV_BYTE (XBUFFER (buffer)));
3189 } 3189 }
3190 3190
3191 tem = Fplist_member (contact, QCcoding); 3191 tem = Fplist_get (contact, QCcoding);
3192 if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem))))
3193 tem = Qnil;
3194 3192
3195 val = Qnil; 3193 val = Qnil;
3196 if (!NILP (tem)) 3194 if (!NILP (tem))
3197 { 3195 {
3198 val = XCAR (XCDR (tem)); 3196 val = tem;
3199 if (CONSP (val)) 3197 if (CONSP (val))
3200 val = XCAR (val); 3198 val = XCAR (val);
3201 } 3199 }
@@ -3209,7 +3207,7 @@ usage: (make-serial-process &rest ARGS) */)
3209 val = Qnil; 3207 val = Qnil;
3210 if (!NILP (tem)) 3208 if (!NILP (tem))
3211 { 3209 {
3212 val = XCAR (XCDR (tem)); 3210 val = tem;
3213 if (CONSP (val)) 3211 if (CONSP (val))
3214 val = XCDR (val); 3212 val = XCDR (val);
3215 } 3213 }
@@ -3244,16 +3242,14 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
3244 Lisp_Object coding_systems = Qt; 3242 Lisp_Object coding_systems = Qt;
3245 Lisp_Object val; 3243 Lisp_Object val;
3246 3244
3247 tem = Fplist_member (contact, QCcoding); 3245 tem = Fplist_get (contact, QCcoding);
3248 if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem))))
3249 tem = Qnil; /* No error message (too late!). */
3250 3246
3251 /* Setup coding systems for communicating with the network stream. */ 3247 /* Setup coding systems for communicating with the network stream. */
3252 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ 3248 /* Qt denotes we have not yet called Ffind_operation_coding_system. */
3253 3249
3254 if (!NILP (tem)) 3250 if (!NILP (tem))
3255 { 3251 {
3256 val = XCAR (XCDR (tem)); 3252 val = tem;
3257 if (CONSP (val)) 3253 if (CONSP (val))
3258 val = XCAR (val); 3254 val = XCAR (val);
3259 } 3255 }
@@ -3287,7 +3283,7 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
3287 3283
3288 if (!NILP (tem)) 3284 if (!NILP (tem))
3289 { 3285 {
3290 val = XCAR (XCDR (tem)); 3286 val = tem;
3291 if (CONSP (val)) 3287 if (CONSP (val))
3292 val = XCDR (val); 3288 val = XCDR (val);
3293 } 3289 }
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 @@
724 44777 724 44777
725 (vector :nowait t)))) 725 (vector :nowait t))))
726 726
727(ert-deftest check-network-process-coding-system-bind ()
728 "Check that binding coding-system-for-{read,write} works."
729 (let* ((coding-system-for-read 'binary)
730 (coding-system-for-write 'utf-8-unix)
731 (server
732 (make-network-process
733 :name "server"
734 :server t
735 :noquery t
736 :family 'ipv4
737 :service t
738 :host 'local))
739 (coding (process-coding-system server)))
740 (should (eq (car coding) 'binary))
741 (should (eq (cdr coding) 'utf-8-unix))
742 (delete-process server)))
743
744(ert-deftest check-network-process-coding-system-no-override ()
745 "Check that coding-system-for-{read,write} is not overridden by :coding nil."
746 (let* ((coding-system-for-read 'binary)
747 (coding-system-for-write 'utf-8-unix)
748 (server
749 (make-network-process
750 :name "server"
751 :server t
752 :noquery t
753 :family 'ipv4
754 :service t
755 :coding nil
756 :host 'local))
757 (coding (process-coding-system server)))
758 (should (eq (car coding) 'binary))
759 (should (eq (cdr coding) 'utf-8-unix))
760 (delete-process server)))
761
762(ert-deftest check-network-process-coding-system-override ()
763 "Check that :coding non-nil overrides coding-system-for-{read,write}."
764 (let* ((coding-system-for-read 'binary)
765 (coding-system-for-write 'utf-8-unix)
766 (server
767 (make-network-process
768 :name "server"
769 :server t
770 :noquery t
771 :family 'ipv4
772 :service t
773 :coding 'georgian-academy
774 :host 'local))
775 (coding (process-coding-system server)))
776 (should (eq (car coding) 'georgian-academy))
777 (should (eq (cdr coding) 'georgian-academy))
778 (delete-process server)))
727;;; network-stream-tests.el ends here 779;;; network-stream-tests.el ends here