diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-08 15:43:34 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-08 15:43:34 +0200 |
commit | 2950065e18649d234b16e60dd0e3d75adeca4513 (patch) | |
tree | 022aa2da8ed1f6588ac02d9be71a1d69df89c73b /src/typval.c | |
parent | 267359902c8792fed13543ddeb56c6df0ae74957 (diff) | |
download | vim-git-2950065e18649d234b16e60dd0e3d75adeca4513.tar.gz |
patch 8.2.3315: cannot use single quote in a float number for readabilityv8.2.3315
Problem: Cannot use single quote in a float number for readability.
Solution: Support single quotes like in numbers. (closes #8713)
Diffstat (limited to 'src/typval.c')
-rw-r--r-- | src/typval.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/typval.c b/src/typval.c index e8ce4ea36..389ca3427 100644 --- a/src/typval.c +++ b/src/typval.c @@ -1704,6 +1704,7 @@ eval_number( int want_string UNUSED) { int len; + int skip_quotes = current_sctx.sc_version >= 4; #ifdef FEAT_FLOAT char_u *p; int get_float = FALSE; @@ -1718,7 +1719,20 @@ eval_number( if (**arg == '.') p = *arg; else - p = skipdigits(*arg + 1); + { + p = *arg + 1; + if (skip_quotes) + for (;;) + { + if (*p == '\'') + ++p; + if (!vim_isdigit(*p)) + break; + p = skipdigits(p); + } + else + p = skipdigits(p); + } if (!want_string && p[0] == '.' && vim_isdigit(p[1])) { get_float = TRUE; @@ -1740,7 +1754,7 @@ eval_number( { float_T f; - *arg += string2float(*arg, &f); + *arg += string2float(*arg, &f, skip_quotes); if (evaluate) { rettv->v_type = VAR_FLOAT; @@ -1784,7 +1798,7 @@ eval_number( varnumber_T n; // decimal, hex or octal number - vim_str2nr(*arg, NULL, &len, current_sctx.sc_version >= 4 + vim_str2nr(*arg, NULL, &len, skip_quotes ? STR2NR_NO_OCT + STR2NR_QUOTE : STR2NR_ALL, &n, NULL, 0, TRUE); if (len == 0) |