From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix some failing tests in BSD systems Date: Wed, 6 Jan 2021 03:38:04 +0200 Message-ID: References: <83a6tpdiuf.fsf@gnu.org> <5e881738-2df3-d5e3-9a46-bc4304ff4092@yandex.ru> <835z4dcrah.fsf@gnu.org> <5d574d90-34b1-0fb1-8b3a-83e7709eadfc@yandex.ru> <83pn2kbsy5.fsf@gnu.org> <6e35988f-fdf0-5384-1aaa-e8e21effead9@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4DD4CB289BC0396F2D69253E" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40230"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: Eli Zaretskii , emacs-devel@gnu.org To: =?UTF-8?Q?Daniel_Mart=c3=adn?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 06 02:39:27 2021 Return-path: Envelope-to: ged-emacs-devel@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 1kwxnL-000ALX-1d for ged-emacs-devel@m.gmane-mx.org; Wed, 06 Jan 2021 02:39:27 +0100 Original-Received: from localhost ([::1]:41022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwxnK-0001Z9-3O for ged-emacs-devel@m.gmane-mx.org; Tue, 05 Jan 2021 20:39:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwxmA-0000sf-E4 for emacs-devel@gnu.org; Tue, 05 Jan 2021 20:38:14 -0500 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:34339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwxm8-0006hK-2Y; Tue, 05 Jan 2021 20:38:14 -0500 Original-Received: by mail-wm1-x334.google.com with SMTP id g25so2310325wmh.1; Tue, 05 Jan 2021 17:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=swp4oqpgX6cGmh8eNt/kEXncKvu6VPq+xRn+xIEjXk0=; b=G5ztperJlyJx1KuKJOAHBoDVfoDAsyUhEeKSpyPwPfftWkMZmv3grXR1Hd5eX/vA+h SSXLjYbpkqYxBCR7i90AB3lO+ydfJhOpxi/7vN3OTJwXnO5al5SJlTC7W5YkjlnjRcnM k4nvMdml80IscXy/NgDPpSGRAgvdj+PEADgFqf/HRSY4YwJvhEoziBkBsbFB9Zg/xjea 25EAcTHVpvZgEWjAMBSRhT3hVV2xpPHvdHwhwSp052v1hR7H8TXkPKLFdoPMY2t/xcKD Ap8wrYUXyHp0z0cB0tOX+clvCPUdWahk/HQb2act8fhBMksN3NtBfu+RKG85BIGNXdxV CW6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=swp4oqpgX6cGmh8eNt/kEXncKvu6VPq+xRn+xIEjXk0=; b=WKCeml7P6hq0YsWpdVwM728ApXD2R4O6Pt9UxOgWHQfWbWCD8WFLxb/9f8Lq2A+zmO pVwq/IJEVAZVLOp6Whd8tz90py9FvZKMECpP+i0WKSbtMfRve+kAsmT7w4WY5BjkLHWh Fa9Sif2msKTVE/4lnYVExKvNJUnGHF0LzYQobD0uYxNgebEugjOQ8heQwMuAn8htD5ku 3fwACfG3Ju/lvF68yJOUBHbP5fWJXGzIq2V2kLpbxFdWxuDRXrRUnZi/yJPnwxdXNkmh 5zmRkiGT3SqgxggJhvYnyugdRXT02W3CW6tG4SHNIm2PUrb4btSdRQ7gKNfJNJkKRbFR XZ5Q== X-Gm-Message-State: AOAM533CI9D71wdMUrqNpW65Vd4G3V5lSnBRby6TTWgZPeI1FRcoYaE/ +rH4miIXgTtINQAYxyAc9DUvbnkTCwDU9w== X-Google-Smtp-Source: ABdhPJyfVyruliACTX3yft5RM5M9pPUnC/JgavNMzInXsmdE7/c99gi9KGozycql2CDG2zyHIn9JYQ== X-Received: by 2002:a7b:c773:: with SMTP id x19mr1431522wmk.127.1609897088930; Tue, 05 Jan 2021 17:38:08 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b10sm1117873wmj.5.2021.01.05.17.38.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 17:38:07 -0800 (PST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=raaahh@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262558 Archived-At: This is a multi-part message in MIME format. --------------4DD4CB289BC0396F2D69253E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 05.01.2021 00:25, Daniel Martín wrote: > Thanks, it fixes the test failures for me. However, I still see the > extra '/' if I follow these steps: > > - make TAGS > - emacs -Q > - Visit src/xdisp.c > - M-? in redisplay_internal > > Perhaps there are more places that need that patch. Thanks, that's the third place, and probably the final one. In the meantime, plot thickens: as pointed out privately by Davis Herring, using 'find' on a directory without a trailing slash will fail if the directory is a symlink (it will only list the symlink itself). At this point we could double down on this approach and use the '-H' argument (though grep-find-template doesn't make this easy), or return to your original patch. Or yet alternatively, paper over this inside the xref-location-group defmethod. The two alternatives attached. So I guess I should ask: was the particular behavior annoying by itself, or is it only a problem because of the failing test? I also wonder whether all macOS users see this, or whether it's maybe fixed in some latest version of BSD find. Because it's apparently (arguably) a bug: https://unix.stackexchange.com/a/320440/166215 --------------4DD4CB289BC0396F2D69253E Content-Type: text/x-patch; charset=UTF-8; name="find-no-doubleslash-h.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="find-no-doubleslash-h.diff" diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 5f9a3fa352..21f075041c 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -119,12 +119,15 @@ semantic-symref-grep-use-template ;; it to the user. By contrast, here we don't show ;; the output, and the SGR escapes get in the way ;; of parsing the output. - (replace-regexp-in-string "--color=always" "" - grep-find-template t t) + (replace-regexp-in-string + "" "-H " + (replace-regexp-in-string "--color=always" "" + grep-find-template t t) + t t) grep-find-template) pattern filepattern - rootdir))) + (directory-file-name rootdir)))) cmd)) (defcustom semantic-symref-grep-shell shell-file-name diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index d417382c0d..04546d1e4d 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -289,9 +289,9 @@ project--files-in-directory ;; expanded and not left for the shell command ;; to interpret. (localdir (file-local-name (expand-file-name dir))) - (command (format "%s %s %s -type f %s -print0" + (command (format "%s -H %s %s -type f %s -print0" find-program - localdir + (directory-file-name localdir) (xref--find-ignores-arguments ignores localdir) (if files (concat (shell-quote-argument "(") diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index d2b5acd555..13fc2f09c7 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1374,7 +1374,8 @@ xref-matches-in-directory ;; do that reliably enough, without creating false negatives? (command (xref--rgrep-command (xref--regexp-to-extended regexp) files - (file-local-name (expand-file-name dir)) + (directory-file-name + (file-local-name (expand-file-name dir))) ignores)) (def default-directory) (buf (get-buffer-create " *xref-grep*")) @@ -1543,7 +1544,10 @@ xref--rgrep-command ;; `shell-quote-argument' quotes the tilde as well. (cl-assert (not (string-match-p "\\`~" dir))) (grep-expand-template - grep-find-template + (replace-regexp-in-string + "" "-H " + grep-find-template + t t) regexp (concat (shell-quote-argument "(") " " find-name-arg " " --------------4DD4CB289BC0396F2D69253E Content-Type: text/x-patch; charset=UTF-8; name="find-no-doubleslash-postprocess.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="find-no-doubleslash-postprocess.diff" diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 5f9a3fa352..9f0ac38ec7 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -168,7 +168,8 @@ semantic-symref-perform-search (erase-buffer) (setq default-directory rootdir) (let ((cmd (semantic-symref-grep-use-template - (file-local-name rootdir) filepattern grepflags greppat))) + (file-name-as-directory (file-local-name rootdir)) + filepattern grepflags greppat))) (process-file semantic-symref-grep-shell nil b nil shell-command-switch cmd))) (setq ans (semantic-symref-parse-tool-output tool b)) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index d417382c0d..f91246a885 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -291,7 +291,7 @@ project--files-in-directory (localdir (file-local-name (expand-file-name dir))) (command (format "%s %s %s -type f %s -print0" find-program - localdir + (file-name-as-directory localdir) (xref--find-ignores-arguments ignores localdir) (if files (concat (shell-quote-argument "(") diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index d2b5acd555..bacc5e6f1c 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -161,11 +161,13 @@ xref--project-root-memo "Cons mapping `default-directory' value to the search root.") (cl-defmethod xref-location-group ((l xref-file-location)) + (let ((file (oref l file))) + (unless (eq xref-file-name-display 'abs) + (setq file (replace-regexp-in-string "//" "/" file t t))) (cl-ecase xref-file-name-display - (abs - (oref l file)) + (abs file) (nondirectory - (file-name-nondirectory (oref l file))) + (file-name-nondirectory file)) (project-relative (unless (and xref--project-root-memo (equal (car xref--project-root-memo) @@ -176,12 +178,12 @@ xref-location-group (let ((pr (project-current))) (and pr (xref--project-root pr))))) (and root (expand-file-name root)))))) - (let ((file (oref l file)) + (let ((file file) (search-root (cdr xref--project-root-memo))) (if (and search-root (string-prefix-p search-root file)) (substring file (length search-root)) - file))))) + file)))))) (defclass xref-buffer-location (xref-location) ((buffer :type buffer :initarg :buffer) @@ -1374,7 +1376,8 @@ xref-matches-in-directory ;; do that reliably enough, without creating false negatives? (command (xref--rgrep-command (xref--regexp-to-extended regexp) files - (file-local-name (expand-file-name dir)) + (file-name-as-directory + (file-local-name (expand-file-name dir))) ignores)) (def default-directory) (buf (get-buffer-create " *xref-grep*")) --------------4DD4CB289BC0396F2D69253E--