From b1d4ef2b420b1fa9826a9e79344adaf71ad27e18 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 5 Jun 2017 21:58:33 -0400 Subject: vim-patch:8.0.0158 Problem: On MS-Windows some float functions return a different value when passed unusual values. strtod() doesn't work for "inf" and "nan". Solution: Accept both results. Fix str2float() for MS-Windows. Also reorder assert function arguments. https://github.com/vim/vim/commit/6247361101dcccc0c877e90ad67cd0cc83df7c68 --- src/nvim/eval.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c9da08acd0..612c3be368 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5898,6 +5898,19 @@ size_t string2float(const char *const text, float_T *const ret_value) { char *s = NULL; + // MS-Windows does not deal with "inf" and "nan" properly + if (STRNICMP(text, "inf", 3) == 0) { + *ret_value = INFINITY; + return 3; + } + if (STRNICMP(text, "-inf", 3) == 0) { + *ret_value = -INFINITY; + return 4; + } + if (STRNICMP(text, "nan", 3) == 0) { + *ret_value = NAN; + return 3; + } *ret_value = strtod(text, &s); return (size_t) (s - text); } -- cgit From 17d616037d9312be6fb99ab559861175a1bc35e6 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 5 Jun 2017 22:39:09 -0400 Subject: vim-patch:8.0.0167 Problem: str2nr() and str2float() do not always work with negative values. Solution: Be more flexible about handling signs. (LemonBoy, closes vim/vim#1332) Add more tests. https://github.com/vim/vim/commit/08243d26d22ad44a857d02c90071578577b8a55d --- src/nvim/eval.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 612c3be368..8cf505587d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15698,11 +15698,15 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_str2float(typval_T *argvars, typval_T *rettv, FunPtr fptr) { char_u *p = skipwhite((const char_u *)tv_get_string(&argvars[0])); + bool isneg = (*p == '-'); - if (*p == '+') { + if (*p == '+' || *p == '-') { p = skipwhite(p + 1); } (void)string2float((char *)p, &rettv->vval.v_float); + if (isneg) { + rettv->vval.v_float *= -1; + } rettv->v_type = VAR_FLOAT; } @@ -15722,7 +15726,8 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) } char_u *p = skipwhite((const char_u *)tv_get_string(&argvars[0])); - if (*p == '+') { + bool isneg = (*p == '-'); + if (*p == '+' || *p == '-') { p = skipwhite(p + 1); } switch (base) { @@ -15743,7 +15748,11 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } vim_str2nr(p, NULL, NULL, what, &n, NULL, 0); - rettv->vval.v_number = n; + if (isneg) { + rettv->vval.v_number = -n; + } else { + rettv->vval.v_number = n; + } } /* -- cgit From cb8efa4fefd845e6cf42c9d14384bd291327cfe8 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 5 Jun 2017 23:05:28 -0400 Subject: vim-patch:8.0.0360 Problem: Sometimes VimL is used, which is confusing. Solution: Consistently use "Vim script". (Hirohito Higashi) https://github.com/vim/vim/commit/b544f3c81f1e6a50322855681ac266ffaa8e313c --- src/nvim/eval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8cf505587d..be08e6a238 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1189,7 +1189,7 @@ int get_spellword(list_T *list, const char **pp) } -// Call some vimL function and return the result in "*rettv". +// Call some vim script function and return the result in "*rettv". // Uses argv[argc] for the function arguments. Only Number and String // arguments are currently supported. // @@ -1257,7 +1257,7 @@ int call_vim_function( } /* - * Call vimL function "func" and return the result as a number. + * Call vim script function "func" and return the result as a number. * Returns -1 when calling the function fails. * Uses argv[argc] for the function arguments. */ @@ -1281,7 +1281,7 @@ call_func_retnr ( return retval; } -/// Call VimL function and return the result as a string +/// Call Vim script function and return the result as a string /// /// @param[in] func Function name. /// @param[in] argc Number of arguments. @@ -1308,7 +1308,7 @@ char *call_func_retstr(const char *const func, const int argc, } /* - * Call vimL function "func" and return the result as a List. + * Call Vim script function "func" and return the result as a List. * Uses argv[argc] for the function arguments. * Returns NULL when there is something wrong. */ -- cgit From dafc14b9691dfa9af143c0372f84b9288163c30a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 5 Jun 2017 23:17:54 -0400 Subject: vim-patch:8.0.0477 Problem: The client-server test may hang when failing. Solution: Set a timer. Add assert_report() https://github.com/vim/vim/commit/42205551b140bee8b419b24abe210f56bb80b35e --- src/nvim/eval.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index be08e6a238..072adb4ebb 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6807,6 +6807,17 @@ static void f_assert_notequal(typval_T *argvars, typval_T *rettv, FunPtr fptr) assert_equal_common(argvars, ASSERT_NOTEQUAL); } +/// "assert_report(msg) +static void f_assert_report(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + garray_T ga; + + prepare_assert_error(&ga); + ga_concat(&ga, (const char_u *)tv_get_string(&argvars[0])); + assert_error(&ga); + ga_clear(&ga); +} + /// "assert_exception(string[, msg])" function static void f_assert_exception(typval_T *argvars, typval_T *rettv, FunPtr fptr) { -- cgit From 5f8411b7bf706210a4ff0960032389d015b88b16 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 6 Jun 2017 05:19:28 -0400 Subject: vim-patch:8.0.0176 Problem: Using :change in between :function and :endfunction fails. Solution: Recognize :change inside a function. (ichizok, closes vim/vim#1374) https://github.com/vim/vim/commit/70bcd7336f9f19304f32c52a86ed5b4b3de852c2 --- src/nvim/eval.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 072adb4ebb..72c00ad10b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19872,9 +19872,15 @@ void ex_function(exarg_T *eap) } } - /* Check for ":append" or ":insert". */ + // Check for ":append", ":change", ":insert". p = skip_range(p, NULL); if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) + || (p[0] == 'c' + && (!ASCII_ISALPHA(p[1]) + || (p[1] == 'h' && (!ASCII_ISALPHA(p[2]) + || (p[2] == 'a' + && (STRNCMP(&p[3], "nge", 3) != 0 + || !ASCII_ISALPHA(p[6]))))))) || (p[0] == 'i' && (!ASCII_ISALPHA(p[1]) || (p[1] == 'n' && (!ASCII_ISALPHA(p[2]) -- cgit From 75c32b549bb505890e657d760e10295cb58cb7fc Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 6 Jun 2017 05:38:34 -0400 Subject: lint --- src/nvim/eval.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 72c00ad10b..59d673fc00 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1256,18 +1256,16 @@ int call_vim_function( return ret; } -/* - * Call vim script function "func" and return the result as a number. - * Returns -1 when calling the function fails. - * Uses argv[argc] for the function arguments. - */ -long -call_func_retnr ( - char_u *func, - int argc, - const char_u *const *const argv, - int safe // use the sandbox -) +/// Call Vim script function and return the result as a number +/// +/// @param[in] func Function name. +/// @param[in] argc Number of arguments. +/// @param[in] argv Array with string arguments. +/// @param[in] safe Use with sandbox. +/// +/// @return -1 when calling function fails, result of function otherwise. +long call_func_retnr(char_u *func, int argc, const char_u *const *const argv, + int safe) { typval_T rettv; long retval; @@ -1288,7 +1286,7 @@ call_func_retnr ( /// @param[in] argv Array with string arguments. /// @param[in] safe Use the sandbox. /// -/// @return [allocated] NULL when calling function failes, allocated string +/// @return [allocated] NULL when calling function fails, allocated string /// otherwise. char *call_func_retstr(const char *const func, const int argc, const char_u *const *const argv, @@ -1307,18 +1305,17 @@ char *call_func_retstr(const char *const func, const int argc, return retval; } -/* - * Call Vim script function "func" and return the result as a List. - * Uses argv[argc] for the function arguments. - * Returns NULL when there is something wrong. - */ -void * -call_func_retlist ( - char_u *func, - int argc, - const char_u *const *const argv, - int safe // use the sandbox -) +/// Call Vim script function and return the result as a List +/// +/// @param[in] func Function name. +/// @param[in] argc Number of arguments. +/// @param[in] argv Array with string arguments. +/// @param[in] safe Use the sandbox. +/// +/// @return [allocated] NULL when calling function fails or return tv is not a +/// List, allocated List otherwise. +void *call_func_retlist(char_u *func, int argc, const char_u *const *const argv, + int safe) { typval_T rettv; -- cgit