diff options
author | h-east <h.east.727@gmail.com> | 2023-05-01 22:36:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-01 22:36:56 +0100 |
commit | 17b695190d63b2de745499cb40a383c2672e275e (patch) | |
tree | d67dc346d6b708c36027ead4a30545c90244406c | |
parent | 2dcfe9ae1df61e1249520ed435dd8cf60e157103 (diff) |
patch 9.0.1504: no error when calling remote_startserver("")v9.0.1504
Problem: No error when calling remote_startserver() with an empty string.
Solution: Give an error for an empty string. (Hirohito Higashi,
closes #12327)
-rw-r--r-- | runtime/doc/builtin.txt | 5 | ||||
-rw-r--r-- | src/clientserver.c | 22 | ||||
-rw-r--r-- | src/testdir/test_clientserver.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 17 insertions, 15 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 91d468ee16..dd680069f7 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -7312,8 +7312,9 @@ remote_send({server}, {string} [, {idvar}]) < *remote_startserver()* *E941* *E942* remote_startserver({name}) - Become the server {name}. This fails if already running as a - server, when |v:servername| is not empty. + Become the server {name}. {name} must be a non-empty string. + This fails if already running as a server, when |v:servername| + is not empty. Can also be used as a |method|: > ServerName()->remote_startserver() diff --git a/src/clientserver.c b/src/clientserver.c index dfbb8a8b03..400a4ad3eb 100644 --- a/src/clientserver.c +++ b/src/clientserver.c @@ -968,25 +968,23 @@ f_remote_send(typval_T *argvars UNUSED, typval_T *rettv) f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED) { #ifdef FEAT_CLIENTSERVER - char_u *server; - - if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + if (check_for_nonempty_string_arg(argvars, 0) == FAIL) return; - server = tv_get_string_chk(&argvars[0]); - if (server == NULL) - return; // type error; errmsg already given if (serverName != NULL) - emsg(_(e_already_started_server)); - else { + emsg(_(e_already_started_server)); + return; + } + + char_u *server = tv_get_string_chk(&argvars[0]); # ifdef FEAT_X11 - if (check_connection() == OK) - serverRegisterName(X_DISPLAY, server); + if (check_connection() == OK) + serverRegisterName(X_DISPLAY, server); # else - serverSetName(server); + serverSetName(server); # endif - } + #else emsg(_(e_clientserver_feature_not_available)); #endif diff --git a/src/testdir/test_clientserver.vim b/src/testdir/test_clientserver.vim index 64c9ab8e81..53947f410b 100644 --- a/src/testdir/test_clientserver.vim +++ b/src/testdir/test_clientserver.vim @@ -182,7 +182,8 @@ func Test_client_server() endif endtry - call assert_fails('call remote_startserver([])', 'E730:') + call assert_fails('call remote_startserver("")', 'E1175:') + call assert_fails('call remote_startserver([])', 'E1174:') call assert_fails("let x = remote_peek([])", 'E730:') call assert_fails("let x = remote_read('vim10')", \ has('unix') ? ['E573:.*vim10'] : 'E277:') diff --git a/src/version.c b/src/version.c index 338399c775..2a99c3b3ce 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1504, +/**/ 1503, /**/ 1502, |