From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Dunn Newsgroups: gmane.emacs.bugs Subject: bug#22046: [PATCH] Improve version-to-list parsing Date: Sun, 29 Nov 2015 19:54:18 -0800 Message-ID: References: <83y4dgma7k.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1448855721 20150 80.91.229.3 (30 Nov 2015 03:55:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Nov 2015 03:55:21 +0000 (UTC) Cc: 22046@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 30 04:55:07 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a3FYQ-0001pK-8s for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Nov 2015 04:55:06 +0100 Original-Received: from localhost ([::1]:38839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3FYU-0002fN-6i for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Nov 2015 22:55:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3FYQ-0002dy-Fl for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2015 22:55:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3FYM-0000Mu-G3 for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2015 22:55:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3FYM-0000Mq-Cd for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2015 22:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a3FYM-0000D4-07 for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2015 22:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alex Dunn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Nov 2015 03:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22046 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22046-submit@debbugs.gnu.org id=B22046.1448855681777 (code B ref 22046); Mon, 30 Nov 2015 03:55:01 +0000 Original-Received: (at 22046) by debbugs.gnu.org; 30 Nov 2015 03:54:41 +0000 Original-Received: from localhost ([127.0.0.1]:59967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a3FY0-0000CS-Vx for submit@debbugs.gnu.org; Sun, 29 Nov 2015 22:54:41 -0500 Original-Received: from mail-pa0-f43.google.com ([209.85.220.43]:36445) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a3FXg-0000C2-O3 for 22046@debbugs.gnu.org; Sun, 29 Nov 2015 22:54:39 -0500 Original-Received: by pacdm15 with SMTP id dm15so170418869pac.3 for <22046@debbugs.gnu.org>; Sun, 29 Nov 2015 19:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=gb9j6oNddLTCXmxtKXCb0hE9bmu0FV8zA4fdrNE5iZY=; b=f7PUzxhHrmaNcw8jzgTVmm7w092jdYwA+m40eW9QB5LM9e4QItyt1PV4pOH1n5rmC0 BtJa/aZnU4AGi+nvf60Cx2q2MBMj798jiNnRc6RAF0/3ZhCxtLvw2OG2SoSF0JTyKpf2 MTLKuiWJwX7nU6eMvByo+9+D+Hbo2EddSbhAmqAqefKIDxVgZBjShlHOut59QoJGn3qk Ld/TKjMz+BdLx3m7BMaG8B6HXhVrwdgChqWJMz1lLvU9A8GVIwvmfebsQ4LRVaE2LVLv a5b0uDRx5ikOux0Jnm2TU6p88FvE18R4uv90zN2YeSBLYgZrFzMhvkqXCg2oPqL6aJy1 MRIQ== X-Received: by 10.98.75.204 with SMTP id d73mr66731179pfj.90.1448855659490; Sun, 29 Nov 2015 19:54:19 -0800 (PST) Original-Received: from localhost (pool-98-108-240-213.snloca.dsl-w.verizon.net. [98.108.240.213]) by smtp.gmail.com with ESMTPSA id 132sm4457335pfc.63.2015.11.29.19.54.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Nov 2015 19:54:18 -0800 (PST) In-Reply-To: <83y4dgma7k.fsf@gnu.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-apple-darwin15.0.0) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109433 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I=E2=80=99d say in both cases =E2=80=9C0.9=E2=80=9D is the version and /alp= ha-?/ is the priority modifier, so if one is '(0 9 -3) then they both should be. Two other options for dealing with these cases (while keeping =E2=80=9COTP-18.0.5=E2=80=9D -> '(18 0 5)) is to just strip the /alpha-?/ a= nd parse those strings as '(0 9) or flag them as invalid version-strings. My ordered preferences are: 1. parse them both as '(0 9 -3) 2. treat them as invalid and throw an error 3. parse them as '(0 9) FWIW, attaching the diff for (1). --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=prefix-separators.diff Content-Description: patch on top of 0001-Improve-version-to-list-parsing.patch diff --git a/lisp/subr.el b/lisp/subr.el index 74d6aa1..dd3bac6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4686,14 +4686,14 @@ version-separator (defconst version-regexp-alist - '(("^[-\._+ ]?snapshot$" . -4) + '(("^[-\._+ ]?snapshot" . -4) ;; treat "1.2.3-20050920" and "1.2-3" as snapshot releases - ("^[-\._+]$" . -4) + ("^[-\._+]" . -4) ;; treat "1.2.3-CVS" as snapshot release - ("^[-\._+ ]?\\(cvs\\|git\\|bzr\\|svn\\|hg\\|darcs\\)$" . -4) - ("^[-\._+ ]?alpha$" . -3) - ("^[-\._+ ]?beta$" . -2) - ("^[-\._+ ]?\\(pre\\|rc\\)$" . -1)) + ("^[-\._+ ]?\\(cvs\\|git\\|bzr\\|svn\\|hg\\|darcs\\)" . -4) + ("^[-\._+ ]?alpha" . -3) + ("^[-\._+ ]?beta" . -2) + ("^[-\._+ ]?\\(pre\\|rc\\)" . -1)) "Specify association between non-numeric version and its priority. This association is used to handle version string like \"1.0pre2\", @@ -4816,9 +4816,10 @@ version-to-list ;; handle alpha, beta, pre, etc. separator (unless (string= s version-separator) (setq al version-regexp-alist) - (while (and al (not (string-match (caar al) s))) + ;; The regular expression needs to match the entire substring + (while (and al (not (string-match (concat (caar al) "$") s))) (setq al (cdr al))) - ;; only allow alpha, beta, pre, etc. separators at the beginning + ;; Only allow alpha, beta, pre, etc. separators at the beginning ;; of the version-string (handled above) or as a normal ;; separator, but not as both ("beta0.9alpha1" is not valid) (cond ((and al (null pref)) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 605db91..9d2365a 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -146,7 +146,9 @@ (should (equal (version-to-list "OTP-18.1.5") '(18 1 5))) (should (equal (version-to-list "OTP.18.1.5") '(18 1 5))) (should (equal (version-to-list "OTP18.1.5") '(18 1 5))) + (should (equal (version-to-list "alpha.0.9") '(0 9 -3))) (should (equal (version-to-list "alpha0.9") '(0 9 -3))) + (should (equal (version-to-list "alpha_0.9") '(0 9 -3))) (should (equal (error-message-string (should-error (version-to-list ""))) @@ -210,7 +212,9 @@ (should (equal (version-to-list "OTP-18_1_5") '(18 1 5))) (should (equal (version-to-list "OTP.18_1_5") '(18 1 5))) (should (equal (version-to-list "OTP18_1_5") '(18 1 5))) + (should (equal (version-to-list "alpha.0_9") '(0 9 -3))) (should (equal (version-to-list "alpha0_9") '(0 9 -3))) + (should (equal (version-to-list "alpha_0_9") '(0 9 -3))) (should (equal (error-message-string (should-error (version-to-list "1_0__7_5"))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Alex Dunn >> Date: Sun, 29 Nov 2015 16:09:12 -0800 >> >> >> Woops. =E2=80=9Calpha0.9=E2=80=9D is parsed as '(0 9 -3), but =E2=80=9Ca= lpha-0.9=E2=80=9D is parsed as >> '(0 9). Shouldn=E2=80=99t be hard to fix, though, if this behavior is d= esired. > > Which part(s) of the string is/are the version in each case, in your > opinion? --=-=-=--