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")))