Mercurial > emacs
comparison lisp/subr.el @ 65668:bbff73cbd15c
(version-regexp-alist): Extend valid syntax for version strings:
allow any of the characters -,_,+ to separate the alpha/beta/rc part
from the version part. Doc fix.
(version-to-list): Doc fix. Bind case-fold-search to t, as advertised.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 24 Sep 2005 10:40:13 +0000 |
parents | 6d566cf5ad51 |
children | 366f80f966cb 2a679c81f552 ee12d75eb214 |
comparison
equal
deleted
inserted
replaced
65667:adbf7c56937f | 65668:bbff73cbd15c |
---|---|
2860 | 2860 |
2861 Usually the separator is \".\", but it can be any other string.") | 2861 Usually the separator is \".\", but it can be any other string.") |
2862 | 2862 |
2863 | 2863 |
2864 (defvar version-regexp-alist | 2864 (defvar version-regexp-alist |
2865 '(("^a\\(lpha\\)?$" . -3) | 2865 '(("^[-_+]?a\\(lpha\\)?$" . -3) |
2866 ("^b\\(eta\\)?$" . -2) | 2866 ("^[-_+]$" . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases |
2867 ("^\\(pre\\|rc\\)$" . -1)) | 2867 ("^[-_+]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release |
2868 ("^[-_+]?b\\(eta\\)?$" . -2) | |
2869 ("^[-_+]?\\(pre\\|rc\\)$" . -1)) | |
2868 "*Specify association between non-numeric version part and a priority. | 2870 "*Specify association between non-numeric version part and a priority. |
2869 | 2871 |
2870 This association is used to handle version string like \"1.0pre2\", | 2872 This association is used to handle version string like \"1.0pre2\", |
2871 \"0.9alpha1\", etc. It's used by `version-to-list' (which see) to convert the | 2873 \"0.9alpha1\", etc. It's used by `version-to-list' (which see) to convert the |
2872 non-numeric part to an integer. For example: | 2874 non-numeric part to an integer. For example: |
2885 (REGEXP . PRIORITY) | 2887 (REGEXP . PRIORITY) |
2886 | 2888 |
2887 Where: | 2889 Where: |
2888 | 2890 |
2889 REGEXP regexp used to match non-numeric part of a version string. | 2891 REGEXP regexp used to match non-numeric part of a version string. |
2892 It should begin with a `^' anchor and end with a `$' to | |
2893 prevent false hits. Letter-case is ignored while matching | |
2894 REGEXP. | |
2890 | 2895 |
2891 PRIORITY negative integer which indicate the non-numeric priority.") | 2896 PRIORITY negative integer which indicate the non-numeric priority.") |
2892 | 2897 |
2893 | 2898 |
2894 (defun version-to-list (ver) | 2899 (defun version-to-list (ver) |
2901 NUMBER ::= (0|1|2|3|4|5|6|7|8|9)+. | 2906 NUMBER ::= (0|1|2|3|4|5|6|7|8|9)+. |
2902 | 2907 |
2903 SEPARATOR ::= `version-separator' (which see) | 2908 SEPARATOR ::= `version-separator' (which see) |
2904 | `version-regexp-alist' (which see). | 2909 | `version-regexp-alist' (which see). |
2905 | 2910 |
2911 The NUMBER part is optional if SEPARATOR is a match for an element | |
2912 in `version-regexp-alist'. | |
2913 | |
2906 As an example of valid version syntax: | 2914 As an example of valid version syntax: |
2907 | 2915 |
2908 1.0pre2 1.0.7.5 22.8beta3 0.9alpha1 | 2916 1.0pre2 1.0.7.5 22.8beta3 0.9alpha1 6.9.30Beta |
2909 | 2917 |
2910 As an example of invalid version syntax: | 2918 As an example of invalid version syntax: |
2911 | 2919 |
2912 1.0prepre2 1.0..7.5 22.8X3 alpha3.2 .5 | 2920 1.0prepre2 1.0..7.5 22.8X3 alpha3.2 .5 |
2913 | 2921 |
2926 See documentation for `version-separator' and `version-regexp-alist'." | 2934 See documentation for `version-separator' and `version-regexp-alist'." |
2927 (or (and (stringp ver) (not (string= ver ""))) | 2935 (or (and (stringp ver) (not (string= ver ""))) |
2928 (error "Invalid version string: '%s'" ver)) | 2936 (error "Invalid version string: '%s'" ver)) |
2929 (save-match-data | 2937 (save-match-data |
2930 (let ((i 0) | 2938 (let ((i 0) |
2931 case-fold-search ; ignore case in matching | 2939 (case-fold-search t) ; ignore case in matching |
2932 lst s al) | 2940 lst s al) |
2933 (while (and (setq s (string-match "[0-9]+" ver i)) | 2941 (while (and (setq s (string-match "[0-9]+" ver i)) |
2934 (= s i)) | 2942 (= s i)) |
2935 ;; handle numeric part | 2943 ;; handle numeric part |
2936 (setq lst (cons (string-to-number (substring ver i (match-end 0))) | 2944 (setq lst (cons (string-to-number (substring ver i (match-end 0))) |