]> granicus.if.org Git - vim/commitdiff
patch 9.0.1132: code is indented more than needed v9.0.1132
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 2 Jan 2023 16:54:53 +0000 (16:54 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 2 Jan 2023 16:54:53 +0000 (16:54 +0000)
Problem:    Code is indented more than needed.
Solution:   Use an early return to reduce indentation. (Yegappan Lakshmanan,
            closes #11769)

13 files changed:
src/arglist.c
src/buffer.c
src/clientserver.c
src/dosinst.c
src/evalfunc.c
src/evalvars.c
src/evalwindow.c
src/ex_docmd.c
src/ex_getln.c
src/fileio.c
src/float.c
src/fold.c
src/version.c

index 6183fafff69e14269a3dd4f334d8cb28c38699d4..bb31c45e93f4286d7a3394a01bbab5d455329f12 100644 (file)
@@ -693,56 +693,56 @@ do_argfile(exarg_T *eap, int argn)
            emsg(_(e_cannot_go_before_first_file));
        else
            emsg(_(e_cannot_go_beyond_last_file));
+
+       return;
     }
-    else
-    {
-       setpcmark();
+
+    setpcmark();
 #ifdef FEAT_GUI
-       need_mouse_correct = TRUE;
+    need_mouse_correct = TRUE;
 #endif
 
-       // split window or create new tab page first
-       if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
-       {
-           if (win_split(0, 0) == FAIL)
-               return;
-           RESET_BINDING(curwin);
-       }
-       else
+    // split window or create new tab page first
+    if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
+    {
+       if (win_split(0, 0) == FAIL)
+           return;
+       RESET_BINDING(curwin);
+    }
+    else
+    {
+       // if 'hidden' set, only check for changed file when re-editing
+       // the same buffer
+       other = TRUE;
+       if (buf_hide(curbuf))
        {
-           // if 'hidden' set, only check for changed file when re-editing
-           // the same buffer
-           other = TRUE;
-           if (buf_hide(curbuf))
-           {
-               p = fix_fname(alist_name(&ARGLIST[argn]));
-               other = otherfile(p);
-               vim_free(p);
-           }
-           if ((!buf_hide(curbuf) || !other)
-                 && check_changed(curbuf, CCGD_AW
-                                        | (other ? 0 : CCGD_MULTWIN)
-                                        | (eap->forceit ? CCGD_FORCEIT : 0)
-                                        | CCGD_EXCMD))
-               return;
+           p = fix_fname(alist_name(&ARGLIST[argn]));
+           other = otherfile(p);
+           vim_free(p);
        }
-
-       curwin->w_arg_idx = argn;
-       if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
-           arg_had_last = TRUE;
-
-       // Edit the file; always use the last known line number.
-       // When it fails (e.g. Abort for already edited file) restore the
-       // argument index.
-       if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
-                     eap, ECMD_LAST,
-                     (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
-                        + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
-           curwin->w_arg_idx = old_arg_idx;
-       // like Vi: set the mark where the cursor is in the file.
-       else if (eap->cmdidx != CMD_argdo)
-           setmark('\'');
+       if ((!buf_hide(curbuf) || !other)
+               && check_changed(curbuf, CCGD_AW
+                   | (other ? 0 : CCGD_MULTWIN)
+                   | (eap->forceit ? CCGD_FORCEIT : 0)
+                   | CCGD_EXCMD))
+           return;
     }
+
+    curwin->w_arg_idx = argn;
+    if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
+       arg_had_last = TRUE;
+
+    // Edit the file; always use the last known line number.
+    // When it fails (e.g. Abort for already edited file) restore the
+    // argument index.
+    if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
+               eap, ECMD_LAST,
+               (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
+               + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
+       curwin->w_arg_idx = old_arg_idx;
+    // like Vi: set the mark where the cursor is in the file.
+    else if (eap->cmdidx != CMD_argdo)
+       setmark('\'');
 }
 
 /*
index 7e4772921a4798e0529b5c817ea96e5faa5d0614..98568987894eae587a9c90aafee78505464afa60 100644 (file)
@@ -146,19 +146,19 @@ read_buffer(
     void
 buffer_ensure_loaded(buf_T *buf)
 {
-    if (buf->b_ml.ml_mfp == NULL)
-    {
-       aco_save_T      aco;
+    if (buf->b_ml.ml_mfp != NULL)
+       return;
 
-       // Make sure the buffer is in a window.  If not then skip it.
-       aucmd_prepbuf(&aco, buf);
-       if (curbuf == buf)
-       {
-           if (swap_exists_action != SEA_READONLY)
-               swap_exists_action = SEA_NONE;
-           open_buffer(FALSE, NULL, 0);
-           aucmd_restbuf(&aco);
-       }
+    aco_save_T aco;
+
+    // Make sure the buffer is in a window.  If not then skip it.
+    aucmd_prepbuf(&aco, buf);
+    if (curbuf == buf)
+    {
+       if (swap_exists_action != SEA_READONLY)
+           swap_exists_action = SEA_NONE;
+       open_buffer(FALSE, NULL, 0);
+       aucmd_restbuf(&aco);
     }
 }
 #endif
@@ -3582,18 +3582,18 @@ buf_set_name(int fnum, char_u *name)
     buf_T      *buf;
 
     buf = buflist_findnr(fnum);
-    if (buf != NULL)
-    {
-       if (buf->b_sfname != buf->b_ffname)
-           vim_free(buf->b_sfname);
-       vim_free(buf->b_ffname);
-       buf->b_ffname = vim_strsave(name);
-       buf->b_sfname = NULL;
-       // Allocate ffname and expand into full path.  Also resolves .lnk
-       // files on Win32.
-       fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
-       buf->b_fname = buf->b_sfname;
-    }
+    if (buf == NULL)
+       return;
+
+    if (buf->b_sfname != buf->b_ffname)
+       vim_free(buf->b_sfname);
+    vim_free(buf->b_ffname);
+    buf->b_ffname = vim_strsave(name);
+    buf->b_sfname = NULL;
+    // Allocate ffname and expand into full path.  Also resolves .lnk
+    // files on Win32.
+    fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
+    buf->b_fname = buf->b_sfname;
 }
 
 /*
@@ -5921,14 +5921,14 @@ buf_get_fname(buf_T *buf)
     void
 set_buflisted(int on)
 {
-    if (on != curbuf->b_p_bl)
-    {
-       curbuf->b_p_bl = on;
-       if (on)
-           apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
-       else
-           apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
-    }
+    if (on == curbuf->b_p_bl)
+       return;
+
+    curbuf->b_p_bl = on;
+    if (on)
+       apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
+    else
+       apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
 }
 
 /*
index ccb723872558614750b0b2eeca3b209ddf880662..2a091a6e97cdaecb1162d40178397589f5ccae33 100644 (file)
@@ -191,38 +191,38 @@ static char_u *build_drop_cmd(int filec, char **filev, int tabs, int sendReply);
     void
 exec_on_server(mparm_T *parmp)
 {
-    if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL)
-    {
+    if (parmp->serverName_arg != NULL && *parmp->serverName_arg == NUL)
+       return;
+
 # ifdef MSWIN
-       // Initialise the client/server messaging infrastructure.
-       serverInitMessaging();
+    // Initialise the client/server messaging infrastructure.
+    serverInitMessaging();
 # endif
 
-       /*
-        * When a command server argument was found, execute it.  This may
-        * exit Vim when it was successful.  Otherwise it's executed further
-        * on.  Remember the encoding used here in "serverStrEnc".
-        */
-       if (parmp->serverArg)
-       {
-           cmdsrv_main(&parmp->argc, parmp->argv,
-                                   parmp->serverName_arg, &parmp->serverStr);
-           parmp->serverStrEnc = vim_strsave(p_enc);
-       }
+    /*
+     * When a command server argument was found, execute it.  This may
+     * exit Vim when it was successful.  Otherwise it's executed further
+     * on.  Remember the encoding used here in "serverStrEnc".
+     */
+    if (parmp->serverArg)
+    {
+       cmdsrv_main(&parmp->argc, parmp->argv,
+               parmp->serverName_arg, &parmp->serverStr);
+       parmp->serverStrEnc = vim_strsave(p_enc);
+    }
 
-       // If we're still running, get the name to register ourselves.
-       // On Win32 can register right now, for X11 need to setup the
-       // clipboard first, it's further down.
-       parmp->servername = serverMakeName(parmp->serverName_arg,
-                                                             parmp->argv[0]);
+    // If we're still running, get the name to register ourselves.
+    // On Win32 can register right now, for X11 need to setup the
+    // clipboard first, it's further down.
+    parmp->servername = serverMakeName(parmp->serverName_arg,
+           parmp->argv[0]);
 # ifdef MSWIN
-       if (parmp->servername != NULL)
-       {
-           serverSetName(parmp->servername);
-           vim_free(parmp->servername);
-       }
-# endif
+    if (parmp->servername != NULL)
+    {
+       serverSetName(parmp->servername);
+       vim_free(parmp->servername);
     }
+# endif
 }
 
 /*
index 60e3c649ac39936bcbe60f94e15168490add95cc..4eae5aadc4c27d9042a4690a655812ba1acc5d59 100644 (file)
@@ -830,87 +830,88 @@ install_bat_choice(int idx)
     char       *vimarg = targets[choices[idx].arg].exearg;
     FILE       *fd;
 
-    if (*batpath != NUL)
+    if (*batpath == NUL)
+       return;
+
+    fd = fopen(batpath, "w");
+    if (fd == NULL)
     {
-       fd = fopen(batpath, "w");
-       if (fd == NULL)
-           printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
-       else
-       {
-           need_uninstall_entry = 1;
-
-           fprintf(fd, "@echo off\n");
-           fprintf(fd, "rem -- Run Vim --\n");
-           fprintf(fd, VIMBAT_UNINSTKEY "\n");
-           fprintf(fd, "\n");
-           fprintf(fd, "setlocal\n");
-
-           /*
-            * Don't use double quotes for the "set" argument, also when it
-            * contains a space.  The quotes would be included in the value.
-            * The order of preference is:
-            * 1. $VIMRUNTIME/vim.exe       (user preference)
-            * 2. $VIM/vim81/vim.exe        (hard coded version)
-            * 3. installdir/vim.exe        (hard coded install directory)
-            */
-           fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
-           fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
-                              VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
-           fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
-           fprintf(fd, "\n");
-
-           // Give an error message when the executable could not be found.
-           fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
-           fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
-           fprintf(fd, "    goto :eof\n");
-           fprintf(fd, ")\n");
-           fprintf(fd, "\n");
-
-           if (*exename == 'g')
-           {
-               fprintf(fd, "rem check --nofork argument\n");
-               fprintf(fd, "set VIMNOFORK=\n");
-               fprintf(fd, ":loopstart\n");
-               fprintf(fd, "if .%%1==. goto loopend\n");
-               fprintf(fd, "if .%%1==.--nofork (\n");
-               fprintf(fd, "    set VIMNOFORK=1\n");
-               fprintf(fd, ") else if .%%1==.-f (\n");
-               fprintf(fd, "    set VIMNOFORK=1\n");
-               fprintf(fd, ")\n");
-               fprintf(fd, "shift\n");
-               fprintf(fd, "goto loopstart\n");
-               fprintf(fd, ":loopend\n");
-               fprintf(fd, "\n");
-           }
+       printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
+       return;
+    }
 
-           if (*exename == 'g')
-           {
-               // For gvim.exe use "start /b" to avoid that the console window
-               // stays open.
-               fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
-               fprintf(fd, "    start \"dummy\" /b /wait ");
-               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
-               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-                                                            exename, vimarg);
-               fprintf(fd, ") else (\n");
-               fprintf(fd, "    start \"dummy\" /b ");
-               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
-               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-                                                            exename, vimarg);
-               fprintf(fd, ")\n");
-           }
-           else
-           {
-               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
-               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-                                                            exename, vimarg);
-           }
+    need_uninstall_entry = 1;
 
-           fclose(fd);
-           printf("%s has been %s\n", batpath,
-                                oldname == NULL ? "created" : "overwritten");
-       }
+    fprintf(fd, "@echo off\n");
+    fprintf(fd, "rem -- Run Vim --\n");
+    fprintf(fd, VIMBAT_UNINSTKEY "\n");
+    fprintf(fd, "\n");
+    fprintf(fd, "setlocal\n");
+
+    /*
+     * Don't use double quotes for the "set" argument, also when it
+     * contains a space.  The quotes would be included in the value.
+     * The order of preference is:
+     * 1. $VIMRUNTIME/vim.exe      (user preference)
+     * 2. $VIM/vim81/vim.exe       (hard coded version)
+     * 3. installdir/vim.exe       (hard coded install directory)
+     */
+    fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
+    fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
+           VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
+    fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
+    fprintf(fd, "\n");
+
+    // Give an error message when the executable could not be found.
+    fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
+    fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
+    fprintf(fd, "    goto :eof\n");
+    fprintf(fd, ")\n");
+    fprintf(fd, "\n");
+
+    if (*exename == 'g')
+    {
+       fprintf(fd, "rem check --nofork argument\n");
+       fprintf(fd, "set VIMNOFORK=\n");
+       fprintf(fd, ":loopstart\n");
+       fprintf(fd, "if .%%1==. goto loopend\n");
+       fprintf(fd, "if .%%1==.--nofork (\n");
+       fprintf(fd, "    set VIMNOFORK=1\n");
+       fprintf(fd, ") else if .%%1==.-f (\n");
+       fprintf(fd, "    set VIMNOFORK=1\n");
+       fprintf(fd, ")\n");
+       fprintf(fd, "shift\n");
+       fprintf(fd, "goto loopstart\n");
+       fprintf(fd, ":loopend\n");
+       fprintf(fd, "\n");
+    }
+
+    if (*exename == 'g')
+    {
+       // For gvim.exe use "start /b" to avoid that the console window
+       // stays open.
+       fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
+       fprintf(fd, "    start \"dummy\" /b /wait ");
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+       fprintf(fd, ") else (\n");
+       fprintf(fd, "    start \"dummy\" /b ");
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+       fprintf(fd, ")\n");
     }
+    else
+    {
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+    }
+
+    fclose(fd);
+    printf("%s has been %s\n", batpath,
+           oldname == NULL ? "created" : "overwritten");
 }
 
 /*
index 314a3f863d04fdbe6f71f25b83f1439f68f83b15..56dc7b8e6a116e72e8b16c060e0e2d904a2e9f2f 100644 (file)
@@ -3172,48 +3172,48 @@ f_and(typval_T *argvars, typval_T *rettv)
 f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
 {
     rettv->v_type = VAR_STRING;
-    if (balloonEval != NULL)
-    {
-       if (balloonEval->msg == NULL)
-           rettv->vval.v_string = NULL;
-       else
-           rettv->vval.v_string = vim_strsave(balloonEval->msg);
-    }
+    if (balloonEval == NULL)
+       return;
+
+    if (balloonEval->msg == NULL)
+       rettv->vval.v_string = NULL;
+    else
+       rettv->vval.v_string = vim_strsave(balloonEval->msg);
 }
 
     static void
 f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
 {
-    if (balloonEval != NULL)
-    {
-       if (in_vim9script()
-               && check_for_string_or_list_arg(argvars, 0) == FAIL)
-           return;
+    if (balloonEval == NULL)
+       return;
 
-       if (argvars[0].v_type == VAR_LIST
+    if (in_vim9script()
+           && check_for_string_or_list_arg(argvars, 0) == FAIL)
+       return;
+
+    if (argvars[0].v_type == VAR_LIST
 # ifdef FEAT_GUI
-               && !gui.in_use
+           && !gui.in_use
 # endif
-          )
-       {
-           list_T *l = argvars[0].vval.v_list;
+       )
+    {
+       list_T *l = argvars[0].vval.v_list;
 
-           // empty list removes the balloon
-           post_balloon(balloonEval, NULL,
-                                      l == NULL || l->lv_len == 0 ? NULL : l);
-       }
-       else
-       {
-           char_u *mesg;
+       // empty list removes the balloon
+       post_balloon(balloonEval, NULL,
+               l == NULL || l->lv_len == 0 ? NULL : l);
+    }
+    else
+    {
+       char_u *mesg;
 
-           if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
-               return;
+       if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+           return;
 
-           mesg = tv_get_string_chk(&argvars[0]);
-           if (mesg != NULL)
-               // empty string removes the balloon
-               post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
-       }
+       mesg = tv_get_string_chk(&argvars[0]);
+       if (mesg != NULL)
+           // empty string removes the balloon
+           post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
     }
 }
 
@@ -3221,25 +3221,25 @@ f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
     static void
 f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
 {
-    if (rettv_list_alloc(rettv) == OK)
+    if (rettv_list_alloc(rettv) != OK)
+       return;
+
+    char_u *msg;
+
+    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+       return;
+    msg = tv_get_string_chk(&argvars[0]);
+    if (msg != NULL)
     {
-       char_u *msg;
+       pumitem_T       *array;
+       int             size = split_message(msg, &array);
 
-       if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
-           return;
-       msg = tv_get_string_chk(&argvars[0]);
-       if (msg != NULL)
-       {
-           pumitem_T   *array;
-           int         size = split_message(msg, &array);
-
-           // Skip the first and last item, they are always empty.
-           for (int i = 1; i < size - 1; ++i)
-               list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
-           while (size > 0)
-               vim_free(array[--size].pum_text);
-           vim_free(array);
-       }
+       // Skip the first and last item, they are always empty.
+       for (int i = 1; i < size - 1; ++i)
+           list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
+       while (size > 0)
+           vim_free(array[--size].pum_text);
+       vim_free(array);
     }
 }
 # endif
@@ -3676,18 +3676,18 @@ f_debugbreak(typval_T *argvars, typval_T *rettv)
 
     pid = (int)tv_get_number(&argvars[0]);
     if (pid == 0)
-       emsg(_(e_invalid_argument));
-    else
     {
-       HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
-
-       if (hProcess != NULL)
-       {
-           DebugBreakProcess(hProcess);
-           CloseHandle(hProcess);
-           rettv->vval.v_number = OK;
-       }
+       emsg(_(e_invalid_argument));
+       return;
     }
+
+    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
+    if (hProcess == NULL)
+       return;
+
+    DebugBreakProcess(hProcess);
+    CloseHandle(hProcess);
+    rettv->vval.v_number = OK;
 }
 #endif
 
@@ -3932,12 +3932,12 @@ execute_redir_str(char_u *value, int value_len)
        len = (int)STRLEN(value);       // Append the entire string
     else
        len = value_len;                // Append only "value_len" characters
-    if (ga_grow(&redir_execute_ga, len) == OK)
-    {
-       mch_memmove((char *)redir_execute_ga.ga_data
-                                      + redir_execute_ga.ga_len, value, len);
-       redir_execute_ga.ga_len += len;
-    }
+    if (ga_grow(&redir_execute_ga, len) != OK)
+       return;
+
+    mch_memmove((char *)redir_execute_ga.ga_data
+           + redir_execute_ga.ga_len, value, len);
+    redir_execute_ga.ga_len += len;
 }
 
 #if defined(FEAT_LUA) || defined(PROTO)
@@ -5043,14 +5043,14 @@ f_getcharpos(typval_T *argvars UNUSED, typval_T *rettv)
     static void
 f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
 {
-    if (rettv_dict_alloc(rettv) == OK)
-    {
-       dict_T *dict = rettv->vval.v_dict;
+    if (rettv_dict_alloc(rettv) != OK)
+       return;
 
-       dict_add_string(dict, "char", last_csearch());
-       dict_add_number(dict, "forward", last_csearch_forward());
-       dict_add_number(dict, "until", last_csearch_until());
-    }
+    dict_T *dict = rettv->vval.v_dict;
+
+    dict_add_string(dict, "char", last_csearch());
+    dict_add_number(dict, "forward", last_csearch_forward());
+    dict_add_number(dict, "until", last_csearch_until());
 }
 
 /*
@@ -6792,29 +6792,29 @@ f_index(typval_T *argvars, typval_T *rettv)
     }
 
     l = argvars[0].vval.v_list;
-    if (l != NULL)
+    if (l == NULL)
+       return;
+
+    CHECK_LIST_MATERIALIZE(l);
+    item = l->lv_first;
+    if (argvars[2].v_type != VAR_UNKNOWN)
     {
-       CHECK_LIST_MATERIALIZE(l);
-       item = l->lv_first;
-       if (argvars[2].v_type != VAR_UNKNOWN)
+       // Start at specified item.  Use the cached index that list_find()
+       // sets, so that a negative number also works.
+       item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
+       idx = l->lv_u.mat.lv_idx;
+       if (argvars[3].v_type != VAR_UNKNOWN)
+           ic = (int)tv_get_bool_chk(&argvars[3], &error);
+       if (error)
+           item = NULL;
+    }
+
+    for ( ; item != NULL; item = item->li_next, ++idx)
+       if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
        {
-           // Start at specified item.  Use the cached index that list_find()
-           // sets, so that a negative number also works.
-           item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
-           idx = l->lv_u.mat.lv_idx;
-           if (argvars[3].v_type != VAR_UNKNOWN)
-               ic = (int)tv_get_bool_chk(&argvars[3], &error);
-           if (error)
-               item = NULL;
+           rettv->vval.v_number = idx;
+           break;
        }
-
-       for ( ; item != NULL; item = item->li_next, ++idx)
-           if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
-           {
-               rettv->vval.v_number = idx;
-               break;
-           }
-    }
 }
 
 /*
@@ -8363,22 +8363,26 @@ f_range(typval_T *argvars, typval_T *rettv)
     if (error)
        return;         // type error; errmsg already given
     if (stride == 0)
+    {
        emsg(_(e_stride_is_zero));
-    else if (stride > 0 ? end + 1 < start : end - 1 > start)
-       emsg(_(e_start_past_end));
-    else
+       return;
+    }
+    if (stride > 0 ? end + 1 < start : end - 1 > start)
     {
-       list_T *list = rettv->vval.v_list;
-
-       // Create a non-materialized list.  This is much more efficient and
-       // works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
-       // be called.
-       list->lv_first = &range_list_item;
-       list->lv_u.nonmat.lv_start = start;
-       list->lv_u.nonmat.lv_end = end;
-       list->lv_u.nonmat.lv_stride = stride;
-       list->lv_len = (end - start) / stride + 1;
+       emsg(_(e_start_past_end));
+       return;
     }
+
+    list_T *list = rettv->vval.v_list;
+
+    // Create a non-materialized list.  This is much more efficient and
+    // works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
+    // be called.
+    list->lv_first = &range_list_item;
+    list->lv_u.nonmat.lv_start = start;
+    list->lv_u.nonmat.lv_end = end;
+    list->lv_u.nonmat.lv_stride = stride;
+    list->lv_len = (end - start) / stride + 1;
 }
 
 /*
@@ -9382,34 +9386,34 @@ set_position(typval_T *argvars, typval_T *rettv, int charpos)
        return;
 
     name = tv_get_string_chk(argvars);
-    if (name != NULL)
+    if (name == NULL)
+       return;
+
+    if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) != OK)
+       return;
+
+    if (pos.col != MAXCOL && --pos.col < 0)
+       pos.col = 0;
+    if ((name[0] == '.' && name[1] == NUL))
     {
-       if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) == OK)
+       // set cursor; "fnum" is ignored
+       curwin->w_cursor = pos;
+       if (curswant >= 0)
        {
-           if (pos.col != MAXCOL && --pos.col < 0)
-               pos.col = 0;
-           if ((name[0] == '.' && name[1] == NUL))
-           {
-               // set cursor; "fnum" is ignored
-               curwin->w_cursor = pos;
-               if (curswant >= 0)
-               {
-                   curwin->w_curswant = curswant - 1;
-                   curwin->w_set_curswant = FALSE;
-               }
-               check_cursor();
-               rettv->vval.v_number = 0;
-           }
-           else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
-           {
-               // set mark
-               if (setmark_pos(name[1], &pos, fnum) == OK)
-                   rettv->vval.v_number = 0;
-           }
-           else
-               emsg(_(e_invalid_argument));
+           curwin->w_curswant = curswant - 1;
+           curwin->w_set_curswant = FALSE;
        }
+       check_cursor();
+       rettv->vval.v_number = 0;
     }
+    else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
+    {
+       // set mark
+       if (setmark_pos(name[1], &pos, fnum) == OK)
+           rettv->vval.v_number = 0;
+    }
+    else
+       emsg(_(e_invalid_argument));
 }
 /*
  * "setcharpos()" function
@@ -9430,32 +9434,32 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
     if (check_for_dict_arg(argvars, 0) == FAIL)
        return;
 
-    if ((d = argvars[0].vval.v_dict) != NULL)
+    if ((d = argvars[0].vval.v_dict) == NULL)
+       return;
+
+    csearch = dict_get_string(d, "char", FALSE);
+    if (csearch != NULL)
     {
-       csearch = dict_get_string(d, "char", FALSE);
-       if (csearch != NULL)
+       if (enc_utf8)
        {
-           if (enc_utf8)
-           {
-               int pcc[MAX_MCO];
-               int c = utfc_ptr2char(csearch, pcc);
+           int pcc[MAX_MCO];
+           int c = utfc_ptr2char(csearch, pcc);
 
-               set_last_csearch(c, csearch, utfc_ptr2len(csearch));
-           }
-           else
-               set_last_csearch(PTR2CHAR(csearch),
-                                               csearch, mb_ptr2len(csearch));
+           set_last_csearch(c, csearch, utfc_ptr2len(csearch));
        }
+       else
+           set_last_csearch(PTR2CHAR(csearch),
+                   csearch, mb_ptr2len(csearch));
+    }
 
-       di = dict_find(d, (char_u *)"forward", -1);
-       if (di != NULL)
-           set_csearch_direction((int)tv_get_number(&di->di_tv)
-                                                       ? FORWARD : BACKWARD);
+    di = dict_find(d, (char_u *)"forward", -1);
+    if (di != NULL)
+       set_csearch_direction((int)tv_get_number(&di->di_tv)
+               ? FORWARD : BACKWARD);
 
-       di = dict_find(d, (char_u *)"until", -1);
-       if (di != NULL)
-           set_csearch_until(!!tv_get_number(&di->di_tv));
-    }
+    di = dict_find(d, (char_u *)"until", -1);
+    if (di != NULL)
+       set_csearch_until(!!tv_get_number(&di->di_tv));
 }
 
 /*
index d9466691f40b9df9258b90b7d3d786c206b0efe0..389a9e4d1864299bfc898385254c9b41e4822b24 100644 (file)
@@ -350,15 +350,15 @@ set_internal_string_var(char_u *name, char_u *value)
     typval_T   *tvp;
 
     val = vim_strsave(value);
-    if (val != NULL)
-    {
-       tvp = alloc_string_tv(val);
-       if (tvp != NULL)
-       {
-           set_var(name, tvp, FALSE);
-           free_tv(tvp);
-       }
-    }
+    if (val == NULL)
+       return;
+
+    tvp = alloc_string_tv(val);
+    if (tvp == NULL)
+       return;
+
+    set_var(name, tvp, FALSE);
+    free_tv(tvp);
 }
 
     int
@@ -576,14 +576,14 @@ restore_vimvar(int idx, typval_T *save_tv)
     hashitem_T *hi;
 
     vimvars[idx].vv_tv = *save_tv;
-    if (vimvars[idx].vv_tv_type == VAR_UNKNOWN)
-    {
-       hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
-       if (HASHITEM_EMPTY(hi))
-           internal_error("restore_vimvar()");
-       else
-           hash_remove(&vimvarht, hi, "restore vimvar");
-    }
+    if (vimvars[idx].vv_tv_type != VAR_UNKNOWN)
+       return;
+
+    hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
+    if (HASHITEM_EMPTY(hi))
+       internal_error("restore_vimvar()");
+    else
+       hash_remove(&vimvarht, hi, "restore vimvar");
 }
 
 /*
@@ -2740,11 +2740,11 @@ set_vim_var_dict(int idx, dict_T *val)
     clear_tv(&vimvars[idx].vv_di.di_tv);
     vimvars[idx].vv_tv_type = VAR_DICT;
     vimvars[idx].vv_dict = val;
-    if (val != NULL)
-    {
-       ++val->dv_refcount;
-       dict_set_items_ro(val);
-    }
+    if (val == NULL)
+       return;
+
+    ++val->dv_refcount;
+    dict_set_items_ro(val);
 }
 
 /*
@@ -3562,11 +3562,11 @@ delete_var(hashtab_T *ht, hashitem_T *hi)
 {
     dictitem_T *di = HI2DI(hi);
 
-    if (hash_remove(ht, hi, "delete variable") == OK)
-    {
-       clear_tv(&di->di_tv);
-       vim_free(di);
-    }
+    if (hash_remove(ht, hi, "delete variable") != OK)
+       return;
+
+    clear_tv(&di->di_tv);
+    vim_free(di);
 }
 
 /*
@@ -4317,29 +4317,29 @@ setwinvar(typval_T *argvars, int off)
     varname = tv_get_string_chk(&argvars[off + 1]);
     varp = &argvars[off + 2];
 
-    if (win != NULL && varname != NULL && varp != NULL)
+    if (win == NULL || varname == NULL || varp == NULL)
+       return;
+
+    need_switch_win = !(tp == curtab && win == curwin);
+    if (!need_switch_win
+           || switch_win(&switchwin, win, tp, TRUE) == OK)
     {
-       need_switch_win = !(tp == curtab && win == curwin);
-       if (!need_switch_win
-              || switch_win(&switchwin, win, tp, TRUE) == OK)
+       if (*varname == '&')
+           set_option_from_tv(varname + 1, varp);
+       else
        {
-           if (*varname == '&')
-               set_option_from_tv(varname + 1, varp);
-           else
+           winvarname = alloc(STRLEN(varname) + 3);
+           if (winvarname != NULL)
            {
-               winvarname = alloc(STRLEN(varname) + 3);
-               if (winvarname != NULL)
-               {
-                   STRCPY(winvarname, "w:");
-                   STRCPY(winvarname + 2, varname);
-                   set_var(winvarname, varp, TRUE);
-                   vim_free(winvarname);
-               }
+               STRCPY(winvarname, "w:");
+               STRCPY(winvarname + 2, varname);
+               set_var(winvarname, varp, TRUE);
+               vim_free(winvarname);
            }
        }
-       if (need_switch_win)
-           restore_win(&switchwin, TRUE);
     }
+    if (need_switch_win)
+       restore_win(&switchwin, TRUE);
 }
 
 /*
@@ -4686,24 +4686,24 @@ f_settabvar(typval_T *argvars, typval_T *rettv UNUSED)
     varname = tv_get_string_chk(&argvars[1]);
     varp = &argvars[2];
 
-    if (varname != NULL && varp != NULL && tp != NULL)
-    {
-       save_curtab = curtab;
-       goto_tabpage_tp(tp, FALSE, FALSE);
+    if (varname == NULL || varp == NULL || tp == NULL)
+       return;
 
-       tabvarname = alloc(STRLEN(varname) + 3);
-       if (tabvarname != NULL)
-       {
-           STRCPY(tabvarname, "t:");
-           STRCPY(tabvarname + 2, varname);
-           set_var(tabvarname, varp, TRUE);
-           vim_free(tabvarname);
-       }
+    save_curtab = curtab;
+    goto_tabpage_tp(tp, FALSE, FALSE);
 
-       // Restore current tabpage
-       if (valid_tabpage(save_curtab))
-           goto_tabpage_tp(save_curtab, FALSE, FALSE);
+    tabvarname = alloc(STRLEN(varname) + 3);
+    if (tabvarname != NULL)
+    {
+       STRCPY(tabvarname, "t:");
+       STRCPY(tabvarname + 2, varname);
+       set_var(tabvarname, varp, TRUE);
+       vim_free(tabvarname);
     }
+
+    // Restore current tabpage
+    if (valid_tabpage(save_curtab))
+       goto_tabpage_tp(save_curtab, FALSE, FALSE);
 }
 
 /*
@@ -4757,37 +4757,37 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
     buf = tv_get_buf_from_arg(&argvars[0]);
     varp = &argvars[2];
 
-    if (buf != NULL && varname != NULL && varp != NULL)
+    if (buf == NULL || varname == NULL || varp == NULL)
+       return;
+
+    if (*varname == '&')
     {
-       if (*varname == '&')
-       {
-           aco_save_T  aco;
+       aco_save_T      aco;
 
-           // Set curbuf to be our buf, temporarily.
-           aucmd_prepbuf(&aco, buf);
-           if (curbuf == buf)
-           {
-               // Only when it worked to set "curbuf".
-               set_option_from_tv(varname + 1, varp);
+       // Set curbuf to be our buf, temporarily.
+       aucmd_prepbuf(&aco, buf);
+       if (curbuf == buf)
+       {
+           // Only when it worked to set "curbuf".
+           set_option_from_tv(varname + 1, varp);
 
-               // reset notion of buffer
-               aucmd_restbuf(&aco);
-           }
+           // reset notion of buffer
+           aucmd_restbuf(&aco);
        }
-       else
+    }
+    else
+    {
+       bufvarname = alloc(STRLEN(varname) + 3);
+       if (bufvarname != NULL)
        {
-           bufvarname = alloc(STRLEN(varname) + 3);
-           if (bufvarname != NULL)
-           {
-               buf_T *save_curbuf = curbuf;
-
-               curbuf = buf;
-               STRCPY(bufvarname, "b:");
-               STRCPY(bufvarname + 2, varname);
-               set_var(bufvarname, varp, TRUE);
-               vim_free(bufvarname);
-               curbuf = save_curbuf;
-           }
+           buf_T *save_curbuf = curbuf;
+
+           curbuf = buf;
+           STRCPY(bufvarname, "b:");
+           STRCPY(bufvarname + 2, varname);
+           set_var(bufvarname, varp, TRUE);
+           vim_free(bufvarname);
+           curbuf = save_curbuf;
        }
     }
 }
@@ -4930,31 +4930,30 @@ expand_autload_callback(callback_T *cb)
     p = vim_strchr(name, '.');
     if (p == NULL)
        return;
+
     import = find_imported(name, p - name, FALSE);
-    if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
-    {
-       scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
+    if (import == NULL || !SCRIPT_ID_VALID(import->imp_sid))
+       return;
 
-       if (si->sn_autoload_prefix != NULL)
-       {
-           char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
+    scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
+    if (si->sn_autoload_prefix == NULL)
+       return;
 
-           if (newname != NULL)
-           {
-               if (cb->cb_partial != NULL)
-               {
-                   if (cb->cb_name == cb->cb_partial->pt_name)
-                       cb->cb_name = newname;
-                   vim_free(cb->cb_partial->pt_name);
-                   cb->cb_partial->pt_name = newname;
-               }
-               else
-               {
-                   vim_free(cb->cb_name);
-                   cb->cb_name = newname;
-               }
-           }
-       }
+    char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
+    if (newname == NULL)
+       return;
+
+    if (cb->cb_partial != NULL)
+    {
+       if (cb->cb_name == cb->cb_partial->pt_name)
+           cb->cb_name = newname;
+       vim_free(cb->cb_partial->pt_name);
+       cb->cb_partial->pt_name = newname;
+    }
+    else
+    {
+       vim_free(cb->cb_name);
+       cb->cb_name = newname;
     }
 }
 
index f8c0c7acfd9cd4fa8036e15a008ebbc2cd95bf84..8b47b98fd14630105bc7011524a987d120d2f4f8 100644 (file)
@@ -718,66 +718,66 @@ f_win_execute(typval_T *argvars, typval_T *rettv)
 
     id = (int)tv_get_number(argvars);
     wp = win_id2wp_tp(id, &tp);
-    if (wp != NULL && tp != NULL)
-    {
-       pos_T   curpos = wp->w_cursor;
-       char_u  cwd[MAXPATHL];
-       int     cwd_status = FAIL;
+    if (wp == NULL || tp == NULL)
+       return;
+
+    pos_T      curpos = wp->w_cursor;
+    char_u     cwd[MAXPATHL];
+    int        cwd_status = FAIL;
 #ifdef FEAT_AUTOCHDIR
-       char_u  autocwd[MAXPATHL];
-       int     apply_acd = FALSE;
+    char_u     autocwd[MAXPATHL];
+    int        apply_acd = FALSE;
 #endif
 
-       // Getting and setting directory can be slow on some systems, only do
-       // this when the current or target window/tab have a local directory or
-       // 'acd' is set.
-       if (curwin != wp
-               && (curwin->w_localdir != NULL
-                   || wp->w_localdir != NULL
-                   || (curtab != tp
-                       && (curtab->tp_localdir != NULL
-                           || tp->tp_localdir != NULL))
+    // Getting and setting directory can be slow on some systems, only do
+    // this when the current or target window/tab have a local directory or
+    // 'acd' is set.
+    if (curwin != wp
+           && (curwin->w_localdir != NULL
+               || wp->w_localdir != NULL
+               || (curtab != tp
+                   && (curtab->tp_localdir != NULL
+                       || tp->tp_localdir != NULL))
 #ifdef FEAT_AUTOCHDIR
-                   || p_acd
+               || p_acd
 #endif
-                   ))
-           cwd_status = mch_dirname(cwd, MAXPATHL);
+              ))
+       cwd_status = mch_dirname(cwd, MAXPATHL);
 
 #ifdef FEAT_AUTOCHDIR
-       // If 'acd' is set, check we are using that directory.  If yes, then
-       // apply 'acd' afterwards, otherwise restore the current directory.
-       if (cwd_status == OK && p_acd)
-       {
-           do_autochdir();
-           apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
-                                                 && STRCMP(cwd, autocwd) == 0;
-       }
+    // If 'acd' is set, check we are using that directory.  If yes, then
+    // apply 'acd' afterwards, otherwise restore the current directory.
+    if (cwd_status == OK && p_acd)
+    {
+       do_autochdir();
+       apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
+           && STRCMP(cwd, autocwd) == 0;
+    }
 #endif
 
-       if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
-       {
-           check_cursor();
-           execute_common(argvars, rettv, 1);
-       }
-       restore_win_noblock(&switchwin, TRUE);
+    if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
+    {
+       check_cursor();
+       execute_common(argvars, rettv, 1);
+    }
+    restore_win_noblock(&switchwin, TRUE);
 #ifdef FEAT_AUTOCHDIR
-       if (apply_acd)
-           do_autochdir();
-       else
+    if (apply_acd)
+       do_autochdir();
+    else
 #endif
-           if (cwd_status == OK)
+       if (cwd_status == OK)
            mch_chdir((char *)cwd);
 
-       // Update the status line if the cursor moved.
-       if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
-           wp->w_redr_status = TRUE;
+    // Update the status line if the cursor moved.
+    if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
+       wp->w_redr_status = TRUE;
 
-       // In case the command moved the cursor or changed the Visual area,
-       // check it is valid.
-       check_cursor();
-       if (VIsual_active)
-           check_pos(curbuf, &VIsual);
-    }
+    // In case the command moved the cursor or changed the Visual area,
+    // check it is valid.
+    check_cursor();
+    if (VIsual_active)
+       check_pos(curbuf, &VIsual);
 }
 
 /*
@@ -1093,11 +1093,11 @@ f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv)
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
     rettv->vval.v_string = alloc(2);
-    if (rettv->vval.v_string != NULL)
-    {
-       rettv->vval.v_string[0] = cmdwin_type;
-       rettv->vval.v_string[1] = NUL;
-    }
+    if (rettv->vval.v_string == NULL)
+       return;
+
+    rettv->vval.v_string[0] = cmdwin_type;
+    rettv->vval.v_string[1] = NUL;
 }
 
 /*
index 9a507c90fa38d219b0517c5ad3b48aa0ba0afe46..4755952a518639f9122545417c483e70c27e1186 100644 (file)
@@ -7049,12 +7049,12 @@ ex_find(exarg_T *eap)
        }
     }
 
-    if (fname != NULL)
-    {
-       eap->arg = fname;
-       do_exedit(eap, NULL);
-       vim_free(fname);
-    }
+    if (fname == NULL)
+       return;
+
+    eap->arg = fname;
+    do_exedit(eap, NULL);
+    vim_free(fname);
 }
 
 /*
index 4884ebd8a34f5ae545d45feeaad5a08b843651f7..49331c417851922ab95c769a911b1012e8740031 100644 (file)
@@ -4210,11 +4210,11 @@ f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = alloc(2);
-    if (rettv->vval.v_string != NULL)
-    {
-       rettv->vval.v_string[0] = get_cmdline_type();
-       rettv->vval.v_string[1] = NUL;
-    }
+    if (rettv->vval.v_string == NULL)
+       return;
+
+    rettv->vval.v_string[0] = get_cmdline_type();
+    rettv->vval.v_string[1] = NUL;
 }
 
 // Set the command line str to "str".
index 1ee08e21edba8111051f359572ad4dcba265f279..d8b395acfd3364f62ee6b7ba60cb6f87173972e5 100644 (file)
@@ -2767,15 +2767,15 @@ set_file_options(int set_options, exarg_T *eap)
     void
 set_forced_fenc(exarg_T *eap)
 {
-    if (eap->force_enc != 0)
-    {
-       char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
+    if (eap->force_enc == 0)
+       return;
 
-       if (fenc != NULL)
-           set_string_option_direct((char_u *)"fenc", -1,
-                                fenc, OPT_FREE|OPT_LOCAL, 0);
-       vim_free(fenc);
-    }
+    char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
+
+    if (fenc != NULL)
+       set_string_option_direct((char_u *)"fenc", -1,
+               fenc, OPT_FREE|OPT_LOCAL, 0);
+    vim_free(fenc);
 }
 
 /*
@@ -5070,12 +5070,11 @@ vim_opentempdir(void)
        return;
 
     dp = opendir((const char*)vim_tempdir);
+    if (dp == NULL)
+       return;
 
-    if (dp != NULL)
-    {
-       vim_tempdir_dp = dp;
-       flock(dirfd(vim_tempdir_dp), LOCK_SH);
-    }
+    vim_tempdir_dp = dp;
+    flock(dirfd(vim_tempdir_dp), LOCK_SH);
 }
 
 /*
@@ -5084,11 +5083,11 @@ vim_opentempdir(void)
    static void
 vim_closetempdir(void)
 {
-    if (vim_tempdir_dp != NULL)
-    {
-       closedir(vim_tempdir_dp);
-       vim_tempdir_dp = NULL;
-    }
+    if (vim_tempdir_dp == NULL)
+       return;
+
+    closedir(vim_tempdir_dp);
+    vim_tempdir_dp = NULL;
 }
 # endif
 
@@ -5098,16 +5097,16 @@ vim_closetempdir(void)
     void
 vim_deltempdir(void)
 {
-    if (vim_tempdir != NULL)
-    {
+    if (vim_tempdir == NULL)
+       return;
+
 # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
-       vim_closetempdir();
+    vim_closetempdir();
 # endif
-       // remove the trailing path separator
-       gettail(vim_tempdir)[-1] = NUL;
-       delete_recursive(vim_tempdir);
-       VIM_CLEAR(vim_tempdir);
-    }
+    // remove the trailing path separator
+    gettail(vim_tempdir)[-1] = NUL;
+    delete_recursive(vim_tempdir);
+    VIM_CLEAR(vim_tempdir);
 }
 
 /*
@@ -5121,17 +5120,17 @@ vim_settempdir(char_u *tempdir)
     char_u     *buf;
 
     buf = alloc(MAXPATHL + 2);
-    if (buf != NULL)
-    {
-       if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
-           STRCPY(buf, tempdir);
-       add_pathsep(buf);
-       vim_tempdir = vim_strsave(buf);
+    if (buf == NULL)
+       return;
+
+    if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
+       STRCPY(buf, tempdir);
+    add_pathsep(buf);
+    vim_tempdir = vim_strsave(buf);
 # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
-       vim_opentempdir();
+    vim_opentempdir();
 # endif
-       vim_free(buf);
-    }
+    vim_free(buf);
 }
 #endif
 
index 04bb8a121ee5530c77b67a05a94742468054e73f..9e8074de8e78da27894925ae10e868ab3a0b2b4d 100644 (file)
@@ -288,15 +288,15 @@ f_float2nr(typval_T *argvars, typval_T *rettv)
     if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
        return;
 
-    if (get_float_arg(argvars, &f) == OK)
-    {
-       if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
-           rettv->vval.v_number = -VARNUM_MAX;
-       else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
-           rettv->vval.v_number = VARNUM_MAX;
-       else
-           rettv->vval.v_number = (varnumber_T)f;
-    }
+    if (get_float_arg(argvars, &f) != OK)
+       return;
+
+    if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
+       rettv->vval.v_number = -VARNUM_MAX;
+    else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
+       rettv->vval.v_number = VARNUM_MAX;
+    else
+       rettv->vval.v_number = (varnumber_T)f;
 }
 
 /*
index a226d6fd2f7066e1f926b04be99b442f82df2cd6..d722a56d0c7ff9cb4b33b9c9fa691f63881877d2 100644 (file)
@@ -644,59 +644,59 @@ foldCreate(linenr_T start, linenr_T end)
            i = (int)(fp - (fold_T *)gap->ga_data);
     }
 
-    if (ga_grow(gap, 1) == OK)
-    {
-       fp = (fold_T *)gap->ga_data + i;
-       ga_init2(&fold_ga, sizeof(fold_T), 10);
+    if (ga_grow(gap, 1) != OK)
+       return;
 
-       // Count number of folds that will be contained in the new fold.
-       for (cont = 0; i + cont < gap->ga_len; ++cont)
-           if (fp[cont].fd_top > end_rel)
-               break;
-       if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
-       {
-           // If the first fold starts before the new fold, let the new fold
-           // start there.  Otherwise the existing fold would change.
-           if (start_rel > fp->fd_top)
-               start_rel = fp->fd_top;
-
-           // When last contained fold isn't completely contained, adjust end
-           // of new fold.
-           if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
-               end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
-           // Move contained folds to inside new fold.
-           mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
-           fold_ga.ga_len += cont;
-           i += cont;
-
-           // Adjust line numbers in contained folds to be relative to the
-           // new fold.
-           for (j = 0; j < cont; ++j)
-               ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
-       }
-       // Move remaining entries to after the new fold.
-       if (i < gap->ga_len)
-           mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
-                                    sizeof(fold_T) * (gap->ga_len - i));
-       gap->ga_len = gap->ga_len + 1 - cont;
-
-       // insert new fold
-       fp->fd_nested = fold_ga;
-       fp->fd_top = start_rel;
-       fp->fd_len = end_rel - start_rel + 1;
-
-       // We want the new fold to be closed.  If it would remain open because
-       // of using 'foldlevel', need to adjust fd_flags of containing folds.
-       if (use_level && !closed && level < curwin->w_p_fdl)
-           closeFold(start, 1L);
-       if (!use_level)
-           curwin->w_fold_manual = TRUE;
-       fp->fd_flags = FD_CLOSED;
-       fp->fd_small = MAYBE;
+    fp = (fold_T *)gap->ga_data + i;
+    ga_init2(&fold_ga, sizeof(fold_T), 10);
 
-       // redraw
-       changed_window_setting();
-    }
+    // Count number of folds that will be contained in the new fold.
+    for (cont = 0; i + cont < gap->ga_len; ++cont)
+       if (fp[cont].fd_top > end_rel)
+           break;
+    if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
+    {
+       // If the first fold starts before the new fold, let the new fold
+       // start there.  Otherwise the existing fold would change.
+       if (start_rel > fp->fd_top)
+           start_rel = fp->fd_top;
+
+       // When last contained fold isn't completely contained, adjust end
+       // of new fold.
+       if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
+           end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
+       // Move contained folds to inside new fold.
+       mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
+       fold_ga.ga_len += cont;
+       i += cont;
+
+       // Adjust line numbers in contained folds to be relative to the
+       // new fold.
+       for (j = 0; j < cont; ++j)
+           ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
+    }
+    // Move remaining entries to after the new fold.
+    if (i < gap->ga_len)
+       mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
+               sizeof(fold_T) * (gap->ga_len - i));
+    gap->ga_len = gap->ga_len + 1 - cont;
+
+    // insert new fold
+    fp->fd_nested = fold_ga;
+    fp->fd_top = start_rel;
+    fp->fd_len = end_rel - start_rel + 1;
+
+    // We want the new fold to be closed.  If it would remain open because
+    // of using 'foldlevel', need to adjust fd_flags of containing folds.
+    if (use_level && !closed && level < curwin->w_p_fdl)
+       closeFold(start, 1L);
+    if (!use_level)
+       curwin->w_fold_manual = TRUE;
+    fp->fd_flags = FD_CLOSED;
+    fp->fd_small = MAYBE;
+
+    // redraw
+    changed_window_setting();
 }
 
 // deleteFold() {{{2
@@ -1719,27 +1719,27 @@ checkSmall(
     int                count;
     int                n;
 
-    if (fp->fd_small == MAYBE)
-    {
-       // Mark any nested folds to maybe-small
-       setSmallMaybe(&fp->fd_nested);
+    if (fp->fd_small != MAYBE)
+       return;
 
-       if (fp->fd_len > curwin->w_p_fml)
-           fp->fd_small = FALSE;
-       else
+    // Mark any nested folds to maybe-small
+    setSmallMaybe(&fp->fd_nested);
+
+    if (fp->fd_len > curwin->w_p_fml)
+       fp->fd_small = FALSE;
+    else
+    {
+       count = 0;
+       for (n = 0; n < fp->fd_len; ++n)
        {
-           count = 0;
-           for (n = 0; n < fp->fd_len; ++n)
+           count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
+           if (count > curwin->w_p_fml)
            {
-               count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
-               if (count > curwin->w_p_fml)
-               {
-                   fp->fd_small = FALSE;
-                   return;
-               }
+               fp->fd_small = FALSE;
+               return;
            }
-           fp->fd_small = TRUE;
        }
+       fp->fd_small = TRUE;
     }
 }
 
@@ -1799,26 +1799,26 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
     line = ml_get(lnum);
     line_len = (int)STRLEN(line);
 
-    if (u_save(lnum - 1, lnum + 1) == OK)
-    {
-       // Check if the line ends with an unclosed comment
-       (void)skip_comment(line, FALSE, FALSE, &line_is_comment);
-       newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
-       if (newline == NULL)
-           return;
-       STRCPY(newline, line);
-       // Append the marker to the end of the line
-       if (p == NULL || line_is_comment)
-           vim_strncpy(newline + line_len, marker, markerlen);
-       else
-       {
-           STRCPY(newline + line_len, cms);
-           STRNCPY(newline + line_len + (p - cms), marker, markerlen);
-           STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
-       }
+    if (u_save(lnum - 1, lnum + 1) != OK)
+       return;
 
-       ml_replace(lnum, newline, FALSE);
+    // Check if the line ends with an unclosed comment
+    (void)skip_comment(line, FALSE, FALSE, &line_is_comment);
+    newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
+    if (newline == NULL)
+       return;
+    STRCPY(newline, line);
+    // Append the marker to the end of the line
+    if (p == NULL || line_is_comment)
+       vim_strncpy(newline + line_len, marker, markerlen);
+    else
+    {
+       STRCPY(newline + line_len, cms);
+       STRNCPY(newline + line_len + (p - cms), marker, markerlen);
+       STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
     }
+
+    ml_replace(lnum, newline, FALSE);
 }
 
 // deleteFoldMarkers() {{{2
index babedcc63e65eadf483a0397505921cdeac4ba4d..08a02151beeeb19787fbd94e40ebac01ad590cdf 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1132,
 /**/
     1131,
 /**/