From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aleksandr Vityazev Newsgroups: gmane.emacs.bugs Subject: bug#51754: 29.0.50; [PATCH] tramp-compat-file-name-concat work in wrong way Date: Wed, 10 Nov 2021 18:56:49 +0000 Message-ID: <87czn7hma6.fsf@posteo.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16417"; mail-complaints-to="usenet@ciao.gmane.io" To: 51754@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 10 19:57:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mksmW-00043x-JA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 19:57:12 +0100 Original-Received: from localhost ([::1]:59044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mksmV-0005yx-HI for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 13:57:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mksmM-0005yl-Fq for bug-gnu-emacs@gnu.org; Wed, 10 Nov 2021 13:57:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mksmM-0001YO-82 for bug-gnu-emacs@gnu.org; Wed, 10 Nov 2021 13:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mksmL-0004kQ-Qy for bug-gnu-emacs@gnu.org; Wed, 10 Nov 2021 13:57:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Nov 2021 18:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51754 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163657061018228 (code B ref -1); Wed, 10 Nov 2021 18:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Nov 2021 18:56:50 +0000 Original-Received: from localhost ([127.0.0.1]:39209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mksmA-0004jw-4y for submit@debbugs.gnu.org; Wed, 10 Nov 2021 13:56:50 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:60700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mksm5-0004jm-DW for submit@debbugs.gnu.org; Wed, 10 Nov 2021 13:56:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mksm4-0005x8-Sr for bug-gnu-emacs@gnu.org; Wed, 10 Nov 2021 13:56:45 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:49079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mksm2-0001X8-OT for bug-gnu-emacs@gnu.org; Wed, 10 Nov 2021 13:56:44 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 2D6AF240104 for ; Wed, 10 Nov 2021 19:56:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.org; s=2017; t=1636570595; bh=iARwbvRVrtAGey+w3zRI7eeuoIv1zkm2lhWUZ+aFUJU=; h=From:To:Subject:Date:From; b=WyXiHJrSbkaK22wPIB/N7+atpfE7rTIxODnx/jQrI1EC4fA9+IP3eB92Z/Oa2qvhR tKWRbApDkTvAYAdhd2VWFsBgzhiKZcf/13Zay0IhSzJG0l0494vZnXTGBjtFu7OvtW Moij9c/FTQJuGn6cqQueSCA1oA86J/vKZmd5R44iur9kgEV8SS5n54oxqR3XMsRUUe an8NUvJCqeCF/U690q75+f1IGMn4waM4XFPIGLXYsHYel9FZ5Nl/DjvGg6+Sbft59U J6zR0yVTYsZGhGhF/kFgmAFWMgpm9GsJCi6+ftsEsxy0HfAc8UltQwTJf8a0LWPBma PpEwUq16JA3sg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HqDbQ24SNz9rxB for ; Wed, 10 Nov 2021 19:56:34 +0100 (CET) Received-SPF: pass client-ip=185.67.36.66; envelope-from=avityazev@posteo.org; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219560 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello,=20 The current implementation of the tramp-compat-file-name-concat=20 from lisp/net/tramp-compat.el fails test fileio-tests/file-name-concat from file test/src/fileio-tests.el for file-name-concat on Emacs where no file-name-concat. #+begin_src elisp (ert-deftest test-tramp-compat-file-name-concat () (should (equal (tramp-compat-file-name-concat "foo" "bar") "foo/bar")) (should (equal (tramp-compat-file-name-concat "foo" "bar") "foo/bar")) (should (equal (tramp-compat-file-name-concat "foo" "bar" "zot") "foo/bar= /zot")) (should (equal (tramp-compat-file-name-concat "foo/" "bar") "foo/bar")) (should (equal (tramp-compat-file-name-concat "foo//" "bar") "foo//bar")) (should (equal (tramp-compat-file-name-concat "foo/" "bar/" "zot") "foo/b= ar/zot")) (should (equal (tramp-compat-file-name-concat "f=C3=B3o" "bar") "f=C3=B3o= /bar")) (should (equal (tramp-compat-file-name-concat "foo" "b=C3=A1r") "foo/b=C3= =A1r")) (should (equal (tramp-compat-file-name-concat "f=C3=B3o" "b=C3=A1r") "f= =C3=B3o/b=C3=A1r")) (let ((string (make-string 5 ?a))) (should (not (multibyte-string-p string))) (aset string 2 255) (should (not (multibyte-string-p string))) (should (equal (tramp-compat-file-name-concat "f=C3=B3o" string) "f=C3= =B3o/aa\377aa"))) (should (equal (tramp-compat-file-name-concat "foo") "foo")) (should (equal (tramp-compat-file-name-concat "foo/") "foo/")) (should (equal (tramp-compat-file-name-concat "foo" "") "foo")) (should (equal (tramp-compat-file-name-concat "foo" "" "" "" nil) "foo")) (should (equal (tramp-compat-file-name-concat "" "bar") "bar")) (should (equal (tramp-compat-file-name-concat "" "") ""))) (ert 'test-tramp-compat-file-name-concat) #+end_src --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=test-tramp-compat-file-name-concat.ert Content-Description: test-tramp-compat-file-name-concat Selector: test-tramp-compat-file-name-concat Passed: 0 Failed: 1 (1 unexpected) Skipped: 0 Total: 1/1 Started at: 2021-11-10 21:21:24+0300 Finished. Finished at: 2021-11-10 21:21:25+0300 F F test-tramp-compat-file-name-concat (wrong-type-argument characterp "zot") --=-=-= Content-Type: text/plain Here is the patch to fix: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-net-tramp-compat.el-Fix-tramp-compat-file-name-.patch Content-Description: tramp-compat-file-name-concat >From 1a0c540abfc129d67bf2e291c038c2163f7fee7f Mon Sep 17 00:00:00 2001 From: Aleksandr Vityazev Date: Wed, 10 Nov 2021 21:36:16 +0300 Subject: [PATCH] * lisp/net/tramp-compat.el: Fix tramp-compat-file-name-concat * lisp/net/tramp-compat.el: Make tramp-compat-file-name-concat work like file-name-concat. --- lisp/net/tramp-compat.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 213ab5857c..fbc3d684ce 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -386,14 +386,17 @@ CONDITION can also be a list of error conditions." (if (fboundp 'file-name-concat) #'file-name-concat (lambda (directory &rest components) - (unless (null directory) - (let ((components (delq nil components)) - file-name-handler-alist) - (if (null components) - directory - (tramp-compat-file-name-concat - (concat (file-name-as-directory directory) (car components)) - (cdr components)))))))) + (let ((components (cl-remove-if (lambda (el) + (or (null el) (equal "" el))) + components)) + file-name-handler-alist) + (if (null components) + directory + (apply #'tramp-compat-file-name-concat + (concat (unless (or (equal "" directory) (null directory)) + (file-name-as-directory directory)) + (car components)) + (cdr components))))))) (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) (put (intern elt) 'tramp-suppress-trace t)) -- 2.33.1 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=--