From b2497ef6952134022ad799247bc5a31f7559ef87 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 16 Jan 2019 13:56:38 +0100 Subject: Some accept-process-output cleanups in Tramp * lisp/net/tramp.el (tramp-action-out-of-band): Read process output in a loop. (tramp-accept-process-output): Return result. (tramp-interrupt-process): * lisp/net/tramp-adb.el (tramp-adb-parse-device-names): * lisp/net/tramp-rclone.el (tramp-rclone-parse-device-names): Remove FIXME. * lisp/net/tramp-sh.el (tramp-local-coding-commands): Fix docstring. * lisp/net/tramp-smb.el (tramp-smb-wait-for-output): Adapt docstring. Simplify code. * lisp/net/tramp-sudoedit.el (tramp-sudoedit-action-sudo): Adapt docstring. Read process output in a loop. * test/lisp/net/tramp-tests.el (tramp-test43-asynchronous-requests): Remove :unstable tag on emba. --- lisp/net/tramp-smb.el | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'lisp/net/tramp-smb.el') diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index abf3248a353..8198930abc6 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1087,7 +1087,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; Half a year. (time-since (nth 3 x)) (days-to-time 183)) "%b %e %R" - "%b %e %Y") + "%b %e %Y") (nth 3 x))))) ; date ;; We mark the file name. The inserted name could be @@ -2026,54 +2026,25 @@ If ARGUMENT is non-nil, use it as argument for ;; We don't use timeouts. If needed, the caller shall wrap around. (defun tramp-smb-wait-for-output (vec) "Wait for output from smbclient command. -Returns nil if an error message has appeared." +Removes smb prompt. Returns nil if an error message has appeared." (with-current-buffer (tramp-get-connection-buffer vec) (let ((p (get-buffer-process (current-buffer))) - (found (progn (goto-char (point-min)) - (re-search-forward tramp-smb-prompt nil t))) - (err (progn (goto-char (point-min)) - (re-search-forward tramp-smb-errors nil t))) buffer-read-only) - ;; Algorithm: get waiting output. See if last line contains - ;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings. - ;; If not, wait a bit and again get waiting output. - ;; FIXME: Either remove " 0.1", or comment why it's needed. - (while (and (not found) (not err) - (or (tramp-accept-process-output p 0.1) - (process-live-p p))) - - ;; Search for prompt. - (goto-char (point-min)) - (setq found (re-search-forward tramp-smb-prompt nil t)) - - ;; Search for errors. - (goto-char (point-min)) - (setq err (re-search-forward tramp-smb-errors nil t))) - - ;; When the process is still alive, read pending output. - ;; FIXME: This loop should be folded into the previous loop. - ;; Also, ERR should be set just once, after the combined - ;; loop has finished. - ;; FIXME: Either remove " 0.1", or comment why it's needed. - (while (and (not found) - (or (tramp-accept-process-output p 0.1) - (process-live-p p))) - - ;; Search for prompt. - (goto-char (point-min)) - (setq found (re-search-forward tramp-smb-prompt nil t))) - + ;; Read pending output. + (while (tramp-accept-process-output p 0.1)) (tramp-message vec 6 "\n%s" (buffer-string)) ;; Remove prompt. - (when found + (goto-char (point-min)) + (when (re-search-forward tramp-smb-prompt nil t) (goto-char (point-max)) (re-search-backward tramp-smb-prompt nil t) (delete-region (point) (point-max))) ;; Return value is whether no error message has appeared. - (not err)))) + (goto-char (point-min)) + (not (re-search-forward tramp-smb-errors nil t))))) (defun tramp-smb-kill-winexe-function () "Send SIGKILL to the winexe process." -- cgit v1.2.1