diff options
| author | Kim F. Storm | 2005-08-26 12:31:55 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-08-26 12:31:55 +0000 |
| commit | ca548b00f881986a7da85a1af95c50c51b8a5188 (patch) | |
| tree | 21977ea541eb2f272257306879308c9f2ede7049 | |
| parent | 7cb5337343e850063779ec2b3d7353871f04b388 (diff) | |
| download | emacs-ca548b00f881986a7da85a1af95c50c51b8a5188.tar.gz emacs-ca548b00f881986a7da85a1af95c50c51b8a5188.zip | |
(version-list-<, version-list-<=, version-list-=)
Renamed from integer-list-*.
(version-list-not-zero): Likewise. Fix while loop.
(version=): Use version-list-= instead of string-equal.
| -rw-r--r-- | lisp/subr.el | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 290f8c54610..ab0b052dae2 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2851,8 +2851,9 @@ convenience wrapper around `make-progress-reporter' and friends. | |||
| 2851 | (setq ,(car spec) (1+ ,(car spec))))) | 2851 | (setq ,(car spec) (1+ ,(car spec))))) |
| 2852 | (progress-reporter-done ,temp2) | 2852 | (progress-reporter-done ,temp2) |
| 2853 | nil ,@(cdr (cdr spec))))) | 2853 | nil ,@(cdr (cdr spec))))) |
| 2854 | |||
| 2854 | 2855 | ||
| 2855 | ;;;; Integer list & Version funs. | 2856 | ;;;; Compare Version Strings |
| 2856 | 2857 | ||
| 2857 | (defvar version-separator "." | 2858 | (defvar version-separator "." |
| 2858 | "*Specify the string used to separate the version elements. | 2859 | "*Specify the string used to separate the version elements. |
| @@ -2952,7 +2953,7 @@ See documentation for `version-separator' and `version-regexp-alist'." | |||
| 2952 | (nreverse lst))))) | 2953 | (nreverse lst))))) |
| 2953 | 2954 | ||
| 2954 | 2955 | ||
| 2955 | (defun integer-list-< (l1 l2) | 2956 | (defun version-list-< (l1 l2) |
| 2956 | "Return t if integer list L1 is lesser than L2. | 2957 | "Return t if integer list L1 is lesser than L2. |
| 2957 | 2958 | ||
| 2958 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), | 2959 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), |
| @@ -2968,12 +2969,12 @@ which is greater than (1 -3)." | |||
| 2968 | ;; l1 null and l2 null ==> l1 length = l2 length | 2969 | ;; l1 null and l2 null ==> l1 length = l2 length |
| 2969 | ((and (null l1) (null l2)) nil) | 2970 | ((and (null l1) (null l2)) nil) |
| 2970 | ;; l1 not null and l2 null ==> l1 length > l2 length | 2971 | ;; l1 not null and l2 null ==> l1 length > l2 length |
| 2971 | (l1 (< (integer-list-not-zero l1) 0)) | 2972 | (l1 (< (version-list-not-zero l1) 0)) |
| 2972 | ;; l1 null and l2 not null ==> l2 length > l1 length | 2973 | ;; l1 null and l2 not null ==> l2 length > l1 length |
| 2973 | (t (< 0 (integer-list-not-zero l2))))) | 2974 | (t (< 0 (version-list-not-zero l2))))) |
| 2974 | 2975 | ||
| 2975 | 2976 | ||
| 2976 | (defun integer-list-= (l1 l2) | 2977 | (defun version-list-= (l1 l2) |
| 2977 | "Return t if integer list L1 is equal to L2. | 2978 | "Return t if integer list L1 is equal to L2. |
| 2978 | 2979 | ||
| 2979 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), | 2980 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), |
| @@ -2989,12 +2990,12 @@ which is greater than (1 -3)." | |||
| 2989 | ;; l1 null and l2 null ==> l1 length = l2 length | 2990 | ;; l1 null and l2 null ==> l1 length = l2 length |
| 2990 | ((and (null l1) (null l2))) | 2991 | ((and (null l1) (null l2))) |
| 2991 | ;; l1 not null and l2 null ==> l1 length > l2 length | 2992 | ;; l1 not null and l2 null ==> l1 length > l2 length |
| 2992 | (l1 (zerop (integer-list-not-zero l1))) | 2993 | (l1 (zerop (version-list-not-zero l1))) |
| 2993 | ;; l1 null and l2 not null ==> l2 length > l1 length | 2994 | ;; l1 null and l2 not null ==> l2 length > l1 length |
| 2994 | (t (zerop (integer-list-not-zero l2))))) | 2995 | (t (zerop (version-list-not-zero l2))))) |
| 2995 | 2996 | ||
| 2996 | 2997 | ||
| 2997 | (defun integer-list-<= (l1 l2) | 2998 | (defun version-list-<= (l1 l2) |
| 2998 | "Return t if integer list L1 is lesser than or equal to L2. | 2999 | "Return t if integer list L1 is lesser than or equal to L2. |
| 2999 | 3000 | ||
| 3000 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), | 3001 | Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), |
| @@ -3010,15 +3011,20 @@ which is greater than (1 -3)." | |||
| 3010 | ;; l1 null and l2 null ==> l1 length = l2 length | 3011 | ;; l1 null and l2 null ==> l1 length = l2 length |
| 3011 | ((and (null l1) (null l2))) | 3012 | ((and (null l1) (null l2))) |
| 3012 | ;; l1 not null and l2 null ==> l1 length > l2 length | 3013 | ;; l1 not null and l2 null ==> l1 length > l2 length |
| 3013 | (l1 (<= (integer-list-not-zero l1) 0)) | 3014 | (l1 (<= (version-list-not-zero l1) 0)) |
| 3014 | ;; l1 null and l2 not null ==> l2 length > l1 length | 3015 | ;; l1 null and l2 not null ==> l2 length > l1 length |
| 3015 | (t (<= 0 (integer-list-not-zero l2))))) | 3016 | (t (<= 0 (version-list-not-zero l2))))) |
| 3016 | |||
| 3017 | 3017 | ||
| 3018 | (defalias 'version= 'string-equal | 3018 | (defun version-list-not-zero (lst) |
| 3019 | "Return t if version V1 is equal to V2. | 3019 | "Return the first non-zero element of integer list LST. |
| 3020 | 3020 | ||
| 3021 | Compare version string using `string-equal'.") | 3021 | If all LST elements are zeroes or LST is nil, return zero." |
| 3022 | (while (and lst (zerop (car lst))) | ||
| 3023 | (setq lst (cdr lst))) | ||
| 3024 | (if lst | ||
| 3025 | (car lst) | ||
| 3026 | ;; there is no element different of zero | ||
| 3027 | 0)) | ||
| 3022 | 3028 | ||
| 3023 | 3029 | ||
| 3024 | (defun version< (v1 v2) | 3030 | (defun version< (v1 v2) |
| @@ -3028,7 +3034,7 @@ Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", | |||
| 3028 | etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" | 3034 | etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" |
| 3029 | is greater than \"1pre\" which is greater than \"1beta\" which is greater than | 3035 | is greater than \"1pre\" which is greater than \"1beta\" which is greater than |
| 3030 | \"1alpha\"." | 3036 | \"1alpha\"." |
| 3031 | (integer-list-< (version-to-list v1) (version-to-list v2))) | 3037 | (version-list-< (version-to-list v1) (version-to-list v2))) |
| 3032 | 3038 | ||
| 3033 | 3039 | ||
| 3034 | (defun version<= (v1 v2) | 3040 | (defun version<= (v1 v2) |
| @@ -3038,19 +3044,17 @@ Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", | |||
| 3038 | etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" | 3044 | etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" |
| 3039 | is greater than \"1pre\" which is greater than \"1beta\" which is greater than | 3045 | is greater than \"1pre\" which is greater than \"1beta\" which is greater than |
| 3040 | \"1alpha\"." | 3046 | \"1alpha\"." |
| 3041 | (integer-list-<= (version-to-list v1) (version-to-list v2))) | 3047 | (version-list-<= (version-to-list v1) (version-to-list v2))) |
| 3042 | 3048 | ||
| 3049 | (defun version= (v1 v2) | ||
| 3050 | "Return t if version V1 is equal to V2. | ||
| 3043 | 3051 | ||
| 3044 | (defun integer-list-not-zero (lst) | 3052 | Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\", |
| 3045 | "Return the first non-zero element of integer list LST. | 3053 | etc. That is, the trailing \".0\"s are irrelevant. Also, version string \"1\" |
| 3054 | is greater than \"1pre\" which is greater than \"1beta\" which is greater than | ||
| 3055 | \"1alpha\"." | ||
| 3056 | (version-list-= (version-to-list v1) (version-to-list v2))) | ||
| 3046 | 3057 | ||
| 3047 | If all LST elements are zeroes or LST is nil, return zero." | ||
| 3048 | (while (zerop (car lst)) | ||
| 3049 | (setq lst (cdr lst))) | ||
| 3050 | (if lst | ||
| 3051 | (car lst) | ||
| 3052 | ;; there is no element different of zero | ||
| 3053 | 0)) | ||
| 3054 | 3058 | ||
| 3055 | 3059 | ||
| 3056 | ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc | 3060 | ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc |