comparison lisp/subr.el @ 67541:f9d4913b40bc

(version-regexp-alist): Allow space as separator before non-numeric part, e.g. "1.0 alpha". (version-to-list): Interpret .X.Y version as 0.X.Y version.
author Kim F. Storm <storm@cua.dk>
date Mon, 12 Dec 2005 14:23:06 +0000
parents a69df0269000
children 915b73d58795 14a4eb789b45
comparison
equal deleted inserted replaced
67540:ee8691863511 67541:f9d4913b40bc
2893 2893
2894 Usually the separator is \".\", but it can be any other string.") 2894 Usually the separator is \".\", but it can be any other string.")
2895 2895
2896 2896
2897 (defvar version-regexp-alist 2897 (defvar version-regexp-alist
2898 '(("^[-_+]?a\\(lpha\\)?$" . -3) 2898 '(("^[-_+ ]?a\\(lpha\\)?$" . -3)
2899 ("^[-_+]$" . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases 2899 ("^[-_+]$" . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases
2900 ("^[-_+]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release 2900 ("^[-_+ ]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release
2901 ("^[-_+]?b\\(eta\\)?$" . -2) 2901 ("^[-_+ ]?b\\(eta\\)?$" . -2)
2902 ("^[-_+]?\\(pre\\|rc\\)$" . -1)) 2902 ("^[-_+ ]?\\(pre\\|rc\\)$" . -1))
2903 "*Specify association between non-numeric version part and a priority. 2903 "*Specify association between non-numeric version part and a priority.
2904 2904
2905 This association is used to handle version string like \"1.0pre2\", 2905 This association is used to handle version string like \"1.0pre2\",
2906 \"0.9alpha1\", etc. It's used by `version-to-list' (which see) to convert the 2906 \"0.9alpha1\", etc. It's used by `version-to-list' (which see) to convert the
2907 non-numeric part to an integer. For example: 2907 non-numeric part to an integer. For example:
2908 2908
2909 String Version Integer List Version 2909 String Version Integer List Version
2910 \"1.0pre2\" (1 0 -1 2) 2910 \"1.0pre2\" (1 0 -1 2)
2911 \"1.0PRE2\" (1 0 -1 2) 2911 \"1.0PRE2\" (1 0 -1 2)
2912 \"22.8beta3\" (22 8 -2 3) 2912 \"22.8beta3\" (22 8 -2 3)
2913 \"22.8Beta3\" (22 8 -2 3) 2913 \"22.8 Beta3\" (22 8 -2 3)
2914 \"0.9alpha1\" (0 9 -3 1) 2914 \"0.9alpha1\" (0 9 -3 1)
2915 \"0.9AlphA1\" (0 9 -3 1) 2915 \"0.9AlphA1\" (0 9 -3 1)
2916 \"0.9alpha\" (0 9 -3) 2916 \"0.9 alpha\" (0 9 -3)
2917 2917
2918 Each element has the following form: 2918 Each element has the following form:
2919 2919
2920 (REGEXP . PRIORITY) 2920 (REGEXP . PRIORITY)
2921 2921
2963 \"0.9alpha1\" (0 9 -3 1) 2963 \"0.9alpha1\" (0 9 -3 1)
2964 \"0.9AlphA1\" (0 9 -3 1) 2964 \"0.9AlphA1\" (0 9 -3 1)
2965 \"0.9alpha\" (0 9 -3) 2965 \"0.9alpha\" (0 9 -3)
2966 2966
2967 See documentation for `version-separator' and `version-regexp-alist'." 2967 See documentation for `version-separator' and `version-regexp-alist'."
2968 (or (and (stringp ver) (not (string= ver ""))) 2968 (or (and (stringp ver) (> (length ver) 0))
2969 (error "Invalid version string: '%s'" ver)) 2969 (error "Invalid version string: '%s'" ver))
2970 ;; Change .x.y to 0.x.y
2971 (if (and (>= (length ver) (length version-separator))
2972 (string-equal (substring ver 0 (length version-separator))
2973 version-separator))
2974 (setq ver (concat "0" ver)))
2970 (save-match-data 2975 (save-match-data
2971 (let ((i 0) 2976 (let ((i 0)
2972 (case-fold-search t) ; ignore case in matching 2977 (case-fold-search t) ; ignore case in matching
2973 lst s al) 2978 lst s al)
2974 (while (and (setq s (string-match "[0-9]+" ver i)) 2979 (while (and (setq s (string-match "[0-9]+" ver i))