unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48375: coding-system-for-read in net-utils-run-simple is not properly set
@ 2021-05-12  9:39 iquiw
  2021-05-15  8:26 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: iquiw @ 2021-05-12  9:39 UTC (permalink / raw)
  To: 48375

In the following code, `let' binding of `coding-system-for-read'
covers only `erase-buffer' call.

https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375

So it does not affect to executed process and output characters are garbled.
e.g. "M-x ifconfig" on Windows.

`net-utils-run-program' (e.g. "M-x ping") has no problem.

Thanks in advance,
Iku





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48375: coding-system-for-read in net-utils-run-simple is not properly set
  2021-05-12  9:39 bug#48375: coding-system-for-read in net-utils-run-simple is not properly set iquiw
@ 2021-05-15  8:26 ` Eli Zaretskii
  2021-05-15  9:32   ` iquiw
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2021-05-15  8:26 UTC (permalink / raw)
  To: iquiw; +Cc: 48375

> From: iquiw <iku.iwasa@gmail.com>
> Date: Wed, 12 May 2021 18:39:25 +0900
> 
> In the following code, `let' binding of `coding-system-for-read'
> covers only `erase-buffer' call.
> 
> https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> 
> So it does not affect to executed process and output characters are garbled.
> e.g. "M-x ifconfig" on Windows.

Thanks.  Does the patch below fix the problem?

diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index 24f2aba..90cca7d 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -363,24 +363,24 @@ net-utils-run-simple
       (when proc
         (set-process-filter proc nil)
         (delete-process proc)))
-    (let ((inhibit-read-only t)
-	(coding-system-for-read
-	 ;; MS-Windows versions of network utilities output text
-	 ;; encoded in the console (a.k.a. "OEM") codepage, which is
-	 ;; different from the default system (a.k.a. "ANSI")
-	 ;; codepage.
-	 (if (eq system-type 'windows-nt)
-	     (intern (format "cp%d" (w32-get-console-output-codepage)))
-	   coding-system-for-read)))
+    (let ((inhibit-read-only t))
       (erase-buffer))
     (net-utils-mode)
     (setq-local net-utils--revert-cmd
                 `(net-utils-run-simple ,(current-buffer)
                                        ,program-name ,args nodisplay))
-    (set-process-filter
-     (apply #'start-process program-name
-            (current-buffer) program-name args)
-     #'net-utils-remove-ctrl-m-filter)
+    (let ((coding-system-for-read
+	   ;; MS-Windows versions of network utilities output text
+	   ;; encoded in the console (a.k.a. "OEM") codepage, which is
+	   ;; different from the default system (a.k.a. "ANSI")
+	   ;; codepage.
+	   (if (eq system-type 'windows-nt)
+	       (intern (format "cp%d" (w32-get-console-output-codepage)))
+	     coding-system-for-read)))
+      (set-process-filter
+       (apply #'start-process program-name
+              (current-buffer) program-name args)
+       #'net-utils-remove-ctrl-m-filter))
     (unless nodisplay (display-buffer (current-buffer)))))
 
 (defun net-utils--revert-function (&optional _ignore-auto _noconfirm)





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#48375: coding-system-for-read in net-utils-run-simple is not properly set
  2021-05-15  8:26 ` Eli Zaretskii
@ 2021-05-15  9:32   ` iquiw
  2021-05-15  9:39     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: iquiw @ 2021-05-15  9:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 48375

On Sat, May 15, 2021 at 5:26 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: iquiw <iku.iwasa@gmail.com>
> > Date: Wed, 12 May 2021 18:39:25 +0900
> >
> > In the following code, `let' binding of `coding-system-for-read'
> > covers only `erase-buffer' call.
> >
> > https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> >
> > So it does not affect to executed process and output characters are garbled.
> > e.g. "M-x ifconfig" on Windows.
>
> Thanks.  Does the patch below fix the problem?

Yes, it works fine with the patch.
Thank you!





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48375: coding-system-for-read in net-utils-run-simple is not properly set
  2021-05-15  9:32   ` iquiw
@ 2021-05-15  9:39     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2021-05-15  9:39 UTC (permalink / raw)
  To: iquiw; +Cc: 48375-done

> From: iquiw <iku.iwasa@gmail.com>
> Date: Sat, 15 May 2021 18:32:05 +0900
> Cc: 48375@debbugs.gnu.org
> 
> > > In the following code, `let' binding of `coding-system-for-read'
> > > covers only `erase-buffer' call.
> > >
> > > https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> > >
> > > So it does not affect to executed process and output characters are garbled.
> > > e.g. "M-x ifconfig" on Windows.
> >
> > Thanks.  Does the patch below fix the problem?
> 
> Yes, it works fine with the patch.
> Thank you!

Thanks for testing, I installed the fix on the master branch, and I'm
closing this bug report.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-15  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12  9:39 bug#48375: coding-system-for-read in net-utils-run-simple is not properly set iquiw
2021-05-15  8:26 ` Eli Zaretskii
2021-05-15  9:32   ` iquiw
2021-05-15  9:39     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).