To: vim_dev@googlegroups.com Subject: Patch 9.0.1196 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1196 Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11813) Files: src/job.c, src/list.c, src/locale.c, src/main.c, src/map.c, src/mark.c, src/match.c, src/mbyte.c, src/memfile.c, src/memline.c, src/menu.c, src/message.c, src/misc1.c, src/misc2.c, src/move.c *** ../vim-9.0.1195/src/job.c 2022-12-02 15:58:34.602705473 +0000 --- src/job.c 2023-01-14 12:27:21.268079543 +0000 *************** *** 793,803 **** static void job_free(job_T *job) { ! if (!in_free_unref_items) ! { ! job_free_contents(job); ! job_free_job(job); ! } } static job_T *jobs_to_free = NULL; --- 793,803 ---- static void job_free(job_T *job) { ! if (in_free_unref_items) ! return; ! ! job_free_contents(job); ! job_free_job(job); } static job_T *jobs_to_free = NULL; *************** *** 1087,1114 **** void job_unref(job_T *job) { ! if (job != NULL && --job->jv_refcount <= 0) ! { ! // Do not free the job if there is a channel where the close callback ! // may get the job info. ! if (!job_channel_still_useful(job)) ! { ! // Do not free the job when it has not ended yet and there is a ! // "stoponexit" flag or an exit callback. ! if (!job_need_end_check(job)) ! { ! job_free(job); ! } ! else if (job->jv_channel != NULL) ! { ! // Do remove the link to the channel, otherwise it hangs ! // around until Vim exits. See job_free() for refcount. ! ch_log(job->jv_channel, "detaching channel from job"); ! job->jv_channel->ch_job = NULL; ! channel_unref(job->jv_channel); ! job->jv_channel = NULL; ! } ! } } } --- 1087,1114 ---- void job_unref(job_T *job) { ! if (job == NULL || --job->jv_refcount > 0) ! return; ! ! // Do not free the job if there is a channel where the close callback ! // may get the job info. ! if (job_channel_still_useful(job)) ! return; ! ! // Do not free the job when it has not ended yet and there is a ! // "stoponexit" flag or an exit callback. ! if (!job_need_end_check(job)) ! { ! job_free(job); ! } ! else if (job->jv_channel != NULL) ! { ! // Do remove the link to the channel, otherwise it hangs ! // around until Vim exits. See job_free() for refcount. ! ch_log(job->jv_channel, "detaching channel from job"); ! job->jv_channel->ch_job = NULL; ! channel_unref(job->jv_channel); ! job->jv_channel = NULL; } } *************** *** 1157,1174 **** job_T *job; job = ALLOC_CLEAR_ONE(job_T); ! if (job != NULL) ! { ! job->jv_refcount = 1; ! job->jv_stoponexit = vim_strsave((char_u *)"term"); ! if (first_job != NULL) ! { ! first_job->jv_prev = job; ! job->jv_next = first_job; ! } ! first_job = job; } return job; } --- 1157,1174 ---- job_T *job; job = ALLOC_CLEAR_ONE(job_T); ! if (job == NULL) ! return NULL; ! job->jv_refcount = 1; ! job->jv_stoponexit = vim_strsave((char_u *)"term"); ! ! if (first_job != NULL) ! { ! first_job->jv_prev = job; ! job->jv_next = first_job; } + first_job = job; return job; } *************** *** 1803,1815 **** return; job = get_job_arg(&argvars[0]); ! if (job != NULL) ! { ! rettv->v_type = VAR_CHANNEL; ! rettv->vval.v_channel = job->jv_channel; ! if (job->jv_channel != NULL) ! ++job->jv_channel->ch_refcount; ! } } /* --- 1803,1815 ---- return; job = get_job_arg(&argvars[0]); ! if (job == NULL) ! return; ! ! rettv->v_type = VAR_CHANNEL; ! rettv->vval.v_channel = job->jv_channel; ! if (job->jv_channel != NULL) ! ++job->jv_channel->ch_refcount; } /* *************** *** 1855,1867 **** #endif l = list_alloc(); ! if (l != NULL) ! { ! dict_add_list(dict, "cmd", l); ! if (job->jv_argv != NULL) ! for (i = 0; job->jv_argv[i] != NULL; i++) ! list_append_string(l, (char_u *)job->jv_argv[i], -1); ! } } /* --- 1855,1867 ---- #endif l = list_alloc(); ! if (l == NULL) ! return; ! ! dict_add_list(dict, "cmd", l); ! if (job->jv_argv != NULL) ! for (i = 0; job->jv_argv[i] != NULL; i++) ! list_append_string(l, (char_u *)job->jv_argv[i], -1); } /* *** ../vim-9.0.1195/src/list.c 2022-11-24 00:08:58.461010529 +0000 --- src/list.c 2023-01-14 12:27:21.268079543 +0000 *************** *** 124,150 **** list_init(l); ! if (count > 0) ! { ! listitem_T *li = (listitem_T *)(l + 1); ! int i; ! l->lv_len = count; ! l->lv_with_items = count; ! l->lv_first = li; ! l->lv_u.mat.lv_last = li + count - 1; ! for (i = 0; i < count; ++i) ! { ! if (i == 0) ! li->li_prev = NULL; ! else ! li->li_prev = li - 1; ! if (i == count - 1) ! li->li_next = NULL; ! else ! li->li_next = li + 1; ! ++li; ! } } return l; --- 124,150 ---- list_init(l); ! if (count <= 0) ! return l; ! listitem_T *li = (listitem_T *)(l + 1); ! int i; ! ! l->lv_len = count; ! l->lv_with_items = count; ! l->lv_first = li; ! l->lv_u.mat.lv_last = li + count - 1; ! for (i = 0; i < count; ++i) ! { ! if (i == 0) ! li->li_prev = NULL; ! else ! li->li_prev = li - 1; ! if (i == count - 1) ! li->li_next = NULL; ! else ! li->li_next = li + 1; ! ++li; } return l; *************** *** 297,307 **** void list_free(list_T *l) { ! if (!in_free_unref_items) ! { ! list_free_contents(l); ! list_free_list(l); ! } } /* --- 297,307 ---- void list_free(list_T *l) { ! if (in_free_unref_items) ! return; ! ! list_free_contents(l); ! list_free_list(l); } /* *************** *** 540,552 **** { listitem_T *li = list_find(l, *idx); ! if (li == NULL) { ! if (*idx < 0) ! { ! *idx = 0; ! li = list_find(l, *idx); ! } } return li; } --- 540,552 ---- { listitem_T *li = list_find(l, *idx); ! if (li != NULL) ! return li; ! ! if (*idx < 0) { ! *idx = 0; ! li = list_find(l, *idx); } return li; } *************** *** 772,792 **** long orig_n1 = *n1; listitem_T *li = list_find_index(l, n1); if (li == NULL) { ! // Vim9: Allow for adding an item at the end. ! if (can_append && in_vim9script() ! && *n1 == l->lv_len && l->lv_lock == 0) ! { ! list_append_number(l, 0); ! li = list_find_index(l, n1); ! } ! if (li == NULL) ! { ! if (!quiet) ! semsg(_(e_list_index_out_of_range_nr), orig_n1); ! return NULL; ! } } return li; } --- 772,792 ---- long orig_n1 = *n1; listitem_T *li = list_find_index(l, n1); + if (li != NULL) + return li; + + // Vim9: Allow for adding an item at the end. + if (can_append && in_vim9script() + && *n1 == l->lv_len && l->lv_lock == 0) + { + list_append_number(l, 0); + li = list_find_index(l, n1); + } if (li == NULL) { ! if (!quiet) ! semsg(_(e_list_index_out_of_range_nr), orig_n1); ! return NULL; } return li; } *************** *** 1286,1330 **** return NULL; copy = list_alloc(); ! if (copy != NULL) { ! if (orig->lv_type == NULL || top || deep) ! copy->lv_type = NULL; ! else ! copy->lv_type = alloc_type(orig->lv_type); ! if (copyID != 0) ! { ! // Do this before adding the items, because one of the items may ! // refer back to this list. ! orig->lv_copyID = copyID; ! orig->lv_copylist = copy; ! } ! CHECK_LIST_MATERIALIZE(orig); ! for (item = orig->lv_first; item != NULL && !got_int; ! item = item->li_next) { ! ni = listitem_alloc(); ! if (ni == NULL) ! break; ! if (deep) { ! if (item_copy(&item->li_tv, &ni->li_tv, ! deep, FALSE, copyID) == FAIL) ! { ! vim_free(ni); ! break; ! } } - else - copy_tv(&item->li_tv, &ni->li_tv); - list_append(copy, ni); - } - ++copy->lv_refcount; - if (item != NULL) - { - list_unref(copy); - copy = NULL; } } return copy; --- 1286,1330 ---- return NULL; copy = list_alloc(); ! if (copy == NULL) ! return NULL; ! ! if (orig->lv_type == NULL || top || deep) ! copy->lv_type = NULL; ! else ! copy->lv_type = alloc_type(orig->lv_type); ! if (copyID != 0) { ! // Do this before adding the items, because one of the items may ! // refer back to this list. ! orig->lv_copyID = copyID; ! orig->lv_copylist = copy; ! } ! CHECK_LIST_MATERIALIZE(orig); ! for (item = orig->lv_first; item != NULL && !got_int; ! item = item->li_next) ! { ! ni = listitem_alloc(); ! if (ni == NULL) ! break; ! if (deep) { ! if (item_copy(&item->li_tv, &ni->li_tv, ! deep, FALSE, copyID) == FAIL) { ! vim_free(ni); ! break; } } + else + copy_tv(&item->li_tv, &ni->li_tv); + list_append(copy, ni); + } + ++copy->lv_refcount; + if (item != NULL) + { + list_unref(copy); + copy = NULL; } return copy; *************** *** 1491,1507 **** retval = list_join_inner(gap, l, sep, echo_style, restore_copyID, copyID, &join_ga); // Dispose each item in join_ga. ! if (join_ga.ga_data != NULL) { ! p = (join_T *)join_ga.ga_data; ! for (i = 0; i < join_ga.ga_len; ++i) ! { ! vim_free(p->tofree); ! ++p; ! } ! ga_clear(&join_ga); } return retval; } --- 1491,1507 ---- retval = list_join_inner(gap, l, sep, echo_style, restore_copyID, copyID, &join_ga); + if (join_ga.ga_data == NULL) + return retval; + // Dispose each item in join_ga. ! p = (join_T *)join_ga.ga_data; ! for (i = 0; i < join_ga.ga_len; ++i) { ! vim_free(p->tofree); ! ++p; } + ga_clear(&join_ga); return retval; } *************** *** 2560,2595 **** // message. Avoid a misleading error message for an empty string that // was not passed as argument. expr = &argvars[1]; ! if (expr->v_type != VAR_UNKNOWN) ! { ! typval_T save_val; ! typval_T save_key; ! prepare_vimvar(VV_VAL, &save_val); ! prepare_vimvar(VV_KEY, &save_key); ! // We reset "did_emsg" to be able to detect whether an error ! // occurred during evaluation of the expression. ! save_did_emsg = did_emsg; ! did_emsg = FALSE; ! ! if (argvars[0].v_type == VAR_DICT) ! dict_filter_map(argvars[0].vval.v_dict, filtermap, type, func_name, ! arg_errmsg, expr, rettv); ! else if (argvars[0].v_type == VAR_BLOB) ! blob_filter_map(argvars[0].vval.v_blob, filtermap, expr, rettv); ! else if (argvars[0].v_type == VAR_STRING) ! string_filter_map(tv_get_string(&argvars[0]), filtermap, expr, ! rettv); ! else // argvars[0].v_type == VAR_LIST ! list_filter_map(argvars[0].vval.v_list, filtermap, type, func_name, ! arg_errmsg, expr, rettv); ! restore_vimvar(VV_KEY, &save_key); ! restore_vimvar(VV_VAL, &save_val); ! did_emsg |= save_did_emsg; ! } } /* --- 2560,2595 ---- // message. Avoid a misleading error message for an empty string that // was not passed as argument. expr = &argvars[1]; ! if (expr->v_type == VAR_UNKNOWN) ! return; ! typval_T save_val; ! typval_T save_key; ! prepare_vimvar(VV_VAL, &save_val); ! prepare_vimvar(VV_KEY, &save_key); ! // We reset "did_emsg" to be able to detect whether an error ! // occurred during evaluation of the expression. ! save_did_emsg = did_emsg; ! did_emsg = FALSE; ! ! if (argvars[0].v_type == VAR_DICT) ! dict_filter_map(argvars[0].vval.v_dict, filtermap, type, func_name, ! arg_errmsg, expr, rettv); ! else if (argvars[0].v_type == VAR_BLOB) ! blob_filter_map(argvars[0].vval.v_blob, filtermap, expr, rettv); ! else if (argvars[0].v_type == VAR_STRING) ! string_filter_map(tv_get_string(&argvars[0]), filtermap, expr, ! rettv); ! else // argvars[0].v_type == VAR_LIST ! list_filter_map(argvars[0].vval.v_list, filtermap, type, func_name, ! arg_errmsg, expr, rettv); ! restore_vimvar(VV_KEY, &save_key); ! restore_vimvar(VV_VAL, &save_val); ! ! did_emsg |= save_did_emsg; } /* *** ../vim-9.0.1195/src/locale.c 2022-09-17 21:07:52.099993159 +0100 --- src/locale.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 151,170 **** char_u *p; p = mch_getenv((char_u *)"LC_ALL"); ! if (p == NULL || *p == NUL) ! { ! p = mch_getenv((char_u *)"LC_MESSAGES"); ! if (p == NULL || *p == NUL) ! { ! p = mch_getenv((char_u *)"LANG"); ! if (p != NULL && VIM_ISDIGIT(*p)) ! p = NULL; // ignore something like "1043" # ifdef HAVE_GET_LOCALE_VAL ! if (p == NULL || *p == NUL) ! p = get_locale_val(LC_CTYPE); # endif - } - } return p; } #endif --- 151,170 ---- char_u *p; p = mch_getenv((char_u *)"LC_ALL"); ! if (p != NULL && *p != NUL) ! return p; ! ! p = mch_getenv((char_u *)"LC_MESSAGES"); ! if (p != NULL && *p != NUL) ! return p; ! ! p = mch_getenv((char_u *)"LANG"); ! if (p != NULL && VIM_ISDIGIT(*p)) ! p = NULL; // ignore something like "1043" # ifdef HAVE_GET_LOCALE_VAL ! if (p == NULL || *p == NUL) ! p = get_locale_val(LC_CTYPE); # endif return p; } #endif *************** *** 504,514 **** static void init_locales(void) { ! if (!did_init_locales) ! { ! did_init_locales = TRUE; ! locales = find_locales(); ! } } # if defined(EXITFREE) || defined(PROTO) --- 504,514 ---- static void init_locales(void) { ! if (did_init_locales) ! return; ! ! did_init_locales = TRUE; ! locales = find_locales(); } # if defined(EXITFREE) || defined(PROTO) *************** *** 516,527 **** free_locales(void) { int i; ! if (locales != NULL) ! { ! for (i = 0; locales[i] != NULL; i++) ! vim_free(locales[i]); ! VIM_CLEAR(locales); ! } } # endif --- 516,528 ---- free_locales(void) { int i; ! ! if (locales == NULL) ! return; ! ! for (i = 0; locales[i] != NULL; i++) ! vim_free(locales[i]); ! VIM_CLEAR(locales); } # endif *** ../vim-9.0.1195/src/main.c 2022-12-26 14:37:40.432187694 +0000 --- src/main.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 3099,3121 **** int i; ESTACK_CHECK_DECLARATION ! if (cnt > 0) ! { ! curwin->w_cursor.lnum = 0; // just in case.. ! estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0); ! ESTACK_CHECK_SETUP # ifdef FEAT_EVAL current_sctx.sc_sid = SID_CMDARG; # endif for (i = 0; i < cnt; ++i) do_cmdline_cmd(cmds[i]); ! ESTACK_CHECK_NOW estack_pop(); # ifdef FEAT_EVAL ! current_sctx.sc_sid = 0; # endif ! TIME_MSG("--cmd commands"); ! } } /* --- 3099,3121 ---- int i; ESTACK_CHECK_DECLARATION ! if (cnt <= 0) ! return; ! ! curwin->w_cursor.lnum = 0; // just in case.. ! estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0); ! ESTACK_CHECK_SETUP # ifdef FEAT_EVAL current_sctx.sc_sid = SID_CMDARG; # endif for (i = 0; i < cnt; ++i) do_cmdline_cmd(cmds[i]); ! ESTACK_CHECK_NOW estack_pop(); # ifdef FEAT_EVAL ! current_sctx.sc_sid = 0; # endif ! TIME_MSG("--cmd commands"); } /* *************** *** 3369,3396 **** ESTACK_CHECK_DECLARATION ! if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL) ! { ! if (is_viminit) ! vimrc_found(NULL, NULL); ! estack_push(ETYPE_ENV, env, 0); ! ESTACK_CHECK_SETUP save_current_sctx = current_sctx; ! current_sctx.sc_version = 1; #ifdef FEAT_EVAL ! current_sctx.sc_sid = SID_ENV; ! current_sctx.sc_seq = 0; ! current_sctx.sc_lnum = 0; #endif ! do_cmdline_cmd(initstr); ! ESTACK_CHECK_NOW estack_pop(); ! current_sctx = save_current_sctx; ! return OK; ! } ! return FAIL; } #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) --- 3369,3395 ---- ESTACK_CHECK_DECLARATION ! if ((initstr = mch_getenv(env)) == NULL || *initstr == NUL) ! return FAIL; ! ! if (is_viminit) ! vimrc_found(NULL, NULL); ! estack_push(ETYPE_ENV, env, 0); ! ESTACK_CHECK_SETUP save_current_sctx = current_sctx; ! current_sctx.sc_version = 1; #ifdef FEAT_EVAL ! current_sctx.sc_sid = SID_ENV; ! current_sctx.sc_seq = 0; ! current_sctx.sc_lnum = 0; #endif ! do_cmdline_cmd(initstr); ! ESTACK_CHECK_NOW estack_pop(); ! current_sctx = save_current_sctx; ! return OK; } #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) *** ../vim-9.0.1195/src/map.c 2022-12-16 18:33:16.345960071 +0000 --- src/map.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 67,77 **** static void validate_maphash(void) { ! if (!maphash_valid) ! { ! CLEAR_FIELD(maphash); ! maphash_valid = TRUE; ! } } /* --- 67,77 ---- static void validate_maphash(void) { ! if (maphash_valid) ! return; ! ! CLEAR_FIELD(maphash); ! maphash_valid = TRUE; } /* *************** *** 581,588 **** // needs to be freed later (*keys_buf and *arg_buf). // replace_termcodes() also removes CTRL-Vs and sometimes backslashes. // If something like is simplified to 0x08 then mark it as simplified ! // and also add a n entry with a modifier, which will work when ! // modifyOtherKeys is working. if (haskey) { char_u *new_keys; --- 581,588 ---- // needs to be freed later (*keys_buf and *arg_buf). // replace_termcodes() also removes CTRL-Vs and sometimes backslashes. // If something like is simplified to 0x08 then mark it as simplified ! // and also add an entry with a modifier, which will work when using a key ! // protocol. if (haskey) { char_u *new_keys; *************** *** 1843,1874 **** // illegal utf-8 byte: // 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER res = alloc(STRLEN(p) * 4 + 1); ! if (res != NULL) { ! d = res; ! for (s = p; *s != NUL; ) ! { ! if ((s[0] == K_SPECIAL #ifdef FEAT_GUI || (gui.in_use && s[0] == CSI) #endif ! ) && s[1] != NUL && s[2] != NUL) ! { ! // Copy special key unmodified. ! *d++ = *s++; ! *d++ = *s++; ! *d++ = *s++; ! } ! else ! { ! // Add character, possibly multi-byte to destination, escaping ! // CSI and K_SPECIAL. Be careful, it can be an illegal byte! ! d = add_char2buf(PTR2CHAR(s), d); ! s += MB_CPTR2LEN(s); ! } } - *d = NUL; } return res; } --- 1843,1875 ---- // illegal utf-8 byte: // 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER res = alloc(STRLEN(p) * 4 + 1); ! if (res == NULL) ! return NULL; ! ! d = res; ! for (s = p; *s != NUL; ) { ! if ((s[0] == K_SPECIAL #ifdef FEAT_GUI || (gui.in_use && s[0] == CSI) #endif ! ) && s[1] != NUL && s[2] != NUL) ! { ! // Copy special key unmodified. ! *d++ = *s++; ! *d++ = *s++; ! *d++ = *s++; ! } ! else ! { ! // Add character, possibly multi-byte to destination, escaping ! // CSI and K_SPECIAL. Be careful, it can be an illegal byte! ! d = add_char2buf(PTR2CHAR(s), d); ! s += MB_CPTR2LEN(s); } } + *d = NUL; + return res; } *** ../vim-9.0.1195/src/mark.c 2022-09-21 13:07:19.577470776 +0100 --- src/mark.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 485,518 **** { char_u *p; ! if (fm->fname != NULL) ! { ! /* ! * First expand "~/" in the file name to the home directory. ! * Don't expand the whole name, it may contain other '~' chars. ! */ ! if (fm->fname[0] == '~' && (fm->fname[1] == '/' #ifdef BACKSLASH_IN_FILENAME ! || fm->fname[1] == '\\' #endif ! )) ! { ! int len; ! ! expand_env((char_u *)"~/", NameBuff, MAXPATHL); ! len = (int)STRLEN(NameBuff); ! vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); ! } ! else ! vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); ! ! // Try to shorten the file name. ! mch_dirname(IObuff, IOSIZE); ! p = shorten_fname(NameBuff, IObuff); ! // buflist_new() will call fmarks_check_names() ! (void)buflist_new(NameBuff, p, (linenr_T)1, 0); } } /* --- 485,518 ---- { char_u *p; ! if (fm->fname == NULL) ! return; ! ! /* ! * First expand "~/" in the file name to the home directory. ! * Don't expand the whole name, it may contain other '~' chars. ! */ ! if (fm->fname[0] == '~' && (fm->fname[1] == '/' #ifdef BACKSLASH_IN_FILENAME ! || fm->fname[1] == '\\' #endif ! )) ! { ! int len; ! expand_env((char_u *)"~/", NameBuff, MAXPATHL); ! len = (int)STRLEN(NameBuff); ! vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1); } + else + vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1); + + // Try to shorten the file name. + mch_dirname(IObuff, IOSIZE); + p = shorten_fname(NameBuff, IObuff); + + // buflist_new() will call fmarks_check_names() + (void)buflist_new(NameBuff, p, (linenr_T)1, 0); } /* *** ../vim-9.0.1195/src/match.c 2022-11-18 22:14:04.802988148 +0000 --- src/match.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 978,991 **** if (dict_has_key(tv->vval.v_dict, "conceal")) *conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE); ! if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL) { ! *win = find_win_by_nr_or_id(&di->di_tv); ! if (*win == NULL) ! { ! emsg(_(e_invalid_window_number)); ! return FAIL; ! } } return OK; --- 978,991 ---- if (dict_has_key(tv->vval.v_dict, "conceal")) *conceal_char = dict_get_string(tv->vval.v_dict, "conceal", FALSE); ! if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) == NULL) ! return OK; ! ! *win = find_win_by_nr_or_id(&di->di_tv); ! if (*win == NULL) { ! emsg(_(e_invalid_window_number)); ! return FAIL; } return OK; *************** *** 1330,1361 **** void f_matcharg(typval_T *argvars UNUSED, typval_T *rettv) { ! if (rettv_list_alloc(rettv) == OK) ! { # ifdef FEAT_SEARCH_EXTRA ! int id; ! matchitem_T *m; ! if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) ! return; ! id = (int)tv_get_number(&argvars[0]); ! if (id >= 1 && id <= 3) { ! if ((m = get_match(curwin, id)) != NULL) ! { ! list_append_string(rettv->vval.v_list, ! syn_id2name(m->mit_hlg_id), -1); ! list_append_string(rettv->vval.v_list, m->mit_pattern, -1); ! } ! else ! { ! list_append_string(rettv->vval.v_list, NULL, -1); ! list_append_string(rettv->vval.v_list, NULL, -1); ! } } - # endif } } /* --- 1330,1361 ---- void f_matcharg(typval_T *argvars UNUSED, typval_T *rettv) { ! if (rettv_list_alloc(rettv) != OK) ! return; ! # ifdef FEAT_SEARCH_EXTRA ! int id; ! matchitem_T *m; ! if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) ! return; ! id = (int)tv_get_number(&argvars[0]); ! if (id >= 1 && id <= 3) ! { ! if ((m = get_match(curwin, id)) != NULL) { ! list_append_string(rettv->vval.v_list, ! syn_id2name(m->mit_hlg_id), -1); ! list_append_string(rettv->vval.v_list, m->mit_pattern, -1); ! } ! else ! { ! list_append_string(rettv->vval.v_list, NULL, -1); ! list_append_string(rettv->vval.v_list, NULL, -1); } } + # endif } /* *** ../vim-9.0.1195/src/mbyte.c 2023-01-10 16:02:41.248313354 +0000 --- src/mbyte.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 809,825 **** void remove_bom(char_u *s) { ! if (enc_utf8) ! { ! char_u *p = s; ! while ((p = vim_strbyte(p, 0xef)) != NULL) ! { ! if (p[1] == 0xbb && p[2] == 0xbf) ! STRMOVE(p, p + 3); ! else ! ++p; ! } } } #endif --- 809,825 ---- void remove_bom(char_u *s) { ! if (!enc_utf8) ! return; ! char_u *p = s; ! ! while ((p = vim_strbyte(p, 0xef)) != NULL) ! { ! if (p[1] == 0xbb && p[2] == 0xbf) ! STRMOVE(p, p + 3); ! else ! ++p; } } #endif *************** *** 4590,4645 **** // copy "enc" to allocated memory, with room for two '-' r = alloc(STRLEN(enc) + 3); ! if (r != NULL) { ! // Make it all lower case and replace '_' with '-'. ! p = r; ! for (s = enc; *s != NUL; ++s) ! { ! if (*s == '_') ! *p++ = '-'; ! else ! *p++ = TOLOWER_ASC(*s); ! } ! *p = NUL; ! // Skip "2byte-" and "8bit-". ! p = enc_skip(r); ! // Change "microsoft-cp" to "cp". Used in some spell files. ! if (STRNCMP(p, "microsoft-cp", 12) == 0) ! STRMOVE(p, p + 10); ! // "iso8859" -> "iso-8859" ! if (STRNCMP(p, "iso8859", 7) == 0) ! { ! STRMOVE(p + 4, p + 3); ! p[3] = '-'; ! } ! // "iso-8859n" -> "iso-8859-n" ! if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8])) ! { ! STRMOVE(p + 9, p + 8); ! p[8] = '-'; ! } ! // "latin-N" -> "latinN" ! if (STRNCMP(p, "latin-", 6) == 0) ! STRMOVE(p + 5, p + 6); ! if (enc_canon_search(p) >= 0) ! { ! // canonical name can be used unmodified ! if (p != r) ! STRMOVE(r, p); ! } ! else if ((i = enc_alias_search(p)) >= 0) ! { ! // alias recognized, get canonical name ! vim_free(r); ! r = vim_strsave((char_u *)enc_canon_table[i].name); ! } } return r; } --- 4590,4645 ---- // copy "enc" to allocated memory, with room for two '-' r = alloc(STRLEN(enc) + 3); ! if (r == NULL) ! return NULL; ! ! // Make it all lower case and replace '_' with '-'. ! p = r; ! for (s = enc; *s != NUL; ++s) { ! if (*s == '_') ! *p++ = '-'; ! else ! *p++ = TOLOWER_ASC(*s); ! } ! *p = NUL; ! // Skip "2byte-" and "8bit-". ! p = enc_skip(r); ! // Change "microsoft-cp" to "cp". Used in some spell files. ! if (STRNCMP(p, "microsoft-cp", 12) == 0) ! STRMOVE(p, p + 10); ! // "iso8859" -> "iso-8859" ! if (STRNCMP(p, "iso8859", 7) == 0) ! { ! STRMOVE(p + 4, p + 3); ! p[3] = '-'; ! } ! // "iso-8859n" -> "iso-8859-n" ! if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8])) ! { ! STRMOVE(p + 9, p + 8); ! p[8] = '-'; ! } ! // "latin-N" -> "latinN" ! if (STRNCMP(p, "latin-", 6) == 0) ! STRMOVE(p + 5, p + 6); ! if (enc_canon_search(p) >= 0) ! { ! // canonical name can be used unmodified ! if (p != r) ! STRMOVE(r, p); ! } ! else if ((i = enc_alias_search(p)) >= 0) ! { ! // alias recognized, get canonical name ! vim_free(r); ! r = vim_strsave((char_u *)enc_canon_table[i].name); } return r; } *************** *** 5269,5294 **** d = string_convert_ext(&input_conv, ptr, &dlen, restp == NULL ? NULL : &unconvertlen); ! if (d != NULL) { ! if (dlen <= maxlen) { ! if (unconvertlen > 0) ! { ! // Move the unconverted characters to allocated memory. ! *restp = alloc(unconvertlen); ! if (*restp != NULL) ! mch_memmove(*restp, ptr + len - unconvertlen, unconvertlen); ! *restlenp = unconvertlen; ! } ! mch_memmove(ptr, d, dlen); } ! else ! // result is too long, keep the unconverted text (the caller must ! // have done something wrong!) ! dlen = len; ! vim_free(d); } return dlen; } --- 5269,5294 ---- d = string_convert_ext(&input_conv, ptr, &dlen, restp == NULL ? NULL : &unconvertlen); ! if (d == NULL) ! return dlen; ! ! if (dlen <= maxlen) { ! if (unconvertlen > 0) { ! // Move the unconverted characters to allocated memory. ! *restp = alloc(unconvertlen); ! if (*restp != NULL) ! mch_memmove(*restp, ptr + len - unconvertlen, unconvertlen); ! *restlenp = unconvertlen; } ! mch_memmove(ptr, d, dlen); } + else + // result is too long, keep the unconverted text (the caller must + // have done something wrong!) + dlen = len; + vim_free(d); return dlen; } *** ../vim-9.0.1195/src/memfile.c 2022-02-11 16:06:57.000000000 +0000 --- src/memfile.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 879,894 **** { bhdr_T *hp; ! if ((hp = ALLOC_ONE(bhdr_T)) != NULL) { ! if ((hp->bh_data = alloc((size_t)mfp->mf_page_size * page_count)) ! == NULL) ! { ! vim_free(hp); // not enough memory ! return NULL; ! } ! hp->bh_page_count = page_count; } return hp; } --- 879,894 ---- { bhdr_T *hp; ! if ((hp = ALLOC_ONE(bhdr_T)) == NULL) ! return NULL; ! ! if ((hp->bh_data = alloc((size_t)mfp->mf_page_size * page_count)) ! == NULL) { ! vim_free(hp); // not enough memory ! return NULL; } + hp->bh_page_count = page_count; return hp; } *************** *** 1209,1220 **** void mf_fullname(memfile_T *mfp) { ! if (mfp != NULL && mfp->mf_fname != NULL && mfp->mf_ffname != NULL) ! { ! vim_free(mfp->mf_fname); ! mfp->mf_fname = mfp->mf_ffname; ! mfp->mf_ffname = NULL; ! } } /* --- 1209,1220 ---- void mf_fullname(memfile_T *mfp) { ! if (mfp == NULL || mfp->mf_fname == NULL || mfp->mf_ffname == NULL) ! return; ! ! vim_free(mfp->mf_fname); ! mfp->mf_fname = mfp->mf_ffname; ! mfp->mf_ffname = NULL; } /* *** ../vim-9.0.1195/src/memline.c 2022-12-23 12:17:26.909264456 +0000 --- src/memline.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 422,442 **** static void ml_set_mfp_crypt(buf_T *buf) { ! if (*buf->b_p_key != NUL) ! { ! int method_nr = crypt_get_method_nr(buf); ! if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD) ! { ! // Generate a seed and store it in the memfile. ! sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0); ! } ! #ifdef FEAT_SODIUM ! else if (method_nr == CRYPT_M_SOD) ! crypt_sodium_randombytes_buf(buf->b_ml.ml_mfp->mf_seed, ! MF_SEED_LEN); ! #endif } } /* --- 422,442 ---- static void ml_set_mfp_crypt(buf_T *buf) { ! if (*buf->b_p_key == NUL) ! return; ! int method_nr = crypt_get_method_nr(buf); ! ! if (method_nr > CRYPT_M_ZIP && method_nr < CRYPT_M_SOD) ! { ! // Generate a seed and store it in the memfile. ! sha2_seed(buf->b_ml.ml_mfp->mf_seed, MF_SEED_LEN, NULL, 0); } + #ifdef FEAT_SODIUM + else if (method_nr == CRYPT_M_SOD) + crypt_sodium_randombytes_buf(buf->b_ml.ml_mfp->mf_seed, + MF_SEED_LEN); + #endif } /* *************** *** 2090,2111 **** char_u *d = NULL, *s, *f; f = fix_fname(name != NULL ? name : (char_u *)""); ! if (f != NULL) ! { ! s = alloc(STRLEN(f) + 1); ! if (s != NULL) ! { ! STRCPY(s, f); ! for (d = s; *d != NUL; MB_PTR_ADV(d)) ! if (vim_ispathsep(*d)) ! *d = '%'; ! dir[STRLEN(dir) - 1] = NUL; // remove one trailing slash ! d = concat_fnames(dir, s, TRUE); ! vim_free(s); ! } ! vim_free(f); } return d; } #endif --- 2090,2111 ---- char_u *d = NULL, *s, *f; f = fix_fname(name != NULL ? name : (char_u *)""); ! if (f == NULL) ! return NULL; ! s = alloc(STRLEN(f) + 1); ! if (s != NULL) ! { ! STRCPY(s, f); ! for (d = s; *d != NUL; MB_PTR_ADV(d)) ! if (vim_ispathsep(*d)) ! *d = '%'; ! ! dir[STRLEN(dir) - 1] = NUL; // remove one trailing slash ! d = concat_fnames(dir, s, TRUE); ! vim_free(s); } + vim_free(f); return d; } #endif *************** *** 5473,5496 **** int text_len; cryptstate_T *state; ! if (dp->db_id == DATA_ID) ! { ! head_end = (char_u *)(&dp->db_index[dp->db_line_count]); ! text_start = (char_u *)dp + dp->db_txt_start; ! text_len = dp->db_txt_end - dp->db_txt_start; ! ! if (head_end > text_start || dp->db_txt_start > size ! || dp->db_txt_end > size) ! return; // data was messed up ! ! state = ml_crypt_prepare(mfp, offset, TRUE); ! if (state != NULL) ! { ! // Decrypt the text in place. ! crypt_decode_inplace(state, text_start, text_len, FALSE); ! crypt_free_state(state); ! } ! } } /* --- 5473,5496 ---- int text_len; cryptstate_T *state; ! if (dp->db_id != DATA_ID) ! return; ! ! head_end = (char_u *)(&dp->db_index[dp->db_line_count]); ! text_start = (char_u *)dp + dp->db_txt_start; ! text_len = dp->db_txt_end - dp->db_txt_start; ! ! if (head_end > text_start || dp->db_txt_start > size ! || dp->db_txt_end > size) ! return; // data was messed up ! ! state = ml_crypt_prepare(mfp, offset, TRUE); ! if (state == NULL) ! return; ! ! // Decrypt the text in place. ! crypt_decode_inplace(state, text_start, text_len, FALSE); ! crypt_free_state(state); } /* *** ../vim-9.0.1195/src/menu.c 2022-11-13 21:09:58.594211220 +0000 --- src/menu.c 2023-01-14 12:27:21.272079540 +0000 *************** *** 1763,1774 **** int i; p = vim_strnsave(name, len + mode_chars_len); ! if (p != NULL) ! { ! mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4)); ! for (i = 0; i < mode_chars_len; ++i) ! p[5 + i] = menu_mode_chars[idx][i]; ! } return p; } --- 1763,1774 ---- int i; p = vim_strnsave(name, len + mode_chars_len); ! if (p == NULL) ! return NULL; ! ! mch_memmove(p + 5 + mode_chars_len, p + 5, (size_t)(len - 4)); ! for (i = 0; i < mode_chars_len; ++i) ! p[5 + i] = menu_mode_chars[idx][i]; return p; } *************** *** 2008,2031 **** break; // Only show a popup when it is defined and has entries ! if (menu != NULL && menu->children != NULL) ! { # if defined(FEAT_GUI) ! if (gui.in_use) ! { ! // Update the menus now, in case the MenuPopup autocommand did ! // anything. ! gui_update_menus(0); ! gui_mch_show_popupmenu(menu); ! } # endif # if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU) ! else # endif # if defined(FEAT_TERM_POPUP_MENU) ! pum_show_popupmenu(menu); # endif - } } #endif --- 2008,2031 ---- break; // Only show a popup when it is defined and has entries ! if (menu == NULL || menu->children == NULL) ! return; ! # if defined(FEAT_GUI) ! if (gui.in_use) ! { ! // Update the menus now, in case the MenuPopup autocommand did ! // anything. ! gui_update_menus(0); ! gui_mch_show_popupmenu(menu); ! } # endif # if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU) ! else # endif # if defined(FEAT_TERM_POPUP_MENU) ! pum_show_popupmenu(menu); # endif } #endif *************** *** 2255,2293 **** vimmenu_T menuarg; tbuf = alloc(5 + (unsigned int)STRLEN(tearpath)); ! if (tbuf != NULL) ! { ! tbuf[0] = K_SPECIAL; ! tbuf[1] = K_SECOND(K_TEAROFF); ! tbuf[2] = K_THIRD(K_TEAROFF); ! STRCPY(tbuf + 3, tearpath); ! STRCAT(tbuf + 3, "\r"); ! ! STRCAT(tearpath, "."); ! STRCAT(tearpath, TEAR_STRING); ! ! // Priority of tear-off is always 1 ! t = pri_tab[pri_idx + 1]; ! pri_tab[pri_idx + 1] = 1; #ifdef FEAT_TOOLBAR ! menuarg.iconfile = NULL; ! menuarg.iconidx = -1; ! menuarg.icon_builtin = FALSE; #endif ! menuarg.noremap[0] = REMAP_NONE; ! menuarg.silent[0] = TRUE; ! menuarg.modes = MENU_ALL_MODES; ! add_menu_path(tearpath, &menuarg, pri_tab, tbuf, FALSE); ! menuarg.modes = MENU_TIP_MODE; ! add_menu_path(tearpath, &menuarg, pri_tab, ! (char_u *)_("Tear off this menu"), FALSE); ! pri_tab[pri_idx + 1] = t; ! vim_free(tbuf); ! } } /* --- 2255,2293 ---- vimmenu_T menuarg; tbuf = alloc(5 + (unsigned int)STRLEN(tearpath)); ! if (tbuf == NULL) ! return; ! ! tbuf[0] = K_SPECIAL; ! tbuf[1] = K_SECOND(K_TEAROFF); ! tbuf[2] = K_THIRD(K_TEAROFF); ! STRCPY(tbuf + 3, tearpath); ! STRCAT(tbuf + 3, "\r"); ! ! STRCAT(tearpath, "."); ! STRCAT(tearpath, TEAR_STRING); ! ! // Priority of tear-off is always 1 ! t = pri_tab[pri_idx + 1]; ! pri_tab[pri_idx + 1] = 1; #ifdef FEAT_TOOLBAR ! menuarg.iconfile = NULL; ! menuarg.iconidx = -1; ! menuarg.icon_builtin = FALSE; #endif ! menuarg.noremap[0] = REMAP_NONE; ! menuarg.silent[0] = TRUE; ! menuarg.modes = MENU_ALL_MODES; ! add_menu_path(tearpath, &menuarg, pri_tab, tbuf, FALSE); ! menuarg.modes = MENU_TIP_MODE; ! add_menu_path(tearpath, &menuarg, pri_tab, ! (char_u *)_("Tear off this menu"), FALSE); ! pri_tab[pri_idx + 1] = t; ! vim_free(tbuf); } /* *************** *** 2789,2804 **** name[len] = NUL; dname = menu_text(name, NULL, NULL); name[len] = i; ! if (dname != NULL) ! { ! for (i = 0; i < menutrans_ga.ga_len; ++i) ! if (STRICMP(dname, tp[i].from_noamp) == 0) ! { ! vim_free(dname); ! return tp[i].to; ! } ! vim_free(dname); ! } return NULL; } --- 2789,2804 ---- name[len] = NUL; dname = menu_text(name, NULL, NULL); name[len] = i; ! if (dname == NULL) ! return NULL; ! ! for (i = 0; i < menutrans_ga.ga_len; ++i) ! if (STRICMP(dname, tp[i].from_noamp) == 0) ! { ! vim_free(dname); ! return tp[i].to; ! } ! vim_free(dname); return NULL; } *** ../vim-9.0.1195/src/message.c 2023-01-04 15:56:47.868550539 +0000 --- src/message.c 2023-01-14 12:27:21.276079541 +0000 *************** *** 375,389 **** // give the raw message so the user at least gets a hint. return msg((char *)s); } - else - { - va_list arglist; ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg((char *)IObuff); ! } } int --- 375,387 ---- // give the raw message so the user at least gets a hint. return msg((char *)s); } ! va_list arglist; ! ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg((char *)IObuff); } int *************** *** 395,409 **** // give the raw message so the user at least gets a hint. return msg_attr((char *)s, attr); } - else - { - va_list arglist; ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg_attr((char *)IObuff, attr); ! } } int --- 393,405 ---- // give the raw message so the user at least gets a hint. return msg_attr((char *)s, attr); } ! va_list arglist; ! ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg_attr((char *)IObuff, attr); } int *************** *** 415,429 **** // give the raw message so the user at least gets a hint. return msg_attr_keep((char *)s, attr, TRUE); } - else - { - va_list arglist; ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg_attr_keep((char *)IObuff, attr, TRUE); ! } } #endif --- 411,423 ---- // give the raw message so the user at least gets a hint. return msg_attr_keep((char *)s, attr, TRUE); } ! va_list arglist; ! ! va_start(arglist, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); ! va_end(arglist); ! return msg_attr_keep((char *)IObuff, attr, TRUE); } #endif *************** *** 834,849 **** void iemsg(char *s) { ! if (!emsg_not_now()) ! { ! emsg_core((char_u *)s); #if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL) ! set_vim_var_string(VV_ERRMSG, (char_u *)s, -1); ! msg_putchar('\n'); // avoid overwriting the error message ! out_flush(); ! abort(); #endif - } } #ifndef PROTO // manual proto with __attribute__ --- 828,843 ---- void iemsg(char *s) { ! if (emsg_not_now()) ! return; ! ! emsg_core((char_u *)s); #if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL) ! set_vim_var_string(VV_ERRMSG, (char_u *)s, -1); ! msg_putchar('\n'); // avoid overwriting the error message ! out_flush(); ! abort(); #endif } #ifndef PROTO // manual proto with __attribute__ *************** *** 856,884 **** void siemsg(const char *s, ...) { ! if (!emsg_not_now()) { ! if (IObuff == NULL) ! { ! // Very early in initialisation and already something wrong, just ! // give the raw message so the user at least gets a hint. ! emsg_core((char_u *)s); ! } ! else ! { ! va_list ap; ! va_start(ap, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, ap); ! va_end(ap); ! emsg_core(IObuff); ! } # ifdef ABORT_ON_INTERNAL_ERROR ! msg_putchar('\n'); // avoid overwriting the error message ! out_flush(); ! abort(); # endif - } } #endif --- 850,878 ---- void siemsg(const char *s, ...) { ! if (emsg_not_now()) ! return; ! ! if (IObuff == NULL) { ! // Very early in initialisation and already something wrong, just ! // give the raw message so the user at least gets a hint. ! emsg_core((char_u *)s); ! } ! else ! { ! va_list ap; ! va_start(ap, s); ! vim_vsnprintf((char *)IObuff, IOSIZE, s, ap); ! va_end(ap); ! emsg_core(IObuff); ! } # ifdef ABORT_ON_INTERNAL_ERROR ! msg_putchar('\n'); // avoid overwriting the error message ! out_flush(); ! abort(); # endif } #endif *************** *** 1006,1033 **** // allocate an entry and add the message at the end of the history p = ALLOC_ONE(struct msg_hist); ! if (p != NULL) ! { ! if (len < 0) ! len = (int)STRLEN(s); ! // remove leading and trailing newlines ! while (len > 0 && *s == '\n') ! { ! ++s; ! --len; ! } ! while (len > 0 && s[len - 1] == '\n') ! --len; ! p->msg = vim_strnsave(s, len); ! p->next = NULL; ! p->attr = attr; ! if (last_msg_hist != NULL) ! last_msg_hist->next = p; ! last_msg_hist = p; ! if (first_msg_hist == NULL) ! first_msg_hist = last_msg_hist; ! ++msg_hist_len; ! } } /* --- 1000,1027 ---- // allocate an entry and add the message at the end of the history p = ALLOC_ONE(struct msg_hist); ! if (p == NULL) ! return; ! ! if (len < 0) ! len = (int)STRLEN(s); ! // remove leading and trailing newlines ! while (len > 0 && *s == '\n') ! { ! ++s; ! --len; ! } ! while (len > 0 && s[len - 1] == '\n') ! --len; ! p->msg = vim_strnsave(s, len); ! p->next = NULL; ! p->attr = attr; ! if (last_msg_hist != NULL) ! last_msg_hist->next = p; ! last_msg_hist = p; ! if (first_msg_hist == NULL) ! first_msg_hist = last_msg_hist; ! ++msg_hist_len; } /* *** ../vim-9.0.1195/src/misc1.c 2022-10-18 15:10:07.541220976 +0100 --- src/misc1.c 2023-01-14 12:27:21.276079541 +0000 *************** *** 1119,1177 **** called_vim_beep = TRUE; #endif ! if (emsg_silent == 0 && !in_assert_fails) { - if (!((bo_flags & val) || (bo_flags & BO_ALL))) - { #ifdef ELAPSED_FUNC ! static int did_init = FALSE; ! static elapsed_T start_tv; ! // Only beep once per half a second, otherwise a sequence of beeps ! // would freeze Vim. ! if (!did_init || ELAPSED_FUNC(start_tv) > 500) ! { ! did_init = TRUE; ! ELAPSED_INIT(start_tv); #endif ! if (p_vb #ifdef FEAT_GUI ! // While the GUI is starting up the termcap is set for ! // the GUI but the output still goes to a terminal. ! && !(gui.in_use && gui.starting) #endif ! ) ! { ! out_str_cf(T_VB); #ifdef FEAT_VTP ! // No restore color information, refresh the screen. ! if (has_vtp_working() != 0 # ifdef FEAT_TERMGUICOLORS ! && (p_tgc || (!p_tgc && t_colors >= 256)) # endif ! ) ! { ! redraw_later(UPD_CLEAR); ! update_screen(0); ! redrawcmd(); ! } ! #endif } - else - out_char(BELL); - #ifdef ELAPSED_FUNC - } #endif } ! // When 'debug' contains "beep" produce a message. If we are sourcing ! // a script or executing a function give the user a hint where the beep ! // comes from. ! if (vim_strchr(p_debug, 'e') != NULL) ! { ! msg_source(HL_ATTR(HLF_W)); ! msg_attr(_("Beep!"), HL_ATTR(HLF_W)); ! } } } --- 1119,1177 ---- called_vim_beep = TRUE; #endif ! if (emsg_silent != 0 || in_assert_fails) ! return; ! ! if (!((bo_flags & val) || (bo_flags & BO_ALL))) { #ifdef ELAPSED_FUNC ! static int did_init = FALSE; ! static elapsed_T start_tv; ! // Only beep once per half a second, otherwise a sequence of beeps ! // would freeze Vim. ! if (!did_init || ELAPSED_FUNC(start_tv) > 500) ! { ! did_init = TRUE; ! ELAPSED_INIT(start_tv); #endif ! if (p_vb #ifdef FEAT_GUI ! // While the GUI is starting up the termcap is set for ! // the GUI but the output still goes to a terminal. ! && !(gui.in_use && gui.starting) #endif ! ) ! { ! out_str_cf(T_VB); #ifdef FEAT_VTP ! // No restore color information, refresh the screen. ! if (has_vtp_working() != 0 # ifdef FEAT_TERMGUICOLORS ! && (p_tgc || (!p_tgc && t_colors >= 256)) # endif ! ) ! { ! redraw_later(UPD_CLEAR); ! update_screen(0); ! redrawcmd(); } #endif + } + else + out_char(BELL); + #ifdef ELAPSED_FUNC } + #endif + } ! // When 'debug' contains "beep" produce a message. If we are sourcing ! // a script or executing a function give the user a hint where the beep ! // comes from. ! if (vim_strchr(p_debug, 'e') != NULL) ! { ! msg_source(HL_ATTR(HLF_W)); ! msg_attr(_("Beep!"), HL_ATTR(HLF_W)); } } *** ../vim-9.0.1195/src/misc2.c 2023-01-13 18:46:53.426481325 +0000 --- src/misc2.c 2023-01-14 12:27:21.276079541 +0000 *************** *** 1130,1154 **** int key0; int key1; ! if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)) { ! // TAB is a special case ! if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) { ! *modifiers &= ~MOD_MASK_SHIFT; ! return K_S_TAB; } - key0 = KEY2TERMCAP0(key); - key1 = KEY2TERMCAP1(key); - for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) - if (key0 == modifier_keys_table[i + 3] - && key1 == modifier_keys_table[i + 4] - && (*modifiers & modifier_keys_table[i])) - { - *modifiers &= ~modifier_keys_table[i]; - return TERMCAP2KEY(modifier_keys_table[i + 1], - modifier_keys_table[i + 2]); - } } return key; } --- 1130,1156 ---- int key0; int key1; ! if (!(*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT))) ! return key; ! ! // TAB is a special case ! if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) { ! *modifiers &= ~MOD_MASK_SHIFT; ! return K_S_TAB; ! } ! key0 = KEY2TERMCAP0(key); ! key1 = KEY2TERMCAP1(key); ! for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) ! { ! if (key0 == modifier_keys_table[i + 3] ! && key1 == modifier_keys_table[i + 4] ! && (*modifiers & modifier_keys_table[i])) { ! *modifiers &= ~modifier_keys_table[i]; ! return TERMCAP2KEY(modifier_keys_table[i + 1], ! modifier_keys_table[i + 2]); } } return key; } *************** *** 1537,1558 **** int may_adjust_key_for_ctrl(int modifiers, int key) { ! if (modifiers & MOD_MASK_CTRL) { - if (ASCII_ISALPHA(key)) - { #ifdef FEAT_TERMINAL ! check_no_reduce_keys(); // may update the no_reduce_keys flag #endif ! return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key; ! } ! if (key == '2') ! return '@'; ! if (key == '6') ! return '^'; ! if (key == '-') ! return '_'; } return key; } --- 1539,1560 ---- int may_adjust_key_for_ctrl(int modifiers, int key) { ! if (!(modifiers & MOD_MASK_CTRL)) ! return key; ! ! if (ASCII_ISALPHA(key)) { #ifdef FEAT_TERMINAL ! check_no_reduce_keys(); // may update the no_reduce_keys flag #endif ! return no_reduce_keys == 0 ? TOUPPER_ASC(key) : key; } + if (key == '2') + return '@'; + if (key == '6') + return '^'; + if (key == '-') + return '_'; return key; } *************** *** 2820,2840 **** // allocate memory str = alloc(cnt + 1); ! if (str != NULL) { ! // Read the string. Quit when running into the EOF. ! for (i = 0; i < cnt; ++i) { ! c = getc(fd); ! if (c == EOF) ! { ! vim_free(str); ! return NULL; ! } ! str[i] = c; } ! str[i] = NUL; } return str; } --- 2822,2842 ---- // allocate memory str = alloc(cnt + 1); ! if (str == NULL) ! return NULL; ! ! // Read the string. Quit when running into the EOF. ! for (i = 0; i < cnt; ++i) { ! c = getc(fd); ! if (c == EOF) { ! vim_free(str); ! return NULL; } ! str[i] = c; } + str[i] = NUL; return str; } *** ../vim-9.0.1195/src/move.c 2022-12-31 15:12:58.046637322 +0000 --- src/move.c 2023-01-14 12:27:21.276079541 +0000 *************** *** 244,258 **** static void reset_skipcol(void) { ! if (curwin->w_skipcol != 0) ! { ! curwin->w_skipcol = 0; ! // Should use the least expensive way that displays all that changed. ! // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw ! // enough when the top line gets another screen line. ! redraw_later(UPD_SOME_VALID); ! } } /* --- 244,258 ---- static void reset_skipcol(void) { ! if (curwin->w_skipcol == 0) ! return; ! curwin->w_skipcol = 0; ! ! // Should use the least expensive way that displays all that changed. ! // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw ! // enough when the top line gets another screen line. ! redraw_later(UPD_SOME_VALID); } /* *************** *** 980,996 **** validate_virtcol_win(win_T *wp) { check_cursor_moved(wp); ! if (!(wp->w_valid & VALID_VIRTCOL)) ! { #ifdef FEAT_PROP_POPUP ! wp->w_virtcol_first_char = 0; #endif ! getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL); #ifdef FEAT_SYN_HL ! redraw_for_cursorcolumn(wp); #endif ! wp->w_valid |= VALID_VIRTCOL; ! } } /* --- 980,997 ---- validate_virtcol_win(win_T *wp) { check_cursor_moved(wp); ! ! if (wp->w_valid & VALID_VIRTCOL) ! return; ! #ifdef FEAT_PROP_POPUP ! wp->w_virtcol_first_char = 0; #endif ! getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL); #ifdef FEAT_SYN_HL ! redraw_for_cursorcolumn(wp); #endif ! wp->w_valid |= VALID_VIRTCOL; } /* *************** *** 1000,1019 **** validate_cheight(void) { check_cursor_moved(curwin); ! if (!(curwin->w_valid & VALID_CHEIGHT)) ! { #ifdef FEAT_DIFF ! if (curwin->w_cursor.lnum == curwin->w_topline) ! curwin->w_cline_height = plines_nofill(curwin->w_cursor.lnum) ! + curwin->w_topfill; ! else #endif ! curwin->w_cline_height = plines(curwin->w_cursor.lnum); #ifdef FEAT_FOLDING ! curwin->w_cline_folded = hasFolding(curwin->w_cursor.lnum, NULL, NULL); #endif ! curwin->w_valid |= VALID_CHEIGHT; ! } } /* --- 1001,1021 ---- validate_cheight(void) { check_cursor_moved(curwin); ! ! if (curwin->w_valid & VALID_CHEIGHT) ! return; ! #ifdef FEAT_DIFF ! if (curwin->w_cursor.lnum == curwin->w_topline) ! curwin->w_cline_height = plines_nofill(curwin->w_cursor.lnum) ! + curwin->w_topfill; ! else #endif ! curwin->w_cline_height = plines(curwin->w_cursor.lnum); #ifdef FEAT_FOLDING ! curwin->w_cline_folded = hasFolding(curwin->w_cursor.lnum, NULL, NULL); #endif ! curwin->w_valid |= VALID_CHEIGHT; } /* *************** *** 1027,1056 **** int width; validate_virtcol(); - if (!(curwin->w_valid & VALID_WCOL)) - { - col = curwin->w_virtcol; - off = curwin_col_off(); - col += off; - width = curwin->w_width - off + curwin_col_off2(); ! // long line wrapping, adjust curwin->w_wrow ! if (curwin->w_p_wrap ! && col >= (colnr_T)curwin->w_width ! && width > 0) ! // use same formula as what is used in curs_columns() ! col -= ((col - curwin->w_width) / width + 1) * width; ! if (col > (int)curwin->w_leftcol) ! col -= curwin->w_leftcol; ! else ! col = 0; ! curwin->w_wcol = col; ! curwin->w_valid |= VALID_WCOL; #ifdef FEAT_PROP_POPUP ! curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED; #endif - } } /* --- 1029,1059 ---- int width; validate_virtcol(); ! if (curwin->w_valid & VALID_WCOL) ! return; ! col = curwin->w_virtcol; ! off = curwin_col_off(); ! col += off; ! width = curwin->w_width - off + curwin_col_off2(); ! ! // long line wrapping, adjust curwin->w_wrow ! if (curwin->w_p_wrap ! && col >= (colnr_T)curwin->w_width ! && width > 0) ! // use same formula as what is used in curs_columns() ! col -= ((col - curwin->w_width) / width + 1) * width; ! if (col > (int)curwin->w_leftcol) ! col -= curwin->w_leftcol; ! else ! col = 0; ! curwin->w_wcol = col; ! ! curwin->w_valid |= VALID_WCOL; #ifdef FEAT_PROP_POPUP ! curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED; #endif } /* *************** *** 1999,2020 **** { int n; ! if (wp->w_topfill > 0) { ! n = plines_win_nofill(wp, wp->w_topline, TRUE); ! if (wp->w_topfill + n > wp->w_height) { ! if (down && wp->w_topline > 1) ! { ! --wp->w_topline; wp->w_topfill = 0; - } - else - { - wp->w_topfill = wp->w_height - n; - if (wp->w_topfill < 0) - wp->w_topfill = 0; - } } } } --- 2002,2023 ---- { int n; ! if (wp->w_topfill <= 0) ! return; ! ! n = plines_win_nofill(wp, wp->w_topline, TRUE); ! if (wp->w_topfill + n > wp->w_height) { ! if (down && wp->w_topline > 1) { ! --wp->w_topline; ! wp->w_topfill = 0; ! } ! else ! { ! wp->w_topfill = wp->w_height - n; ! if (wp->w_topfill < 0) wp->w_topfill = 0; } } } *** ../vim-9.0.1195/src/version.c 2023-01-14 11:46:09.708717819 +0000 --- src/version.c 2023-01-14 12:28:37.132056455 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1196, /**/ -- hundred-and-one symptoms of being an internet addict: 8. You spend half of the plane trip with your laptop on your lap...and your child in the overhead compartment. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///