Mercurial > vim
comparison src/ex_docmd.c @ 13244:ac42c4b11dbc v8.0.1496
patch 8.0.1496: clearing a pointer takes two lines
commit https://github.com/vim/vim/commit/d23a823669d93fb2a570a039173eefe4856ac806
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 10 18:45:26 2018 +0100
patch 8.0.1496: clearing a pointer takes two lines
Problem: Clearing a pointer takes two lines.
Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi,
closes #2629)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Feb 2018 19:00:07 +0100 |
parents | dc28351a85d4 |
children | 69278c25429d |
comparison
equal
deleted
inserted
replaced
13243:899b19739188 | 13244:ac42c4b11dbc |
---|---|
866 /* 1. If repeating, get a previous line from lines_ga. */ | 866 /* 1. If repeating, get a previous line from lines_ga. */ |
867 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) | 867 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
868 { | 868 { |
869 /* Each '|' separated command is stored separately in lines_ga, to | 869 /* Each '|' separated command is stored separately in lines_ga, to |
870 * be able to jump to it. Don't use next_cmdline now. */ | 870 * be able to jump to it. Don't use next_cmdline now. */ |
871 vim_free(cmdline_copy); | 871 VIM_CLEAR(cmdline_copy); |
872 cmdline_copy = NULL; | |
873 | 872 |
874 /* Check if a function has returned or, unless it has an unclosed | 873 /* Check if a function has returned or, unless it has an unclosed |
875 * try conditional, aborted. */ | 874 * try conditional, aborted. */ |
876 if (getline_is_func) | 875 if (getline_is_func) |
877 { | 876 { |
1082 current_line = cmd_loop_cookie.current_line; | 1081 current_line = cmd_loop_cookie.current_line; |
1083 #endif | 1082 #endif |
1084 | 1083 |
1085 if (next_cmdline == NULL) | 1084 if (next_cmdline == NULL) |
1086 { | 1085 { |
1087 vim_free(cmdline_copy); | 1086 VIM_CLEAR(cmdline_copy); |
1088 cmdline_copy = NULL; | |
1089 #ifdef FEAT_CMDHIST | 1087 #ifdef FEAT_CMDHIST |
1090 /* | 1088 /* |
1091 * If the command was typed, remember it for the ':' register. | 1089 * If the command was typed, remember it for the ':' register. |
1092 * Do this AFTER executing the command to make :@: work. | 1090 * Do this AFTER executing the command to make :@: work. |
1093 */ | 1091 */ |
5800 { | 5798 { |
5801 EMSG(_("E174: Command already exists: add ! to replace it")); | 5799 EMSG(_("E174: Command already exists: add ! to replace it")); |
5802 goto fail; | 5800 goto fail; |
5803 } | 5801 } |
5804 | 5802 |
5805 vim_free(cmd->uc_rep); | 5803 VIM_CLEAR(cmd->uc_rep); |
5806 cmd->uc_rep = NULL; | |
5807 #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | 5804 #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) |
5808 vim_free(cmd->uc_compl_arg); | 5805 VIM_CLEAR(cmd->uc_compl_arg); |
5809 cmd->uc_compl_arg = NULL; | |
5810 #endif | 5806 #endif |
5811 break; | 5807 break; |
5812 } | 5808 } |
5813 | 5809 |
5814 /* Stop as soon as we pass the name to add */ | 5810 /* Stop as soon as we pass the name to add */ |
8950 | 8946 |
8951 #if defined(EXITFREE) || defined(PROTO) | 8947 #if defined(EXITFREE) || defined(PROTO) |
8952 void | 8948 void |
8953 free_cd_dir(void) | 8949 free_cd_dir(void) |
8954 { | 8950 { |
8955 vim_free(prev_dir); | 8951 VIM_CLEAR(prev_dir); |
8956 prev_dir = NULL; | 8952 VIM_CLEAR(globaldir); |
8957 | |
8958 vim_free(globaldir); | |
8959 globaldir = NULL; | |
8960 } | 8953 } |
8961 #endif | 8954 #endif |
8962 | 8955 |
8963 /* | 8956 /* |
8964 * Deal with the side effects of changing the current directory. | 8957 * Deal with the side effects of changing the current directory. |
8965 * When "local" is TRUE then this was after an ":lcd" command. | 8958 * When "local" is TRUE then this was after an ":lcd" command. |
8966 */ | 8959 */ |
8967 void | 8960 void |
8968 post_chdir(int local) | 8961 post_chdir(int local) |
8969 { | 8962 { |
8970 vim_free(curwin->w_localdir); | 8963 VIM_CLEAR(curwin->w_localdir); |
8971 curwin->w_localdir = NULL; | |
8972 if (local) | 8964 if (local) |
8973 { | 8965 { |
8974 /* If still in global directory, need to remember current | 8966 /* If still in global directory, need to remember current |
8975 * directory as global directory. */ | 8967 * directory as global directory. */ |
8976 if (globaldir == NULL && prev_dir != NULL) | 8968 if (globaldir == NULL && prev_dir != NULL) |
8981 } | 8973 } |
8982 else | 8974 else |
8983 { | 8975 { |
8984 /* We are now in the global directory, no need to remember its | 8976 /* We are now in the global directory, no need to remember its |
8985 * name. */ | 8977 * name. */ |
8986 vim_free(globaldir); | 8978 VIM_CLEAR(globaldir); |
8987 globaldir = NULL; | |
8988 } | 8979 } |
8989 | 8980 |
8990 shorten_fnames(TRUE); | 8981 shorten_fnames(TRUE); |
8991 } | 8982 } |
8992 | 8983 |