diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index 21ce4ebda8..e80439c361 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -1,4 +1,4 @@ -*channel.txt* For Vim version 7.4. Last change: 2016 Jan 28 +*channel.txt* For Vim version 7.4. Last change: 2016 Jan 31 VIM REFERENCE MANUAL by Bram Moolenaar @@ -48,10 +48,10 @@ And the response is: The number will increase every time you send a message. The server can send a command to Vim. Type this on T1 (literally, including -the quotes): > - NOT IMPLEMENTED YET - ["ex","echo 'hi there'"] -And you should see the message in Vim. +the quotes): + ["ex","echo 'hi there'"] ~ +And you should see the message in Vim. You can move the cursor a word forward: + ["normal","w"] ~ To handle asynchronous communication a callback needs to be used: > func MyHandler(handle, msg) @@ -100,6 +100,14 @@ When {callback} is empty (zero or an empty string) the handler is removed. Once done with the channel, disconnect it like this: > call disconnect(handle) +Currently up to 10 channels can be in use at the same time. *E897* + +When the channel can't be opened you will get an error message. +*E898* *E899* *E900* *E901* *E902* + +If there is an error reading or writing a channel it will be closed. +*E896* *E630* *E631* + ============================================================================== 3. Using a JSON channel *channel-use* @@ -146,36 +154,77 @@ The channel will then be inactive. ============================================================================== 4. Vim commands *channel-commands* -NOT IMPLEMENTED YET +PARTLY IMPLEMENTED: only "ex" and "normal" work With a "json" channel the process can send commands to Vim that will be handled by Vim internally, it does not require a handler for the channel. -Possible commands are: +Possible commands are: *E903* *E904* *E905* + ["redraw" {forced}] ["ex", {Ex command}] ["normal", {Normal mode command}] - ["eval", {number}, {expression}] + ["eval", {expression}, {number}] ["expr", {expression}] With all of these: Be careful what these commands do! You can easily interfere with what the user is doing. To avoid trouble use |mode()| to check that the editor is in the expected state. E.g., to send keys that must be -inserted as text, not executed as a command: > - ["ex","if mode() == 'i' | call feedkeys('ClassName') | endif"] +inserted as text, not executed as a command: + ["ex","if mode() == 'i' | call feedkeys('ClassName') | endif"] ~ + +Errors in these commands are normally not reported to avoid them messing up +the display. If you do want to see them, set the 'verbose' option to 3 or +higher. + + +Command "redraw" ~ + +The other commands do not update the screen, so that you can send a sequence +of commands without the cursor moving around. You must end with the "redraw" +command to show any changed text and show the cursor where it belongs. + +The argument is normally an empty string: + ["redraw", ""] ~ +To first clear the screen pass "force": + ["redraw", "force"] ~ + + +Command "ex" ~ The "ex" command is executed as any Ex command. There is no response for -completion or error. You could use functions in an |autoload| script. -You can also invoke |feedkeys()| to insert anything. +completion or error. You could use functions in an |autoload| script: + ["ex","call myscript#MyFunc(arg)"] -The "normal" command is executed like with |:normal|. +You can also use "call |feedkeys()|" to insert any key sequence. -The "eval" command will result in sending back the result of the expression: + +Command "normal" ~ + +The "normal" command is executed like with |:normal!|, commands are not +mapped. Example to open the folds under the cursor: + ["normal" "zO"] + + +Command "eval" ~ + +The "eval" command an be used to get the result of an expression. For +example, to get the number of lines in the current buffer: + ["eval","line('$')"] ~ + +it will send back the result of the expression: [{number}, {result}] -Here {number} is the same as what was in the request. +Here {number} is the same as what was in the request. Use a negative number +to avoid confusion with message that Vim sends. -The "expr" command is similar, but does not send back any response. +{result} is the result of the evaluation and is JSON encoded. If the +evaluation fails it is the string "ERROR". + + +Command "expr" ~ + +The "expr" command is similar to "eval", but does not send back any response. Example: - ["expr","setline('$', ['one', 'two', 'three'])"] + ["expr","setline('$', ['one', 'two', 'three'])"] ~ ============================================================================== 5. Using a raw channel *channel-raw* diff --git a/runtime/tools/blink.c b/runtime/tools/blink.c index 1ffd848edc..5b5b281723 100644 --- a/runtime/tools/blink.c +++ b/runtime/tools/blink.c @@ -7,6 +7,7 @@ #include + int main() { while (1) @@ -18,4 +19,5 @@ main() fflush(stdout); usleep(250000); /* off time */ } + return 0; } diff --git a/src/Makefile b/src/Makefile index c6b6ff4452..1d9230407c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2663,9 +2663,11 @@ GUI_GTK_RES_INPUTS = \ ../pixmaps/stock_vim_window_split_vertical.png auto/gui_gtk_gresources.c: gui_gtk_res.xml $(GUI_GTK_RES_INPUTS) - $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register $< + $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register gui_gtk_res.xml auto/gui_gtk_gresources.h: gui_gtk_res.xml $(GUI_GTK_RES_INPUTS) - $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register $< + if test -z "$(GLIB_COMPILE_RESOURCES)"; then touch $@; else \ + $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register gui_gtk_res.xml; \ + fi # All the object files are put in the "objects" directory. Since not all make # commands understand putting object files in another directory, it must be diff --git a/src/auto/configure b/src/auto/configure index 54cdef132d..98c775e55a 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -639,7 +639,6 @@ NARROW_PROTO MOTIF_LIBNAME GRESOURCE_OBJ GRESOURCE_SRC -GRESOURCE_HDR GLIB_COMPILE_RESOURCES GNOME_INCLUDEDIR GNOME_LIBDIR @@ -4906,6 +4905,10 @@ fi $as_echo "$enable_luainterp" >&6; } if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + as_fn_error $? "cannot use Lua with tiny or small features" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-lua-prefix argument" >&5 @@ -5646,6 +5649,9 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_perlinterp" >&5 $as_echo "$enable_perlinterp" >&6; } if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + as_fn_error $? "cannot use Perl with tiny or small features" "$LINENO" 5 + fi # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 @@ -7319,8 +7325,14 @@ else fi if test "$enable_netbeans" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot use NetBeans with tiny or small features" >&5 +$as_echo "cannot use NetBeans with tiny or small features" >&6; } + enable_netbeans="no" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -7336,8 +7348,14 @@ else fi if test "$enable_channel" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot use channels with tiny or small features" >&5 +$as_echo "cannot use channels with tiny or small features" >&6; } + enable_channel="no" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } + fi else if test "$enable_netbeans" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, netbeans also disabled" >&5 @@ -9199,7 +9217,6 @@ $as_echo "cannot be found in PATH." >&6; } $as_echo "usable." >&6; } $as_echo "#define USE_GRESOURCE 1" >>confdefs.h - GRESOURCE_HDR="auto/gui_gtk_gresources.h" GRESOURCE_SRC="auto/gui_gtk_gresources.c" GRESOURCE_OBJ="objects/gui_gtk_gresources.o" fi @@ -9217,7 +9234,6 @@ fi - if test -z "$SKIP_MOTIF"; then gui_XXX="/usr/XXX/Motif* /usr/Motif*/XXX /usr/XXX /usr/shlib /usr/X11*/XXX /usr/XXX/X11* /usr/dt/XXX /local/Motif*/XXX /local/XXX/Motif* /usr/local/Motif*/XXX /usr/local/XXX/Motif* /usr/local/XXX /usr/local/X11*/XXX /usr/local/LessTif/Motif*/XXX $MOTIFHOME/XXX" GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`" diff --git a/src/channel.c b/src/channel.c index 0c340e909f..8b27b2489a 100644 --- a/src/channel.c +++ b/src/channel.c @@ -318,14 +318,14 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void)) if (idx < 0) { CHERROR("All channels are in use\n", ""); - EMSG(_("E999: All channels are in use")); + EMSG(_("E897: All channels are in use")); return -1; } if ((sd = (sock_T)socket(AF_INET, SOCK_STREAM, 0)) == (sock_T)-1) { CHERROR("error in socket() in channel_open()\n", ""); - PERROR("E999: socket() in channel_open()"); + PERROR("E898: socket() in channel_open()"); return -1; } @@ -337,7 +337,7 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void)) if ((host = gethostbyname(hostname)) == NULL) { CHERROR("error in gethostbyname() in channel_open()\n", ""); - PERROR("E999: gethostbyname() in channel_open()"); + PERROR("E901: gethostbyname() in channel_open()"); sock_close(sd); return -1; } @@ -355,7 +355,7 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void)) { SOCK_ERRNO; CHERROR("socket() retry in channel_open()\n", ""); - PERROR("E999: socket() retry in channel_open()"); + PERROR("E900: socket() retry in channel_open()"); return -1; } if (connect(sd, (struct sockaddr *)&server, sizeof(server))) @@ -387,7 +387,7 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void)) { /* Get here when the server can't be found. */ CHERROR("Cannot connect to port after retry\n", ""); - PERROR(_("E999: Cannot connect to port after retry2")); + PERROR(_("E899: Cannot connect to port after retry2")); sock_close(sd); return -1; } @@ -396,7 +396,7 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void)) else { CHERROR("Cannot connect to port\n", ""); - PERROR(_("E999: Cannot connect to port")); + PERROR(_("E902: Cannot connect to port")); sock_close(sd); return -1; } @@ -443,13 +443,15 @@ channel_set_req_callback(int idx, char_u *callback) } /* - * Decode JSON "msg", which must have the form "[expr1, expr2]". + * Decode JSON "msg", which must have the form "[expr1, expr2, expr3]". * Put "expr1" in "tv1". * Put "expr2" in "tv2". + * Put "expr3" in "tv3". If "tv3" is NULL there is no "expr3". + * * Return OK or FAIL. */ int -channel_decode_json(char_u *msg, typval_T *tv1, typval_T *tv2) +channel_decode_json(char_u *msg, typval_T *tv1, typval_T *tv2, typval_T *tv3) { js_read_T reader; typval_T listtv; @@ -459,16 +461,31 @@ channel_decode_json(char_u *msg, typval_T *tv1, typval_T *tv2) reader.js_used = 0; json_decode(&reader, &listtv); - if (listtv.v_type == VAR_LIST && listtv.vval.v_list->lv_len == 2) + if (listtv.v_type == VAR_LIST) { - /* Move the item from the list and then change the type to avoid the - * item being freed. */ - *tv1 = listtv.vval.v_list->lv_first->li_tv; - listtv.vval.v_list->lv_first->li_tv.v_type = VAR_NUMBER; - *tv2 = listtv.vval.v_list->lv_last->li_tv; - listtv.vval.v_list->lv_last->li_tv.v_type = VAR_NUMBER; - list_unref(listtv.vval.v_list); - return OK; + list_T *list = listtv.vval.v_list; + + if (list->lv_len == 2 || (tv3 != NULL && list->lv_len == 3)) + { + /* Move the item from the list and then change the type to avoid the + * item being freed. */ + *tv1 = list->lv_first->li_tv; + list->lv_first->li_tv.v_type = VAR_NUMBER; + *tv2 = list->lv_first->li_next->li_tv; + list->lv_first->li_next->li_tv.v_type = VAR_NUMBER; + if (tv3 != NULL) + { + if (list->lv_len == 3) + { + *tv3 = list->lv_last->li_tv; + list->lv_last->li_tv.v_type = VAR_NUMBER; + } + else + tv3->v_type = VAR_UNKNOWN; + } + list_unref(list); + return OK; + } } /* give error message? */ @@ -497,44 +514,86 @@ invoke_callback(int idx, char_u *callback, typval_T *argv) out_flush(); } +/* + * Execute a command received over channel "idx". + * "cmd" is the command string, "arg2" the second argument. + * "arg3" is the third argument, NULL if missing. + */ static void -channel_exe_cmd(char_u *cmd, typval_T *arg) +channel_exe_cmd(int idx, char_u *cmd, typval_T *arg2, typval_T *arg3) { + char_u *arg; + + if (arg2->v_type != VAR_STRING) + { + if (p_verbose > 2) + EMSG("E903: received ex command with non-string argument"); + return; + } + arg = arg2->vval.v_string; + if (STRCMP(cmd, "ex") == 0) { - if (arg->v_type == VAR_STRING) - do_cmdline_cmd(arg->vval.v_string); - else if (p_verbose > 2) - EMSG("E999: received ex command with non-string argument"); + do_cmdline_cmd(arg); } else if (STRCMP(cmd, "normal") == 0) { - if (arg->v_type == VAR_STRING) - { - exarg_T ea; + exarg_T ea; - ea.arg = arg->vval.v_string; - ea.addr_count = 0; - ea.forceit = TRUE; /* no mapping */ - ex_normal(&ea); + ea.arg = arg; + ea.addr_count = 0; + ea.forceit = TRUE; /* no mapping */ + ex_normal(&ea); + } + else if (STRCMP(cmd, "redraw") == 0) + { + exarg_T ea; - update_screen(0); - showruler(FALSE); - setcursor(); - out_flush(); + ea.forceit = *arg != NUL; + ex_redraw(&ea); + showruler(FALSE); + setcursor(); + out_flush(); #ifdef FEAT_GUI - if (gui.in_use) - { - gui_update_cursor(FALSE, FALSE); - gui_mch_flush(); - } -#endif + if (gui.in_use) + { + gui_update_cursor(FALSE, FALSE); + gui_mch_flush(); + } +#endif + } + else if (STRCMP(cmd, "expr") == 0 || STRCMP(cmd, "eval") == 0) + { + int is_eval = cmd[1] == 'v'; + + if (is_eval && arg3->v_type != VAR_NUMBER) + { + if (p_verbose > 2) + EMSG("E904: third argument for eval must be a number"); + } + else + { + typval_T *tv = eval_expr(arg, NULL); + typval_T err_tv; + char_u *json; + + if (is_eval) + { + if (tv == NULL) + { + err_tv.v_type = VAR_STRING; + err_tv.vval.v_string = (char_u *)"ERROR"; + tv = &err_tv; + } + json = json_encode_nr_expr(arg3->vval.v_number, tv); + channel_send(idx, json, "eval"); + vim_free(json); + } + free_tv(tv); } - else if (p_verbose > 2) - EMSG("E999: received normal command with non-string argument"); } else if (p_verbose > 2) - EMSG2("E999: received unknown command: %s", cmd); + EMSG2("E905: received unknown command: %s", cmd); } /* @@ -546,6 +605,7 @@ may_invoke_callback(int idx) char_u *msg; typval_T typetv; typval_T argv[3]; + typval_T arg3; char_u *cmd = NULL; int seq_nr = -1; int ret = OK; @@ -562,9 +622,10 @@ may_invoke_callback(int idx) if (channels[idx].ch_json_mode) { - ret = channel_decode_json(msg, &typetv, &argv[1]); + ret = channel_decode_json(msg, &typetv, &argv[1], &arg3); if (ret == OK) { + /* TODO: error if arg3 is set when it shouldn't? */ if (typetv.v_type == VAR_STRING) cmd = typetv.vval.v_string; else if (typetv.v_type == VAR_NUMBER) @@ -581,7 +642,7 @@ may_invoke_callback(int idx) { if (cmd != NULL) { - channel_exe_cmd(cmd, &argv[1]); + channel_exe_cmd(idx, cmd, &argv[1], &arg3); } else if (channels[idx].ch_req_callback != NULL && seq_nr != 0) { @@ -601,6 +662,7 @@ may_invoke_callback(int idx) { clear_tv(&typetv); clear_tv(&argv[1]); + clear_tv(&arg3); } } @@ -899,7 +961,7 @@ channel_read(int idx) { /* Todo: which channel? */ CHERROR("%s(): cannot from channel\n", "channel_read"); - PERROR(_("E999: read from channel")); + PERROR(_("E896: read from channel")); } } diff --git a/src/charset.c b/src/charset.c index 538d82115a..2414b2a401 100644 --- a/src/charset.c +++ b/src/charset.c @@ -822,14 +822,11 @@ vim_strnsize(char_u *s, int len) else \ return ptr2cells(p); -#if defined(FEAT_VREPLACE) || defined(FEAT_EX_EXTRA) || defined(FEAT_GUI) \ - || defined(FEAT_VIRTUALEDIT) || defined(PROTO) int chartabsize(char_u *p, colnr_T col) { RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, p, col) } -#endif #ifdef FEAT_LINEBREAK static int @@ -1568,7 +1565,6 @@ skiphex(char_u *q) } #endif -#if defined(FEAT_EX_EXTRA) || defined(PROTO) /* * skip to bin digit (or NUL after the string) */ @@ -1607,7 +1603,6 @@ skiptohex(char_u *q) ++p; return p; } -#endif /* * Variant of isdigit() that can handle characters > 0x100. diff --git a/src/config.mk.in b/src/config.mk.in index 6809e25366..15ac329d7a 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -163,7 +163,6 @@ MOTIF_LIBNAME = @MOTIF_LIBNAME@ GTK_LIBNAME = @GTK_LIBNAME@ GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ -GRESOURCE_HDR = @GRESOURCE_HDR@ GRESOURCE_SRC = @GRESOURCE_SRC@ GRESOURCE_OBJ = @GRESOURCE_OBJ@ diff --git a/src/configure.in b/src/configure.in index 17ede21b0b..207a263e18 100644 --- a/src/configure.in +++ b/src/configure.in @@ -509,6 +509,10 @@ AC_ARG_ENABLE(luainterp, AC_MSG_RESULT($enable_luainterp) if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Lua with tiny or small features]) + fi + dnl -- find the lua executable AC_SUBST(vi_cv_path_lua) @@ -969,6 +973,9 @@ AC_ARG_ENABLE(perlinterp, [enable_perlinterp="no"]) AC_MSG_RESULT($enable_perlinterp) if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_ERROR([cannot use Perl with tiny or small features]) + fi AC_SUBST(vi_cv_path_perl) AC_PATH_PROG(vi_cv_path_perl, perl) if test "X$vi_cv_path_perl" != "X"; then @@ -1990,7 +1997,12 @@ AC_ARG_ENABLE(netbeans, [ --disable-netbeans Disable NetBeans integration support.], , [enable_netbeans="yes"]) if test "$enable_netbeans" = "yes"; then - AC_MSG_RESULT(no) + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_RESULT([cannot use NetBeans with tiny or small features]) + enable_netbeans="no" + else + AC_MSG_RESULT(no) + fi else AC_MSG_RESULT(yes) fi @@ -2000,7 +2012,12 @@ AC_ARG_ENABLE(channel, [ --disable-channel Disable process communication support.], , [enable_channel="yes"]) if test "$enable_channel" = "yes"; then - AC_MSG_RESULT(no) + if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then + AC_MSG_RESULT([cannot use channels with tiny or small features]) + enable_channel="no" + else + AC_MSG_RESULT(no) + fi else if test "$enable_netbeans" = "yes"; then AC_MSG_RESULT([yes, netbeans also disabled]) @@ -2676,7 +2693,6 @@ if test "x$GUITYPE" = "xGTK"; then else AC_MSG_RESULT([usable.]) AC_DEFINE(USE_GRESOURCE) - GRESOURCE_HDR="auto/gui_gtk_gresources.h" GRESOURCE_SRC="auto/gui_gtk_gresources.c" GRESOURCE_OBJ="objects/gui_gtk_gresources.o" fi @@ -2688,7 +2704,6 @@ if test "x$GUITYPE" = "xGTK"; then fi fi AC_SUBST(GLIB_COMPILE_RESOURCES) -AC_SUBST(GRESOURCE_HDR) AC_SUBST(GRESOURCE_SRC) AC_SUBST(GRESOURCE_OBJ) diff --git a/src/eval.c b/src/eval.c index 1d9afd9cce..3e62e70881 100644 --- a/src/eval.c +++ b/src/eval.c @@ -919,6 +919,8 @@ eval_init(void) /* add to compat scope dict */ hash_add(&compat_hashtab, p->vv_di.di_key); } + vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; + set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc()); @@ -5999,7 +6001,7 @@ list_free( * It is not initialized, don't forget to set v_lock. */ listitem_T * -listitem_alloc() +listitem_alloc(void) { return (listitem_T *)alloc(sizeof(listitem_T)); } @@ -10900,13 +10902,11 @@ f_filewritable(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = filewritable(get_tv_string(&argvars[0])); } -static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what); - static void -findfilendir(argvars, rettv, find_what) - typval_T *argvars UNUSED; - typval_T *rettv; - int find_what UNUSED; +findfilendir( + typval_T *argvars UNUSED, + typval_T *rettv, + int find_what UNUSED) { #ifdef FEAT_SEARCHPATH char_u *fname; @@ -12862,9 +12862,7 @@ f_has(typval_T *argvars, typval_T *rettv) "emacs_tags", #endif "eval", /* always present, of course! */ -#ifdef FEAT_EX_EXTRA - "ex_extra", -#endif + "ex_extra", /* graduated feature */ #ifdef FEAT_SEARCH_EXTRA "extra_search", #endif @@ -13703,16 +13701,12 @@ get_user_input( if (defstr != NULL) { -# ifdef FEAT_EX_EXTRA int save_ex_normal_busy = ex_normal_busy; ex_normal_busy = 0; -# endif rettv->vval.v_string = getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr, xp_type, xp_arg); -# ifdef FEAT_EX_EXTRA ex_normal_busy = save_ex_normal_busy; -# endif } if (inputdialog && rettv->vval.v_string == NULL && argvars[1].v_type != VAR_UNKNOWN @@ -16930,8 +16924,6 @@ f_sendexpr(typval_T *argvars, typval_T *rettv) { char_u *text; char_u *resp; - typval_T nrtv; - typval_T listtv; typval_T typetv; int ch_idx; @@ -16939,19 +16931,9 @@ f_sendexpr(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; - nrtv.v_type = VAR_NUMBER; - nrtv.vval.v_number = channel_get_id(); - if (rettv_list_alloc(&listtv) == FAIL) + text = json_encode_nr_expr(channel_get_id(), &argvars[1]); + if (text == NULL) return; - if (list_append_tv(listtv.vval.v_list, &nrtv) == FAIL - || list_append_tv(listtv.vval.v_list, &argvars[1]) == FAIL) - { - list_unref(listtv.vval.v_list); - return; - } - - text = json_encode(&listtv); - list_unref(listtv.vval.v_list); ch_idx = send_common(argvars, text, "sendexpr"); if (ch_idx >= 0) @@ -16962,7 +16944,7 @@ f_sendexpr(typval_T *argvars, typval_T *rettv) resp = channel_read_block(ch_idx); if (resp != NULL) { - channel_decode_json(resp, &typetv, rettv); + channel_decode_json(resp, &typetv, rettv, NULL); vim_free(resp); } } @@ -20649,11 +20631,8 @@ set_vim_var_string( char_u *val, int len) /* length of "val" to use or -1 (whole string) */ { - /* Need to do this (at least) once, since we can't initialize a union. - * Will always be invoked when "v:progname" is set. */ - vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; - - vim_free(vimvars[idx].vv_str); + clear_tv(&vimvars[idx].vv_di.di_tv); + vimvars[idx].vv_type = VAR_STRING; if (val == NULL) vimvars[idx].vv_str = NULL; else if (len == -1) @@ -20668,7 +20647,8 @@ set_vim_var_string( void set_vim_var_list(int idx, list_T *val) { - list_unref(vimvars[idx].vv_list); + clear_tv(&vimvars[idx].vv_di.di_tv); + vimvars[idx].vv_type = VAR_LIST; vimvars[idx].vv_list = val; if (val != NULL) ++val->lv_refcount; @@ -20683,7 +20663,8 @@ set_vim_var_dict(int idx, dict_T *val) int todo; hashitem_T *hi; - dict_unref(vimvars[idx].vv_dict); + clear_tv(&vimvars[idx].vv_di.di_tv); + vimvars[idx].vv_type = VAR_DICT; vimvars[idx].vv_dict = val; if (val != NULL) { @@ -21973,6 +21954,7 @@ item_copy( #endif case VAR_STRING: case VAR_FUNC: + case VAR_SPECIAL: copy_tv(from, to); break; case VAR_LIST: diff --git a/src/ex_cmds.c b/src/ex_cmds.c index ba3efac9bb..3efdf8bbbb 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -18,9 +18,7 @@ # include #endif -#ifdef FEAT_EX_EXTRA static int linelen(int *has_tab); -#endif static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, int do_in, int do_out); #ifdef FEAT_VIMINFO static char_u *viminfo_filename(char_u *); @@ -138,7 +136,6 @@ do_ascii(exarg_T *eap UNUSED) msg(IObuff); } -#if defined(FEAT_EX_EXTRA) || defined(PROTO) /* * ":left", ":center" and ":right": align text. */ @@ -787,7 +784,6 @@ ex_retab(exarg_T *eap) u_clearline(); } -#endif /* * :move command - move lines line1-line2 to line dest @@ -6577,7 +6573,6 @@ ex_viusage(exarg_T *eap UNUSED) do_cmdline_cmd((char_u *)"help normal-index"); } -#if defined(FEAT_EX_EXTRA) || defined(PROTO) static void helptags_one(char_u *dir, char_u *ext, char_u *lang, int add_help_tags); /* @@ -6586,19 +6581,19 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *lang, int add_help_ta void ex_helptags(exarg_T *eap) { - garray_T ga; - int i, j; - int len; -#ifdef FEAT_MULTI_LANG - char_u lang[2]; -#endif expand_T xpc; char_u *dirname; + int add_help_tags = FALSE; +#ifdef FEAT_MULTI_LANG + int len; + int i, j; + garray_T ga; + char_u lang[2]; char_u ext[5]; char_u fname[8]; int filecount; char_u **files; - int add_help_tags = FALSE; +#endif /* Check for ":helptags ++t {dir}". */ if (STRNCMP(eap->arg, "++t", 3) == 0 && vim_iswhite(eap->arg[3])) @@ -6962,7 +6957,6 @@ helptags_one( ga_clear(&ga); fclose(fd_tags); /* there is no check for an error... */ } -#endif #if defined(FEAT_SIGNS) || defined(PROTO) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 118867dba0..cf1f9fd05f 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -90,9 +90,7 @@ do_debug(char_u *cmd) tasave_T typeaheadbuf; int typeahead_saved = FALSE; int save_ignore_script = 0; -# ifdef FEAT_EX_EXTRA int save_ex_normal_busy; -# endif int n; char_u *cmdline = NULL; char_u *p; @@ -161,10 +159,8 @@ do_debug(char_u *cmd) * with the commands being executed. Reset "ex_normal_busy" to avoid * the side effects of using ":normal". Save the stuff buffer and make * it empty. Set ignore_script to avoid reading from script input. */ -# ifdef FEAT_EX_EXTRA save_ex_normal_busy = ex_normal_busy; ex_normal_busy = 0; -# endif if (!debug_greedy) { save_typeahead(&typeaheadbuf); @@ -180,9 +176,7 @@ do_debug(char_u *cmd) restore_typeahead(&typeaheadbuf); ignore_script = save_ignore_script; } -# ifdef FEAT_EX_EXTRA ex_normal_busy = save_ex_normal_busy; -# endif cmdline_row = msg_row; msg_starthere(); @@ -3706,10 +3700,7 @@ fgets_cr(char *s, int n, FILE *stream) * At least CodeWarrior 9 needed this code. */ char * -fgets_cr(s, n, stream) - char *s; - int n; - FILE *stream; +fgets_cr(char *s, int n, FILE *stream) { int c = 0; int char_read = 0; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index c3b837f148..4687c92b2a 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -337,7 +337,6 @@ static void ex_rundo(exarg_T *eap); static void ex_redo(exarg_T *eap); static void ex_later(exarg_T *eap); static void ex_redir(exarg_T *eap); -static void ex_redraw(exarg_T *eap); static void ex_redrawstatus(exarg_T *eap); static void close_redir(void); static void ex_mkrc(exarg_T *eap); @@ -346,18 +345,8 @@ static void ex_mark(exarg_T *eap); static char_u *uc_fun_cmd(void); static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *compl); #endif -#ifdef FEAT_EX_EXTRA static void ex_startinsert(exarg_T *eap); static void ex_stopinsert(exarg_T *eap); -#else -# define ex_normal ex_ni -# define ex_align ex_ni -# define ex_retab ex_ni -# define ex_startinsert ex_ni -# define ex_stopinsert ex_ni -# define ex_helptags ex_ni -# define ex_sort ex_ni -#endif #ifdef FEAT_FIND_ID static void ex_checkpath(exarg_T *eap); static void ex_findpat(exarg_T *eap); @@ -666,14 +655,12 @@ do_exmode( MSG(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); while (exmode_active) { -#ifdef FEAT_EX_EXTRA /* Check for a ":normal" command and no more characters left. */ if (ex_normal_busy > 0 && typebuf.tb_len == 0) { exmode_active = FALSE; break; } -#endif msg_scroll = TRUE; need_wait_return = FALSE; ex_pressedreturn = FALSE; @@ -9497,7 +9484,7 @@ ex_redir(exarg_T *eap) /* * ":redraw": force redraw */ - static void + void ex_redraw(exarg_T *eap) { int r = RedrawingDisabled; @@ -9887,7 +9874,6 @@ update_topline_cursor(void) update_curswant(); } -#if defined(FEAT_EX_EXTRA) || defined(PROTO) /* * ":normal[!] {commands}": Execute normal mode commands. */ @@ -10089,9 +10075,7 @@ ex_stopinsert(exarg_T *eap UNUSED) restart_edit = 0; stop_insert_mode = TRUE; } -#endif -#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(PROTO) /* * Execute normal mode command "cmd". * "remap" can be REMAP_NONE or REMAP_YES. @@ -10103,10 +10087,7 @@ exec_normal_cmd(char_u *cmd, int remap, int silent) ins_typebuf(cmd, remap, 0, TRUE, silent); exec_normal(FALSE); } -#endif -#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(FEAT_EVAL) \ - || defined(PROTO) /* * Execute normal_cmd() until there is no typeahead left. */ @@ -10124,7 +10105,6 @@ exec_normal(int was_typed) normal_cmd(&oa, TRUE); /* execute a Normal mode cmd */ } } -#endif #ifdef FEAT_FIND_ID static void diff --git a/src/ex_getln.c b/src/ex_getln.c index 2964b3c178..372e958cfd 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1129,10 +1129,7 @@ getcmdline( /* In exmode it doesn't make sense to return. Except when * ":normal" runs out of characters. */ if (exmode_active -#ifdef FEAT_EX_EXTRA - && (ex_normal_busy == 0 || typebuf.tb_len > 0) -#endif - ) + && (ex_normal_busy == 0 || typebuf.tb_len > 0)) goto cmdline_not_changed; gotesc = TRUE; /* will free ccline.cmdbuff after @@ -5663,7 +5660,7 @@ set_cmdline_pos( * Returns NUL when something is wrong. */ int -get_cmdline_type() +get_cmdline_type(void) { struct cmdline_info *p = get_ccline_ptr(); diff --git a/src/feature.h b/src/feature.h index bd8c0be14b..824f9a0485 100644 --- a/src/feature.h +++ b/src/feature.h @@ -253,13 +253,6 @@ # define FEAT_LINEBREAK #endif -/* - * +ex_extra ":retab", ":right", ":left", ":center", ":normal". - */ -#if defined(FEAT_NORMAL) || defined(FEAT_CHANNEL) -# define FEAT_EX_EXTRA -#endif - /* * +extra_search 'hlsearch' and 'incsearch' options. */ diff --git a/src/fileio.c b/src/fileio.c index a11c6bdcbf..92318862db 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -10025,9 +10025,9 @@ theend: * "curbuf" and "curwin" to match "buf". */ void -aucmd_prepbuf(aco, buf) - aco_save_T *aco; /* structure to save values in */ - buf_T *buf; /* new curbuf */ +aucmd_prepbuf( + aco_save_T *aco, /* structure to save values in */ + buf_T *buf) /* new curbuf */ { aco->save_curbuf = curbuf; --curbuf->b_nwindows; @@ -10041,8 +10041,8 @@ aucmd_prepbuf(aco, buf) * This is the non-autocommand version. */ void -aucmd_restbuf(aco) - aco_save_T *aco; /* structure holding saved values */ +aucmd_restbuf( + aco_save_T *aco) /* structure holding saved values */ { --curbuf->b_nwindows; curbuf = aco->save_curbuf; diff --git a/src/getchar.c b/src/getchar.c index 3fcd30b063..43422148f6 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1356,8 +1356,6 @@ static int old_mouse_row; /* mouse_row related to old_char */ static int old_mouse_col; /* mouse_col related to old_char */ #endif -#if defined(FEAT_EVAL) || defined(FEAT_EX_EXTRA) || defined(PROTO) - /* * Save all three kinds of typeahead, so that the user must type at a prompt. */ @@ -1406,7 +1404,6 @@ restore_typeahead(tasave_T *tp) set_input_buf(tp->save_inputbuf); # endif } -#endif /* * Open a new script file for the ":source!" command. @@ -1981,11 +1978,7 @@ vgetorpeek(int advance) * Using ":normal" can also do this, but it saves the typeahead buffer, * thus it should be OK. But don't get a key from the user then. */ - if (vgetc_busy > 0 -#ifdef FEAT_EX_EXTRA - && ex_normal_busy == 0 -#endif - ) + if (vgetc_busy > 0 && ex_normal_busy == 0) return NUL; local_State = get_real_state(); @@ -2605,9 +2598,7 @@ vgetorpeek(int advance) && typebuf.tb_len == 1 && typebuf.tb_buf[typebuf.tb_off] == ESC && !no_mapping -#ifdef FEAT_EX_EXTRA && ex_normal_busy == 0 -#endif && typebuf.tb_maplen == 0 && (State & INSERT) && (p_timeout @@ -2729,12 +2720,11 @@ vgetorpeek(int advance) continue; } -#ifdef FEAT_EX_EXTRA if (ex_normal_busy > 0) { -# ifdef FEAT_CMDWIN +#ifdef FEAT_CMDWIN static int tc = 0; -# endif +#endif /* No typeahead left and inside ":normal". Must return * something to avoid getting stuck. When an incomplete @@ -2753,19 +2743,18 @@ vgetorpeek(int advance) if (p_im && (State & INSERT)) c = Ctrl_L; else if ((State & CMDLINE) -# ifdef FEAT_CMDWIN +#ifdef FEAT_CMDWIN || (cmdwin_type > 0 && tc == ESC) -# endif +#endif ) c = Ctrl_C; else c = ESC; -# ifdef FEAT_CMDWIN +#ifdef FEAT_CMDWIN tc = c; -# endif +#endif break; } -#endif /* * get a character: 3. from the user - update display @@ -4638,18 +4627,14 @@ eval_map_expr( /* Forbid changing text or using ":normal" to avoid most of the bad side * effects. Also restore the cursor position. */ ++textlock; -#ifdef FEAT_EX_EXTRA ++ex_normal_lock; -#endif set_vim_var_char(c); /* set v:char to the typed character */ save_cursor = curwin->w_cursor; save_msg_col = msg_col; save_msg_row = msg_row; p = eval_to_string(expr, NULL, FALSE); --textlock; -#ifdef FEAT_EX_EXTRA --ex_normal_lock; -#endif curwin->w_cursor = save_cursor; msg_col = save_msg_col; msg_row = save_msg_row; @@ -5340,7 +5325,7 @@ init_mappings(void) #if defined(MSDOS) || defined(MSWIN) ||defined(MACOS) int i; - for (i = 0; i < sizeof(initmappings) / sizeof(struct initmap); ++i) + for (i = 0; i < (int)(sizeof(initmappings) / sizeof(struct initmap)); ++i) add_map(initmappings[i].arg, initmappings[i].mode); #endif } diff --git a/src/globals.h b/src/globals.h index ca3903b930..faa1ec8609 100644 --- a/src/globals.h +++ b/src/globals.h @@ -997,10 +997,8 @@ EXTERN typebuf_T typebuf /* typeahead buffer */ = {NULL, NULL, 0, 0, 0, 0, 0, 0, 0} #endif ; -#ifdef FEAT_EX_EXTRA EXTERN int ex_normal_busy INIT(= 0); /* recursiveness of ex_normal() */ EXTERN int ex_normal_lock INIT(= 0); /* forbid use of ex_normal() */ -#endif #ifdef FEAT_EVAL EXTERN int ignore_script INIT(= FALSE); /* ignore script input */ #endif @@ -1577,9 +1575,7 @@ EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxm EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer")); EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %ld does not exist")); -#ifdef FEAT_EX_EXTRA EXTERN char_u e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter")); -#endif EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); #if defined(FEAT_SYN_HL) || \ (defined(FEAT_INS_EXPAND) && defined(FEAT_COMPL_FUNC)) diff --git a/src/gui_w32.c b/src/gui_w32.c index 6a0e0a3594..05d8e3005e 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -2292,7 +2292,7 @@ im_set_active(int active) * Get IM status. When IM is on, return not 0. Else return 0. */ int -im_get_status() +im_get_status(void) { return global_ime_get_status(); } diff --git a/src/gui_x11.c b/src/gui_x11.c index e6e6f614fa..5a0fe8d527 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -2234,8 +2234,7 @@ fontset_height2(XFontSet fs) /* NOT USED YET static int -fontset_descent(fs) - XFontSet fs; +fontset_descent(XFontSet fs) { XFontSetExtents *extents; diff --git a/src/if_perl.xs b/src/if_perl.xs index f37f416117..b723dcbe5b 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -631,8 +631,7 @@ perl_runtime_link_init(char *libname, int verbose) * There were no DLL loaded, return FALSE. */ int -perl_enabled(verbose) - int verbose; +perl_enabled(int verbose) { return perl_runtime_link_init((char *)p_perldll, verbose) == OK; } @@ -644,7 +643,7 @@ perl_enabled(verbose) * there's nothing to actually parse. */ static void -perl_init() +perl_init(void) { char *bootargs[] = { "VI", NULL }; int argc = 3; @@ -670,7 +669,7 @@ perl_init() * perl_end(): clean up after ourselves */ void -perl_end() +perl_end(void) { if (perl_interp) { @@ -696,9 +695,9 @@ perl_end() * split at '\n' first though. */ void -msg_split(s, attr) - char_u *s; - int attr; /* highlighting attributes */ +msg_split( + char_u *s, + int attr) /* highlighting attributes */ { char *next; char *token = (char *)s; @@ -719,10 +718,10 @@ msg_split(s, attr) * work properly. */ char_u * -eval_to_string(arg, nextcmd, dolist) - char_u *arg UNUSED; - char_u **nextcmd UNUSED; - int dolist UNUSED; +eval_to_string( + char_u *arg UNUSED, + char_u **nextcmd UNUSED, + int dolist UNUSED) { return NULL; } @@ -740,9 +739,7 @@ eval_to_string(arg, nextcmd, dolist) */ static SV * -newWINrv(rv, ptr) - SV *rv; - win_T *ptr; +newWINrv(SV *rv, win_T *ptr) { sv_upgrade(rv, SVt_RV); if (ptr->w_perl_private == NULL) @@ -758,9 +755,7 @@ newWINrv(rv, ptr) } static SV * -newBUFrv(rv, ptr) - SV *rv; - buf_T *ptr; +newBUFrv(SV *rv, buf_T *ptr) { sv_upgrade(rv, SVt_RV); if (ptr->b_perl_private == NULL) @@ -780,8 +775,7 @@ newBUFrv(rv, ptr) * Remove all references to the window to be destroyed */ void -perl_win_free(wp) - win_T *wp; +perl_win_free(win_T *wp) { if (wp->w_perl_private) sv_setiv((SV *)wp->w_perl_private, 0); @@ -789,8 +783,7 @@ perl_win_free(wp) } void -perl_buf_free(bp) - buf_T *bp; +perl_buf_free(buf_T *bp) { if (bp->b_perl_private) sv_setiv((SV *)bp->b_perl_private, 0); @@ -834,7 +827,7 @@ struct ufuncs cb_funcs = { cur_val, 0, 1 }; * Make the magical main::curwin and main::curbuf variables */ static void -VIM_init() +VIM_init(void) { static char cw[] = "main::curwin"; static char cb[] = "main::curbuf"; @@ -866,8 +859,7 @@ static char *e_noperl = N_("Sorry, this command is disabled: the Perl library co * ":perl" */ void -ex_perl(eap) - exarg_T *eap; +ex_perl(exarg_T *eap) { char *err; char *script; @@ -947,8 +939,7 @@ ex_perl(eap) } static int -replace_line(line, end) - linenr_T *line, *end; +replace_line(linenr_T *line, linenr_T *end) { char *str; @@ -989,8 +980,7 @@ ref_map_free(void) } static struct ref_map_S * -ref_map_find_SV(sv) - SV *const sv; +ref_map_find_SV(SV *const sv) { struct ref_map_S *refs = ref_map; int count = 350; @@ -1016,9 +1006,7 @@ ref_map_find_SV(sv) } static int -perl_to_vim(sv, rettv) - SV *sv; - typval_T *rettv; +perl_to_vim(SV *sv, typval_T *rettv) { if (SvROK(sv)) sv = SvRV(sv); @@ -1171,9 +1159,7 @@ perl_to_vim(sv, rettv) * "perleval()" */ void -do_perleval(str, rettv) - char_u *str; - typval_T *rettv; +do_perleval(char_u *str, typval_T *rettv) { char *err = NULL; STRLEN err_len = 0; @@ -1241,8 +1227,7 @@ do_perleval(str, rettv) * ":perldo". */ void -ex_perldo(eap) - exarg_T *eap; +ex_perldo(exarg_T *eap) { STRLEN length; SV *sv; @@ -1314,9 +1299,21 @@ err: } #ifndef FEAT_WINDOWS -int win_valid(win_T *w) { return TRUE; } -int win_count() { return 1; } -win_T *win_find_nr(int n) { return curwin; } + int +win_valid(win_T *w) +{ + return TRUE; +} + int +win_count(void) +{ + return 1; +} + win_T * +win_find_nr(int n) +{ + return curwin; +} #endif XS(boot_VIM); @@ -1513,8 +1510,7 @@ SetHeight(win, height) curwin = savewin; void -Cursor(win, ...) - VIWIN win +Cursor(VIWIN win, ...) PPCODE: if (items == 1) diff --git a/src/json.c b/src/json.c index 7256a8ceda..a56104217c 100644 --- a/src/json.c +++ b/src/json.c @@ -33,6 +33,33 @@ json_encode(typval_T *val) return ga.ga_data; } +/* + * Encode ["nr", "val"] into a JSON format string. + * Returns NULL when out of memory. + */ + char_u * +json_encode_nr_expr(int nr, typval_T *val) +{ + typval_T listtv; + typval_T nrtv; + char_u *text; + + nrtv.v_type = VAR_NUMBER; + nrtv.vval.v_number = nr; + if (rettv_list_alloc(&listtv) == FAIL) + return NULL; + if (list_append_tv(listtv.vval.v_list, &nrtv) == FAIL + || list_append_tv(listtv.vval.v_list, val) == FAIL) + { + list_unref(listtv.vval.v_list); + return NULL; + } + + text = json_encode(&listtv); + list_unref(listtv.vval.v_list); + return text; +} + static void write_string(garray_T *gap, char_u *str) { diff --git a/src/normal.c b/src/normal.c index d52b7bbea4..eab436f507 100644 --- a/src/normal.c +++ b/src/normal.c @@ -8958,11 +8958,7 @@ nv_esc(cmdarg_T *cap) /* A CTRL-C is often used at the start of a menu. When 'insertmode' is * set return to Insert mode afterwards. */ - if (restart_edit == 0 && goto_im() -#ifdef FEAT_EX_EXTRA - && ex_normal_busy == 0 -#endif - ) + if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) restart_edit = 'a'; } diff --git a/src/os_macosx.m b/src/os_macosx.m index 00358290b8..d5d0cfe1e2 100644 --- a/src/os_macosx.m +++ b/src/os_macosx.m @@ -37,13 +37,13 @@ NSString *VimPboardType = @"VimPboardType"; void -clip_mch_lose_selection(VimClipboard *cbd) +clip_mch_lose_selection(VimClipboard *cbd UNUSED) { } int -clip_mch_own_selection(VimClipboard *cbd) +clip_mch_own_selection(VimClipboard *cbd UNUSED) { /* This is called whenever there is a new selection and 'guioptions' * contains the "a" flag (automatically copy selection). Return TRUE, else diff --git a/src/os_unix.c b/src/os_unix.c index b9c70de990..e0f29f798b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2041,15 +2041,13 @@ set_x11_icon(char_u *icon) #else /* FEAT_X11 */ static int -get_x11_title(test_only) - int test_only UNUSED; +get_x11_title(int test_only UNUSED) { return FALSE; } static int -get_x11_icon(test_only) - int test_only; +get_x11_icon(int test_only) { if (!test_only) { @@ -2335,9 +2333,7 @@ mch_get_host_name(char_u *s, int len) # endif void -mch_get_host_name(s, len) - char_u *s; - int len; +mch_get_host_name(char_u *s, int len) { # ifdef VAXC vaxc$gethostname((char *)s, len); @@ -2745,9 +2741,7 @@ mch_copy_sec(char_u *from_file, char_u *to_file) * Copy security info from "from_file" to "to_file". */ void -mch_copy_sec(from_file, to_file) - char_u *from_file; - char_u *to_file; +mch_copy_sec(char_u *from_file, char_u *to_file) { static const char * const smack_copied_attributes[] = { diff --git a/src/po/sjiscorr.c b/src/po/sjiscorr.c index a0b09f02f3..2f55b9ec3e 100644 --- a/src/po/sjiscorr.c +++ b/src/po/sjiscorr.c @@ -7,7 +7,7 @@ #include int -main(int argc, char **argv); +main(int argc, char **argv) { char buffer[BUFSIZ]; char *p; diff --git a/src/proto/channel.pro b/src/proto/channel.pro index bf3d93e5fe..e0fbda891d 100644 --- a/src/proto/channel.pro +++ b/src/proto/channel.pro @@ -4,7 +4,7 @@ int channel_open(char *hostname, int port_in, void (*close_cb)(void)); void channel_set_json_mode(int idx, int json_mode); void channel_set_callback(int idx, char_u *callback); void channel_set_req_callback(int idx, char_u *callback); -int channel_decode_json(char_u *msg, typval_T *tv1, typval_T *tv2); +int channel_decode_json(char_u *msg, typval_T *tv1, typval_T *tv2, typval_T *tv3); int channel_is_open(int idx); void channel_close(int idx); int channel_save(int idx, char_u *buf, int len); diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro index 0ba0fd711e..6ff1588e9e 100644 --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -46,6 +46,7 @@ void post_chdir(int local); void ex_cd(exarg_T *eap); void do_sleep(long msec); void ex_may_print(exarg_T *eap); +void ex_redraw(exarg_T *eap); int vim_mkdir_emsg(char_u *name, int prot); FILE *open_exfile(char_u *fname, int forceit, char *mode); void update_topline_cursor(void); diff --git a/src/proto/json.pro b/src/proto/json.pro index 06635456b0..48ce9ade93 100644 --- a/src/proto/json.pro +++ b/src/proto/json.pro @@ -1,4 +1,5 @@ /* json.c */ char_u *json_encode(typval_T *val); +char_u *json_encode_nr_expr(int nr, typval_T *val); void json_decode(js_read_T *reader, typval_T *res); /* vim: set ft=c : */ diff --git a/src/pty.c b/src/pty.c index 833b2d6418..853c90cb4c 100644 --- a/src/pty.c +++ b/src/pty.c @@ -195,8 +195,7 @@ OpenPTY(char **ttyn) && !defined(PTY_DONE) #define PTY_DONE int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { char *m, *s; int f; @@ -220,8 +219,7 @@ OpenPTY(ttyn) #if defined(__sgi) && !defined(PTY_DONE) #define PTY_DONE int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { int f; char *name; @@ -246,8 +244,7 @@ OpenPTY(ttyn) #if defined(MIPS) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE) #define PTY_DONE int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { int f; struct stat buf; @@ -274,8 +271,7 @@ OpenPTY(ttyn) * Same for Mac OS X Leopard. */ #define PTY_DONE int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { int f; char *m; @@ -316,8 +312,7 @@ int aixhack = -1; #endif int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { int f; /* used for opening a new pty-pair: */ @@ -363,8 +358,7 @@ static char TtyProto[] = "/dev/ttyXY"; # endif int -OpenPTY(ttyn) - char **ttyn; +OpenPTY(char **ttyn) { char *p, *q, *l, *d; int f; diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index 70a303ffcd..22046e2b8d 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -37,6 +37,15 @@ func Test_assert_exception() endtry endfunc +func Test_wrong_error_type() + let save_verrors = v:errors + let v:['errors'] = {'foo': 3} + call assert_equal('yes', 'no') + let verrors = v:errors + let v:errors = save_verrors + call assert_equal(type([]), type(verrors)) +endfunc + func Test_user_is_happy() smile sleep 300m diff --git a/src/testdir/test_viml.vim b/src/testdir/test_viml.vim index f7b34146ac..6c755bb534 100644 --- a/src/testdir/test_viml.vim +++ b/src/testdir/test_viml.vim @@ -1001,6 +1001,16 @@ func Test_type() call assert_equal(v:none, eval(string(v:none))) call assert_equal(v:null, eval(string(v:null))) + call assert_equal(v:false, copy(v:false)) + call assert_equal(v:true, copy(v:true)) + call assert_equal(v:none, copy(v:none)) + call assert_equal(v:null, copy(v:null)) + + call assert_equal([v:false], deepcopy([v:false])) + call assert_equal([v:true], deepcopy([v:true])) + call assert_equal([v:none], deepcopy([v:none])) + call assert_equal([v:null], deepcopy([v:null])) + call assert_true(empty(v:false)) call assert_false(empty(v:true)) call assert_true(empty(v:null)) diff --git a/src/ui.c b/src/ui.c index 49eaae2322..645aaea1ca 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1600,7 +1600,6 @@ vim_used_in_input_buf(void) } #endif -#if defined(FEAT_EVAL) || defined(FEAT_EX_EXTRA) || defined(PROTO) /* * Return the current contents of the input buffer and make it empty. * The returned pointer must be passed to set_input_buf() later. @@ -1644,7 +1643,6 @@ set_input_buf(char_u *p) vim_free(gap); } } -#endif #if defined(FEAT_GUI) \ || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE) \ @@ -1721,15 +1719,12 @@ push_raw_key(char_u *s, int len) } #endif -#if defined(FEAT_GUI) || defined(FEAT_EVAL) || defined(FEAT_EX_EXTRA) \ - || defined(PROTO) /* Remove everything from the input buffer. Called when ^C is found */ void trash_input_buf(void) { inbufcount = 0; } -#endif /* * Read as much data from the input buffer as possible up to maxlen, and store diff --git a/src/version.c b/src/version.c index 6811a54fba..f8716b2a15 100644 --- a/src/version.c +++ b/src/version.c @@ -221,11 +221,7 @@ static char *(features[]) = #else "-eval", #endif -#ifdef FEAT_EX_EXTRA "+ex_extra", -#else - "-ex_extra", -#endif #ifdef FEAT_SEARCH_EXTRA "+extra_search", #else @@ -761,6 +757,26 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1229, +/**/ + 1228, +/**/ + 1227, +/**/ + 1226, +/**/ + 1225, +/**/ + 1224, +/**/ + 1223, +/**/ + 1222, +/**/ + 1221, +/**/ + 1220, /**/ 1219, /**/