changeset 32345:2fee2d1b498e v9.0.1504

patch 9.0.1504: no error when calling remote_startserver("") Commit: https://github.com/vim/vim/commit/17b695190d63b2de745499cb40a383c2672e275e Author: h-east <h.east.727@gmail.com> Date: Mon May 1 22:36:56 2023 +0100 patch 9.0.1504: no error when calling remote_startserver("") Problem: No error when calling remote_startserver() with an empty string. Solution: Give an error for an empty string. (Hirohito Higashi, closes #12327)
author Bram Moolenaar <Bram@vim.org>
date Mon, 01 May 2023 23:45:05 +0200
parents d0d70d51fbe1
children 0e2ba4c8b1c1
files runtime/doc/builtin.txt src/clientserver.c src/testdir/test_clientserver.vim src/version.c
diffstat 4 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -968,25 +968,23 @@ f_remote_send(typval_T *argvars UNUSED, 
 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
--- 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:')
--- 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,