# HG changeset patch # User Bram Moolenaar # Date 1661436903 -7200 # Node ID 6c7eddcce52c183f3d2715c90a4b272397ff12f9 # Parent cd89b592bcc957a7ec0075fcde8ac8f7397dcbe4 patch 9.0.0263: too many #ifdefs Commit: https://github.com/vim/vim/commit/6d4b2f54df5d533eb0794331f38445a6ca5d3a3f Author: Bram Moolenaar Date: Thu Aug 25 15:11:15 2022 +0100 patch 9.0.0263: too many #ifdefs Problem: Too many #ifdefs. Solution: Make some functions always available. diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -222,9 +222,7 @@ open_buffer( // Read the file if there is one. if (curbuf->b_ffname != NULL -#ifdef FEAT_QUICKFIX && !bt_quickfix(curbuf) -#endif && !bt_nofilename(curbuf) #ifdef FEAT_NETBEANS_INTG && netbeansReadFile @@ -1328,11 +1326,7 @@ do_buffer_ext( return FAIL; } #ifdef FEAT_PROP_POPUP - if ((flags & DOBUF_NOPOPUP) && bt_popup(buf) -# ifdef FEAT_TERMINAL - && !bt_terminal(buf) -#endif - ) + if ((flags & DOBUF_NOPOPUP) && bt_popup(buf) && !bt_terminal(buf)) return OK; #endif @@ -1445,11 +1439,7 @@ do_buffer_ext( { // Skip current and unlisted bufs. Also skip a quickfix // buffer, it might be deleted soon. - if (buf == curbuf || !buf->b_p_bl -#if defined(FEAT_QUICKFIX) - || bt_quickfix(buf) -#endif - ) + if (buf == curbuf || !buf->b_p_bl || bt_quickfix(buf)) buf = NULL; else if (buf->b_ml.ml_mfp == NULL) { @@ -1487,10 +1477,7 @@ do_buffer_ext( } // in non-help buffer, try to skip help buffers, and vv if (buf->b_help == curbuf->b_help && buf->b_p_bl -#if defined(FEAT_QUICKFIX) - && !bt_quickfix(buf) -#endif - ) + && !bt_quickfix(buf)) { if (buf->b_ml.ml_mfp != NULL) // found loaded buffer break; @@ -1508,11 +1495,7 @@ do_buffer_ext( if (buf == NULL) // No loaded buffer, find listed one { FOR_ALL_BUFFERS(buf) - if (buf->b_p_bl && buf != curbuf -#if defined(FEAT_QUICKFIX) - && !bt_quickfix(buf) -#endif - ) + if (buf->b_p_bl && buf != curbuf && !bt_quickfix(buf)) break; } if (buf == NULL) // Still no buffer, just take one @@ -1521,10 +1504,8 @@ do_buffer_ext( buf = curbuf->b_next; else buf = curbuf->b_prev; -#if defined(FEAT_QUICKFIX) if (bt_quickfix(buf)) buf = NULL; -#endif } } @@ -1987,9 +1968,7 @@ curbuf_reusable(void) && curbuf->b_ffname == NULL && curbuf->b_nwindows <= 1 && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()) -#if defined(FEAT_QUICKFIX) && !bt_quickfix(curbuf) -#endif && !curbufIsChanged()); } @@ -3787,15 +3766,9 @@ fileinfo( vim_snprintf_add(buffer, IOSIZE, "\"%s%s%s%s%s%s", curbufIsChanged() ? (shortmess(SHM_MOD) ? " [+]" : _(" [Modified]")) : " ", - (curbuf->b_flags & BF_NOTEDITED) -#ifdef FEAT_QUICKFIX - && !bt_dontwrite(curbuf) -#endif + (curbuf->b_flags & BF_NOTEDITED) && !bt_dontwrite(curbuf) ? _("[Not edited]") : "", - (curbuf->b_flags & BF_NEW) -#ifdef FEAT_QUICKFIX - && !bt_dontwrite(curbuf) -#endif + (curbuf->b_flags & BF_NEW) && !bt_dontwrite(curbuf) ? new_file_message() : "", (curbuf->b_flags & BF_READERR) ? _("[Read errors]") : "", curbuf->b_p_ro ? (shortmess(SHM_RO) ? _("[RO]") @@ -5676,27 +5649,31 @@ bt_normal(buf_T *buf) return buf != NULL && buf->b_p_bt[0] == NUL; } -#if defined(FEAT_QUICKFIX) || defined(PROTO) /* * Return TRUE if "buf" is the quickfix buffer. */ int bt_quickfix(buf_T *buf) { +#ifdef FEAT_QUICKFIX return buf != NULL && buf->b_p_bt[0] == 'q'; +#else + return FALSE; +#endif } -#endif - -#if defined(FEAT_TERMINAL) || defined(PROTO) + /* * Return TRUE if "buf" is a terminal buffer. */ int bt_terminal(buf_T *buf) { +#if defined(FEAT_TERMINAL) return buf != NULL && buf->b_p_bt[0] == 't'; +#else + return FALSE; +#endif } -#endif /* * Return TRUE if "buf" is a help buffer. @@ -5764,7 +5741,6 @@ bt_dontwrite(buf_T *buf) || buf->b_p_bt[0] == 'p'); } -#if defined(FEAT_QUICKFIX) || defined(PROTO) int bt_dontwrite_msg(buf_T *buf) { @@ -5775,7 +5751,6 @@ bt_dontwrite_msg(buf_T *buf) } return FALSE; } -#endif /* * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide" diff --git a/src/bufwrite.c b/src/bufwrite.c --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -742,9 +742,7 @@ buf_write( && reset_changed && whole && buf == curbuf -#ifdef FEAT_QUICKFIX && !bt_nofilename(buf) -#endif && !filtering && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL) && vim_strchr(p_cpo, CPO_FNAMEW) != NULL) @@ -813,11 +811,9 @@ buf_write( if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEAPPENDCMD, sfname, sfname, FALSE, curbuf, eap))) { -#ifdef FEAT_QUICKFIX if (overwriting && bt_nofilename(curbuf)) nofile_err = TRUE; else -#endif apply_autocmds_exarg(EVENT_FILEAPPENDPRE, sfname, sfname, FALSE, curbuf, eap); } @@ -846,11 +842,9 @@ buf_write( } else { -#ifdef FEAT_QUICKFIX if (overwriting && bt_nofilename(curbuf)) nofile_err = TRUE; else -#endif apply_autocmds_exarg(EVENT_BUFWRITEPRE, sfname, sfname, FALSE, curbuf, eap); } @@ -860,11 +854,9 @@ buf_write( if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEWRITECMD, sfname, sfname, FALSE, curbuf, eap))) { -#ifdef FEAT_QUICKFIX if (overwriting && bt_nofilename(curbuf)) nofile_err = TRUE; else -#endif apply_autocmds_exarg(EVENT_FILEWRITEPRE, sfname, sfname, FALSE, curbuf, eap); } diff --git a/src/change.c b/src/change.c --- a/src/change.c +++ b/src/change.c @@ -100,11 +100,7 @@ changed(void) // Create a swap file if that is wanted. // Don't do this for "nofile" and "nowrite" buffer types. - if (curbuf->b_may_swap -#ifdef FEAT_QUICKFIX - && !bt_dontwrite(curbuf) -#endif - ) + if (curbuf->b_may_swap && !bt_dontwrite(curbuf)) { int save_need_wait_return = need_wait_return; diff --git a/src/drawscreen.c b/src/drawscreen.c --- a/src/drawscreen.c +++ b/src/drawscreen.c @@ -482,11 +482,7 @@ win_redr_status(win_T *wp, int ignore_pu len += (int)STRLEN(p + len); } #endif - if (bufIsChanged(wp->w_buffer) -#ifdef FEAT_TERMINAL - && !bt_terminal(wp->w_buffer) -#endif - ) + if (bufIsChanged(wp->w_buffer) && !bt_terminal(wp->w_buffer)) { vim_snprintf((char *)p + len, MAXPATHL - len, "%s", "[+]"); len += (int)STRLEN(p + len); diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -954,9 +954,9 @@ EXTERN char e_at_bottom_of_quickfix_stac INIT(= N_("E380: At bottom of quickfix stack")); EXTERN char e_at_top_of_quickfix_stack[] INIT(= N_("E381: At top of quickfix stack")); +#endif EXTERN char e_cannot_write_buftype_option_is_set[] INIT(= N_("E382: Cannot write, 'buftype' option is set")); -#endif EXTERN char e_invalid_search_string_str[] INIT(= N_("E383: Invalid search string: %s")); EXTERN char e_search_hit_top_without_match_for_str[] diff --git a/src/evalbuffer.c b/src/evalbuffer.c --- a/src/evalbuffer.c +++ b/src/evalbuffer.c @@ -93,11 +93,7 @@ find_buffer(typval_T *avar) // buffer, these don't use the full path. FOR_ALL_BUFFERS(buf) if (buf->b_fname != NULL - && (path_with_url(buf->b_fname) -#ifdef FEAT_QUICKFIX - || bt_nofilename(buf) -#endif - ) + && (path_with_url(buf->b_fname) || bt_nofilename(buf)) && STRCMP(buf->b_fname, avar->vval.v_string) == 0) break; } diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1677,12 +1677,7 @@ append_redir( (char *)opt, (char *)fname); } else - vim_snprintf((char *)end, (size_t)(buflen - (end - buf)), -#ifdef FEAT_QUICKFIX - " %s %s", -#else - " %s%s", // " > %s" causes problems on Amiga -#endif + vim_snprintf((char *)end, (size_t)(buflen - (end - buf)), " %s %s", (char *)opt, (char *)fname); } @@ -1947,11 +1942,7 @@ do_write(exarg_T *eap) * and a file name is required. * "nofile" and "nowrite" buffers cannot be written implicitly either. */ - if (!other && ( -#ifdef FEAT_QUICKFIX - bt_dontwrite_msg(curbuf) || -#endif - check_fname() == FAIL + if (!other && (bt_dontwrite_msg(curbuf) || check_fname() == FAIL #ifdef UNIX || check_writable(curbuf->b_ffname) == FAIL #endif diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -27,10 +27,8 @@ autowrite(buf_T *buf, int forceit) bufref_T bufref; if (!(p_aw || p_awa) || !p_write -#ifdef FEAT_QUICKFIX // never autowrite a "nofile" or "nowrite" buffer || bt_dontwrite(buf) -#endif || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) return FAIL; set_bufref(&bufref, buf); diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -55,8 +55,6 @@ static int getargopt(exarg_T *eap); # define qf_history ex_ni # define ex_helpgrep ex_ni # define ex_vimgrep ex_ni -#endif -#if !defined(FEAT_QUICKFIX) # define ex_cclose ex_ni # define ex_copen ex_ni # define ex_cwindow ex_ni diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -514,9 +514,7 @@ readfile( // Create a swap file now, so that other Vims are warned // that we are editing this file. Don't do this for a // "nofile" or "nowrite" buffer type. -#ifdef FEAT_QUICKFIX if (!bt_dontwrite(curbuf)) -#endif { check_need_swap(newfile); // SwapExists autocommand may mess things up @@ -595,9 +593,7 @@ readfile( // Create a swap file now, so that other Vims are warned that we are // editing this file. // Don't do this for a "nofile" or "nowrite" buffer type. -#ifdef FEAT_QUICKFIX if (!bt_dontwrite(curbuf)) -#endif { check_need_swap(newfile); if (!read_stdin && (curbuf != old_curbuf @@ -3407,9 +3403,7 @@ shorten_buf_fname(buf_T *buf, char_u *di char_u *p; if (buf->b_fname != NULL -#ifdef FEAT_QUICKFIX && !bt_nofilename(buf) -#endif && !path_with_url(buf->b_fname) && (force || buf->b_sfname == NULL diff --git a/src/netbeans.c b/src/netbeans.c --- a/src/netbeans.c +++ b/src/netbeans.c @@ -2152,10 +2152,7 @@ nb_do_cmd( if (p_write && !buf->bufp->b_p_ro && buf->bufp->b_ffname != NULL -#ifdef FEAT_QUICKFIX - && !bt_dontwrite(buf->bufp) -#endif - ) + && !bt_dontwrite(buf->bufp)) { bufref_T bufref; diff --git a/src/session.c b/src/session.c --- a/src/session.c +++ b/src/session.c @@ -148,11 +148,8 @@ ses_do_win(win_T *wp) && term_should_restore(wp->w_buffer); #endif if (wp->w_buffer->b_fname == NULL -#ifdef FEAT_QUICKFIX // When 'buftype' is "nofile" can't restore the window contents. - || bt_nofilename(wp->w_buffer) -#endif - ) + || bt_nofilename(wp->w_buffer)) return (ssop_flags & SSOP_BLANK); if (bt_help(wp->w_buffer)) return (ssop_flags & SSOP_HELP); @@ -374,10 +371,7 @@ put_view( # endif // Load the file. else if (wp->w_buffer->b_ffname != NULL -# ifdef FEAT_QUICKFIX - && !bt_nofilename(wp->w_buffer) -# endif - ) + && !bt_nofilename(wp->w_buffer)) { // Editing a file in this buffer: use ":edit file". // This may have side effects! (e.g., compressed or network file). @@ -708,11 +702,9 @@ makeopens( { if (!(only_save_windows && buf->b_nwindows == 0) && !(buf->b_help && !(ssop_flags & SSOP_HELP)) -#ifdef FEAT_TERMINAL // Skip terminal buffers: finished ones are not useful, others // will be resurrected and result in a new buffer. && !bt_terminal(buf) -#endif && buf->b_fname != NULL && buf->b_p_bl) { @@ -818,10 +810,7 @@ makeopens( if (ses_do_win(wp) && wp->w_buffer->b_ffname != NULL && !bt_help(wp->w_buffer) -#ifdef FEAT_QUICKFIX - && !bt_nofilename(wp->w_buffer) -#endif - ) + && !bt_nofilename(wp->w_buffer)) { if (need_tabnext && put_line(fd, "tabnext") == FAIL) goto fail; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -732,6 +732,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 263, +/**/ 262, /**/ 261, diff --git a/src/viminfo.c b/src/viminfo.c --- a/src/viminfo.c +++ b/src/viminfo.c @@ -434,12 +434,8 @@ write_viminfo_bufferlist(FILE *fp) { if (buf->b_fname == NULL || !buf->b_p_bl -#ifdef FEAT_QUICKFIX || bt_quickfix(buf) -#endif -#ifdef FEAT_TERMINAL || bt_terminal(buf) -#endif || removable(buf->b_ffname)) continue; @@ -1994,11 +1990,7 @@ write_buffer_marks(buf_T *buf, FILE *fp_ static int skip_for_viminfo(buf_T *buf) { - return -#ifdef FEAT_TERMINAL - bt_terminal(buf) || -#endif - removable(buf->b_ffname); + return bt_terminal(buf) || removable(buf->b_ffname); } /* diff --git a/src/window.c b/src/window.c --- a/src/window.c +++ b/src/window.c @@ -172,12 +172,10 @@ do_window( case 's': CHECK_CMDWIN; reset_VIsual_and_resel(); // stop Visual mode -#ifdef FEAT_QUICKFIX // When splitting the quickfix window open a new buffer in it, // don't replicate the quickfix buffer. if (bt_quickfix(curbuf)) goto newwindow; -#endif #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif @@ -189,12 +187,10 @@ do_window( case 'v': CHECK_CMDWIN; reset_VIsual_and_resel(); // stop Visual mode -#ifdef FEAT_QUICKFIX // When splitting the quickfix window open a new buffer in it, // don't replicate the quickfix buffer. if (bt_quickfix(curbuf)) goto newwindow; -#endif #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif @@ -228,9 +224,7 @@ do_window( case 'n': CHECK_CMDWIN; reset_VIsual_and_resel(); // stop Visual mode -#ifdef FEAT_QUICKFIX newwindow: -#endif if (Prenum) // window height vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum);