From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#55787: 29.0.50; inconsistent sort order with ls-lisp-version-lessp Date: Sat, 04 Jun 2022 17:52:44 +0300 Message-ID: <837d5wbhvn.fsf@gnu.org> References: <87tu91fi43.fsf@yfb02119.nifty.com> <83h750c1q3.fsf@gnu.org> <87tu90jz7e.fsf@yfb02119.nifty.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32632"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55787@debbugs.gnu.org To: TAKAHASHI Yoshio Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 04 16:54:10 2022 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 1nxVAH-0008E3-Hv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jun 2022 16:54:09 +0200 Original-Received: from localhost ([::1]:42142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxVAG-0007oF-Ay for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jun 2022 10:54:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxVAA-0007nq-J7 for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2022 10:54:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxVAA-0007qM-AB for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2022 10:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nxVAA-0001X5-8n for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2022 10:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jun 2022 14:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55787 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 55787-submit@debbugs.gnu.org id=B55787.16543543865827 (code B ref 55787); Sat, 04 Jun 2022 14:54:02 +0000 Original-Received: (at 55787) by debbugs.gnu.org; 4 Jun 2022 14:53:06 +0000 Original-Received: from localhost ([127.0.0.1]:59480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxV9G-0001Vv-7D for submit@debbugs.gnu.org; Sat, 04 Jun 2022 10:53:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxV9B-0001VN-C4 for 55787@debbugs.gnu.org; Sat, 04 Jun 2022 10:53:05 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxV94-0007lp-Lo; Sat, 04 Jun 2022 10:52:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Ls+V5NB7kQ6SXKYK4mMVG4nwLlXF0PbIzFkCUqKTyWs=; b=hK+VRBzZDkWL 5TNoHKYgcCsZUGz1d+FAX9sgh8V0al3oF7lU1/+fLATHWOtjooJuFV8LH+FE4fjxBw03qoCv9aKhp BRQaRxQRUXlRwVBww8IrE/JE+v3DVLL4ESa1rKksXOi3cCfWalGvzMbp51HfRZgYGgbi5C6ki3kwM CbI0bCXlpYW0AKEujssKzn/reg2i4misFthPsw2qWi/8NR/DV3rYIF6U/epCN59MgOyXmuXXGDDyK g1c33vYsBmKU9pkZr1l4x6DnSQW/MObsSeozQ3oxNLhcneSo4Uy5ltCSCD6LHE4IgC4v4n0LtyzrA kfOZRnVrtL3lj8TFq9c6mg==; Original-Received: from [87.69.77.57] (port=1778 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxV94-0000n5-5x; Sat, 04 Jun 2022 10:52:54 -0400 In-Reply-To: <87tu90jz7e.fsf@yfb02119.nifty.com> (message from TAKAHASHI Yoshio on Sat, 04 Jun 2022 23:11:17 +0900) 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:233666 Archived-At: > From: TAKAHASHI Yoshio > Cc: 55787@debbugs.gnu.org > Date: Sat, 04 Jun 2022 23:11:17 +0900 > > >> $ cat /tmp/test.el > >> (require 'ls-lisp) > >> (print (sort (vector "01.0" "10" "010" "01.2") > >> (lambda (x y) > >> (ls-lisp-version-lessp x y)))) > >> $ emacs -Q --batch -l /tmp/test.el > >> > >> ["01.0" "10" "010" "01.2"] > > > > Why do you think this is wrong? This function is not meant to compare > > dotted versions with undotted ones, only dotted to dotted or undotted > > to undotted. The strings are supposed to be file names, where a dot > > begins an extension. > > > > See the node "More details about version sort" in the GNU Coreutils > > manual for more info. > > I report this "inconsistency" because ls-lisp does not sort files as ls > program does when `dired-listing-switches' has 'v', such as "-alGv". What do you see with 'ls' and what do you see with ls-lisp? Also, in which locale are you trying this with 'ls'? > # "01.0", "10", ... is minimal reproducible pattern that I stlipped down > # my real filenames pattern. I'd prefer to see the real file names instead, since that's what ls-lisp-version-lessp was written to handle. > I'm not aware that `ls-lisp-version-lessp' does not support > dotted-undotted mixed cases. Doc string says it acts as `strverscmp', I > expect the same result (order) in dired buffer. And in below example, > the result seems to act like `strverscmp'. The exact spec of strverscmp is not known, AFAIK, and the implementation is a state machine, which is somewhat hard to reverse-engineer. I'm only aware of the documentation in the glibc manual; did you read it? Comparing with 'ls' is also somewhat problematic, because in UTF-8 locales its collation rules ignore some punctuation characters -- again, because that's how glibc implements that. Emacs on MS-Windows can emulate this behavior if you set w32-collate-ignore-punctuation to a non-nil value. > (print (sort (vector "01.0" "10" "01.2") ; no "010" in arg. > (lambda (x y) > (ls-lisp-version-lessp x y)))) > ["01.0" "01.2" "10"] If I create files by the names in your original example, I see this in a Dired buffer created by "C-u C-x d" after I set the switches to "-alv": drwxrwxrwx 1 xxxxx yyy 0 06-04 10:19 . drwxrwxrwx 1 xxxxx yyy 0 06-04 11:02 .. -rw-rw-rw- 1 xxxxx yyy 0 06-04 10:19 10 -rw-rw-rw- 1 xxxxx yyy 0 06-04 10:19 010 -rw-rw-rw- 1 xxxxx yyy 0 06-04 10:19 01.0 -rw-rw-rw- 1 xxxxx yyy 0 06-04 10:19 01.2 which seems reasonable. > > If you want a general-purpose version-comparison function, use > > version< instead. > > Umm, do I need to use `version<' in `ls-lisp-handle-switches' with > extracting numerical part from filename argument? No, I wrote that before I understood what you were trying to do. Please ignore that part.