diff options
author | K.Takata <kentkt@csc.jp> | 2022-07-30 15:43:59 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-07-30 15:43:59 +0100 |
commit | d90f91fe3075bb51668ed926182b2163da9df001 (patch) | |
tree | 44a94d1432fd4bbae2d1acfba88a8e03f497719e /src/evalfunc.c | |
parent | 0f823c360947779d9de6048c6bce51c670a06eb6 (diff) |
patch 9.0.0113: has() is not strict about parsing the patch versionv9.0.0113
Problem: has() is not strict about parsing the patch version.
Solution: Check the version more strictly. (Ken Takata, closes #10752)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 9b09caab73..ef66aedf9a 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6458,19 +6458,26 @@ f_has(typval_T *argvars, typval_T *rettv) x = TRUE; if (name[5] == '-' && STRLEN(name) >= 11 - && vim_isdigit(name[6]) - && vim_isdigit(name[8]) - && vim_isdigit(name[10])) + && (name[6] >= '1' && name[6] <= '9')) { - int major = atoi((char *)name + 6); - int minor = atoi((char *)name + 8); - - // Expect "patch-9.9.01234". - n = (major < VIM_VERSION_MAJOR - || (major == VIM_VERSION_MAJOR - && (minor < VIM_VERSION_MINOR - || (minor == VIM_VERSION_MINOR - && has_patch(atoi((char *)name + 10)))))); + char *end; + int major, minor; + + // This works for patch-8.1.2, patch-9.0.3, patch-10.0.4, etc. + // Not for patch-9.10.5. + major = (int)strtoul((char *)name + 6, &end, 10); + if (*end == '.' && vim_isdigit(end[1]) + && end[2] == '.' && vim_isdigit(end[3])) + { + minor = atoi(end + 1); + + // Expect "patch-9.9.01234". + n = (major < VIM_VERSION_MAJOR + || (major == VIM_VERSION_MAJOR + && (minor < VIM_VERSION_MINOR + || (minor == VIM_VERSION_MINOR + && has_patch(atoi(end + 3)))))); + } } else if (isdigit(name[5])) n = has_patch(atoi((char *)name + 5)); |