diff options
41 files changed, 398 insertions, 361 deletions
diff --git a/.ci/coverity.sh b/.ci/coverity.sh deleted file mode 100644 index 0edaf2e088..0000000000 --- a/.ci/coverity.sh +++ /dev/null @@ -1,16 +0,0 @@ -. "$CI_SCRIPTS/common.sh" - -# temporarily disable error checking, the coverity script exits with -# status code 1 whenever it (1) fails OR (2) is not on the correct -# branch. -set +e -curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | -COVERITY_SCAN_PROJECT_NAME="neovim/neovim" \ - COVERITY_SCAN_NOTIFICATION_EMAIL="coverity@aktau.be" \ - COVERITY_SCAN_BRANCH_PATTERN="coverity-scan" \ - COVERITY_SCAN_BUILD_COMMAND_PREPEND="$MAKE_CMD deps" \ - COVERITY_SCAN_BUILD_COMMAND="$MAKE_CMD nvim" \ - bash -set -e - -exit 0 diff --git a/.travis.yml b/.travis.yml index 94affe7bd6..a82246986d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,11 @@ env: global: - PROJECT_ROOT="$(pwd)" - CI_SCRIPTS="$PROJECT_ROOT/.ci" - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "QEz92NyItkzQu52kCFD928jEwUYnA2OIgSyeNrp+Y3gm5rOmSZerY8hGiXyNZxocap9+qIPCapRRYU3ZYKWZPeucWMLN3aIjxAFdhugKbnmNYE1jFugb6b8N3SxiX/3206NHXlYaz0OZhh6OBAFmPUXamJC8OrWVgPNPo7wv4UQ=" matrix: - CI_TARGET=clang-asan - CI_TARGET=gcc - CI_TARGET=gcc-32 - CI_TARGET=clint - - CI_TARGET=coverity before_install: # Adds user to a dummy group. # That allows to test changing the group of the file by `os_fchown`. @@ -9,7 +9,7 @@ [Bountysource](https://www.bountysource.com/teams/neovim) [](https://travis-ci.org/neovim/neovim) -[](https://waffle.io/neovim/neovim) +[](https://waffle.io/neovim/neovim) [](https://coveralls.io/r/neovim/neovim) [](https://scan.coverity.com/projects/2227) [](http://neovim.org/doc/reports/clang) @@ -32,6 +32,8 @@ For lots more details, see - Performance, reliability, and portability improvements - See the [progress page](https://github.com/neovim/neovim/wiki/Progress) for a comprehensive list. +[](https://waffle.io/neovim/neovim/metrics) + ### What's being worked on now - Port all IO to [libuv](https://github.com/joyent/libuv/blob/master/README.md) diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 800ab08ce3..3d8ae276ce 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -50,7 +50,7 @@ metadata from a compiled nvim instance. There are two ways to obtain API metadata: -1. By connecting to a running nvim instance and calling `vim_get_api_metadata` +1. By connecting to a running nvim instance and calling `vim_get_api_info` via msgpack-rpc. This is the preferred way for clients written in dynamically-typed languages, which can define functions at runtime. @@ -179,7 +179,7 @@ Tabpage -> enum value kObjectTypeTabpage The most reliable way of determining the type codes for the special nvim types is at runtime by inspecting the `types` key of metadata dictionary returned by -`vim_get_api_metadata` method. Here's an example json representation of the +`vim_get_api_info` method. Here's an example json representation of the `types` object: > "types": { diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 7880c66e1e..7d50aae7ab 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -96,7 +96,6 @@ // i -> initial // m -> medial // f -> final -// #define a_s_FATHATAN 0xfe70 #define a_m_TATWEEL_FATHATAN 0xfe71 #define a_s_DAMMATAN 0xfe72 @@ -246,7 +245,8 @@ #ifdef INCLUDE_GENERATED_DECLARATIONS # include "arabic.c.generated.h" #endif -// Returns True if c is an ISO-8859-6 shaped ARABIC letter (user entered). + +// Returns true if c is an ISO-8859-6 shaped ARABIC letter (user entered). static bool A_is_a(int cur_c) { switch (cur_c) { @@ -293,7 +293,7 @@ static bool A_is_a(int cur_c) return false; } -// Returns True if c is an Isolated Form-B ARABIC letter +// Returns true if c is an Isolated Form-B ARABIC letter static bool A_is_s(int cur_c) { switch (cur_c) { @@ -339,7 +339,7 @@ static bool A_is_s(int cur_c) return false; } -// Returns True if c is a Final shape of an ARABIC letter +// Returns true if c is a Final shape of an ARABIC letter static bool A_is_f(int cur_c) { switch (cur_c) { @@ -1259,12 +1259,11 @@ static int chg_c_f2m(int cur_c) tempc = a_m_YEH; break; - /* NOTE: these encodings are multi-positional, no ? - case a_f_LAM_ALEF_MADDA_ABOVE: - case a_f_LAM_ALEF_HAMZA_ABOVE: - case a_f_LAM_ALEF_HAMZA_BELOW: - case a_f_LAM_ALEF: - */ + // NOTE: these encodings are multi-positional, no ? + // case a_f_LAM_ALEF_MADDA_ABOVE: + // case a_f_LAM_ALEF_HAMZA_ABOVE: + // case a_f_LAM_ALEF_HAMZA_BELOW: + // case a_f_LAM_ALEF: default: tempc = 0; } @@ -1272,9 +1271,7 @@ static int chg_c_f2m(int cur_c) return tempc; } -/* - * Change shape - from Combination (2 char) to an Isolated - */ +// Change shape - from Combination (2 char) to an Isolated. static int chg_c_laa2i(int hid_c) { int tempc; @@ -1303,9 +1300,7 @@ static int chg_c_laa2i(int hid_c) return tempc; } -/* - * Change shape - from Combination-Isolated to Final - */ +// Change shape - from Combination-Isolated to Final. static int chg_c_laa2f(int hid_c) { int tempc; @@ -1334,9 +1329,7 @@ static int chg_c_laa2f(int hid_c) return tempc; } -/* - * Do "half-shaping" on character "c". Return zero if no shaping. - */ +// Do "half-shaping" on character "c". Return zero if no shaping. static int half_shape(int c) { if (A_is_a(c)) { @@ -1349,27 +1342,25 @@ static int half_shape(int c) return 0; } -/* - * Do Arabic shaping on character "c". Returns the shaped character. - * out: "ccp" points to the first byte of the character to be shaped. - * in/out: "c1p" points to the first composing char for "c". - * in: "prev_c" is the previous character (not shaped) - * in: "prev_c1" is the first composing char for the previous char - * (not shaped) - * in: "next_c" is the next character (not shaped). - */ +// Do Arabic shaping on character "c". Returns the shaped character. +// out: "ccp" points to the first byte of the character to be shaped. +// in/out: "c1p" points to the first composing char for "c". +// in: "prev_c" is the previous character (not shaped) +// in: "prev_c1" is the first composing char for the previous char +// (not shaped) +// in: "next_c" is the next character (not shaped). int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c) { - /* Deal only with Arabic character, pass back all others */ + // Deal only with Arabic character, pass back all others if (!A_is_ok(c)) { return c; } - /* half-shape current and previous character */ + // half-shape current and previous character int shape_c = half_shape(prev_c); - /* Save away current character */ + // Save away current character int curr_c = c; int curr_laa = A_firstc_laa(c, *c1p); @@ -1383,7 +1374,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, curr_c = chg_c_laa2i(curr_laa); } - /* Remove the composing character */ + // Remove the composing character *c1p = 0; } else if (!A_is_valid(prev_c) && A_is_valid(next_c)) { curr_c = chg_c_a2i(c); @@ -1397,8 +1388,8 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, curr_c = chg_c_a2s(c); } - /* Sanity check -- curr_c should, in the future, never be 0. - * We should, in the future, insert a fatal error here. */ + // Sanity check -- curr_c should, in the future, never be 0. + // We should, in the future, insert a fatal error here. if (curr_c == NUL) { curr_c = c; } @@ -1406,12 +1397,12 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, if ((curr_c != c) && (ccp != NULL)) { char_u buf[MB_MAXBYTES + 1]; - /* Update the first byte of the character. */ + // Update the first byte of the character (*mb_char2bytes)(curr_c, buf); *ccp = buf[0]; } - /* Return the shaped character */ + // Return the shaped character return curr_c; } @@ -1441,11 +1432,9 @@ bool arabic_maycombine(int two) return false; } -/* - * A_firstc_laa returns first character of LAA combination if it exists - * in: "c" base character - * in: "c1" first composing character - */ +// A_firstc_laa returns first character of LAA combination if it ex.ists +// in: "c" base character +// in: "c1" first composing character static int A_firstc_laa(int c, int c1) { if ((c1 != NUL) && (c == a_LAM) && !A_is_harakat(c1)) { @@ -1454,19 +1443,15 @@ static int A_firstc_laa(int c, int c1) return 0; } -/* - * A_is_harakat returns TRUE if 'c' is an Arabic Harakat character - * (harakat/tanween) - */ +// A_is_harakat returns true if 'c' is an Arabic Harakat character. +// (harakat/tanween) static bool A_is_harakat(int c) { return c >= a_FATHATAN && c <= a_SUKUN; } -/* - * A_is_iso returns TRUE if 'c' is an Arabic ISO-8859-6 character - * (alphabet/number/punctuation) - */ +// A_is_iso returns true if 'c' is an Arabic ISO-8859-6 character. +// (alphabet/number/punctuation) static bool A_is_iso(int c) { return (c >= a_HAMZA && c <= a_GHAIN) || @@ -1474,10 +1459,8 @@ static bool A_is_iso(int c) c == a_MINI_ALEF; } -/* - * A_is_formb returns TRUE if 'c' is an Arabic 10646-1 FormB character - * (alphabet/number/punctuation) - */ +// A_is_formb returns true if 'c' is an Arabic 10646-1 FormB character. +// (alphabet/number/punctuation) static bool A_is_formb(int c) { return (c >= a_s_FATHATAN && c <= a_s_DAMMATAN) || @@ -1486,27 +1469,21 @@ static bool A_is_formb(int c) c == a_BYTE_ORDER_MARK; } -/* - * A_is_ok returns TRUE if 'c' is an Arabic 10646 (8859-6 or Form-B) - */ +// A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B). static bool A_is_ok(int c) { return A_is_iso(c) || A_is_formb(c); } -/* - * A_is_valid returns TRUE if 'c' is an Arabic 10646 (8859-6 or Form-B) - * with some exceptions/exclusions - */ +// A_is_valid returns true if 'c' is an Arabic 10646 (8859-6 or Form-B), +// with some exceptions/exclusions. static bool A_is_valid(int c) { return A_is_ok(c) && !A_is_special(c); } -/* - * A_is_special returns TRUE if 'c' is not a special Arabic character. - * Specials don't adhere to most of the rules. - */ +// A_is_special returns true if 'c' is not a special Arabic character. +// Specials don't adhere to most of the rules. static bool A_is_special(int c) { return c == a_HAMZA || c == a_s_HAMZA; diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index b76bad67f6..6b5b97fe67 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -332,7 +332,7 @@ close_buffer ( /* When the buffer is no longer in a window, trigger BufWinLeave */ if (buf->b_nwindows == 1) { - buf->b_closing = TRUE; + buf->b_closing = true; apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, FALSE, buf); if (!buf_valid(buf)) { @@ -340,7 +340,7 @@ close_buffer ( EMSG(_(e_auabort)); return; } - buf->b_closing = FALSE; + buf->b_closing = false; if (abort_if_last && one_window()) { /* Autocommands made this the only window. */ EMSG(_(e_auabort)); @@ -350,7 +350,7 @@ close_buffer ( /* When the buffer becomes hidden, but is not unloaded, trigger * BufHidden */ if (!unload_buf) { - buf->b_closing = TRUE; + buf->b_closing = true; apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, FALSE, buf); if (!buf_valid(buf)) { @@ -358,7 +358,7 @@ close_buffer ( EMSG(_(e_auabort)); return; } - buf->b_closing = FALSE; + buf->b_closing = false; if (abort_if_last && one_window()) { /* Autocommands made this the only window. */ EMSG(_(e_auabort)); @@ -447,7 +447,7 @@ close_buffer ( buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED; /* Init the options when loaded again. */ - buf->b_p_initialized = FALSE; + buf->b_p_initialized = false; } buf_clear_file(buf); if (del_buf) @@ -481,7 +481,7 @@ void buf_freeall(buf_T *buf, int flags) { bool is_curbuf = (buf == curbuf); - buf->b_closing = TRUE; + buf->b_closing = true; apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf); if (!buf_valid(buf)) /* autocommands may delete the buffer */ return; @@ -496,7 +496,7 @@ void buf_freeall(buf_T *buf, int flags) if (!buf_valid(buf)) /* autocommands may delete the buffer */ return; } - buf->b_closing = FALSE; + buf->b_closing = false; if (aborting()) /* autocmds may abort script processing */ return; @@ -1398,7 +1398,7 @@ buflist_new ( free_buffer_stuff(buf, FALSE); /* delete local variables et al. */ /* Init the options. */ - buf->b_p_initialized = FALSE; + buf->b_p_initialized = false; buf_copy_options(buf, BCO_ENTER); /* need to reload lmaps and set b:keymap_name */ @@ -1446,7 +1446,7 @@ buflist_new ( buf->file_id_valid = true; buf->file_id = file_id; } - buf->b_u_synced = TRUE; + buf->b_u_synced = true; buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED; if (flags & BLN_DUMMY) buf->b_flags |= BF_DUMMY; @@ -2004,7 +2004,7 @@ static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, copy_winopt(&win->w_onebuf_opt, &wip->wi_opt); wip->wi_fold_manual = win->w_fold_manual; cloneFoldGrowArray(&win->w_folds, &wip->wi_folds); - wip->wi_optset = TRUE; + wip->wi_optset = true; } /* insert the entry in front of the list */ @@ -2084,7 +2084,7 @@ void get_winopts(buf_T *buf) if (wip != NULL && wip->wi_optset) { copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt); curwin->w_fold_manual = wip->wi_fold_manual; - curwin->w_foldinvalid = TRUE; + curwin->w_foldinvalid = true; cloneFoldGrowArray(&wip->wi_folds, &curwin->w_folds); } else copy_winopt(&curwin->w_allbuf_opt, &curwin->w_onebuf_opt); diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 094d6dfd05..196b975d2a 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -243,9 +243,9 @@ struct wininfo_S { wininfo_T *wi_prev; /* previous entry or NULL for first entry */ win_T *wi_win; /* pointer to window that did set wi_fpos */ pos_T wi_fpos; /* last cursor position in the file */ - int wi_optset; /* TRUE when wi_opt has useful values */ + bool wi_optset; /* true when wi_opt has useful values */ winopt_T wi_opt; /* local window options */ - int wi_fold_manual; /* copy of w_fold_manual */ + bool wi_fold_manual; /* copy of w_fold_manual */ garray_T wi_folds; /* clone of w_folds */ }; @@ -464,7 +464,7 @@ struct file_buffer { int b_nwindows; /* nr of windows open on this buffer */ int b_flags; /* various BF_ flags */ - int b_closing; /* buffer is being closed, don't let + bool b_closing; /* buffer is being closed, don't let autocommands close it too. */ /* @@ -482,18 +482,18 @@ struct file_buffer { int b_fnum; /* buffer number for this file. */ - int b_changed; /* 'modified': Set to TRUE if something in the + bool b_changed; /* 'modified': Set to true if something in the file has been changed and not written out. */ int b_changedtick; /* incremented for each change, also for undo */ - int b_saving; /* Set to TRUE if we are in the middle of + bool b_saving; /* Set to true if we are in the middle of saving the buffer. */ /* * Changes to a buffer require updating of the display. To minimize the * work, remember changes made and update everything at once. */ - int b_mod_set; /* TRUE when there are changes since the last + bool b_mod_set; /* true when there are changes since the last time the display was updated */ linenr_T b_mod_top; /* topmost lnum that was changed */ linenr_T b_mod_bot; /* lnum below last changed line, AFTER the @@ -524,7 +524,7 @@ struct file_buffer { */ pos_T b_changelist[JUMPLISTSIZE]; int b_changelistlen; /* number of active entries */ - int b_new_change; /* set by u_savecommon() */ + bool b_new_change; /* set by u_savecommon() */ /* * Character table, only used in charset.c for 'iskeyword' @@ -546,7 +546,7 @@ struct file_buffer { pos_T b_op_start_orig; // used for Insstart_orig pos_T b_op_end; - int b_marks_read; /* Have we read viminfo marks yet? */ + bool b_marks_read; /* Have we read viminfo marks yet? */ /* * The following only used in undo.c. @@ -556,7 +556,7 @@ struct file_buffer { if b_u_curhead is not NULL */ u_header_T *b_u_curhead; /* pointer to current header */ int b_u_numhead; /* current number of headers */ - int b_u_synced; /* entry lists are synced */ + bool b_u_synced; /* entry lists are synced */ long b_u_seq_last; /* last used undo sequence number */ long b_u_save_nr_last; /* counter for last file write */ long b_u_seq_cur; /* hu_seq of header below which we are now */ @@ -570,7 +570,7 @@ struct file_buffer { linenr_T b_u_line_lnum; /* line number of line in u_line */ colnr_T b_u_line_colnr; /* optional column number */ - int b_scanned; /* ^N/^P have scanned this buffer */ + bool b_scanned; /* ^N/^P have scanned this buffer */ /* flags for use of ":lmap" and IM control */ long b_p_iminsert; /* input mode for insert */ @@ -595,7 +595,7 @@ struct file_buffer { * They are here because their value depends on the type of file * or contents of the file being edited. */ - int b_p_initialized; /* set when options initialized */ + bool b_p_initialized; /* set when options initialized */ int b_p_scriptID[BV_COUNT]; /* SIDs for buffer-local options */ @@ -731,8 +731,8 @@ struct file_buffer { * then set to indicate that a swap file may be opened later. It is reset * if a swap file could not be opened. */ - int b_may_swap; - int b_did_warn; /* Set to 1 if user has been warned on first + bool b_may_swap; + bool b_did_warn; /* Set to true if user has been warned on first change of a read-only file */ /* Two special kinds of buffers: @@ -740,7 +740,7 @@ struct file_buffer { * spell buffer - used for spell info, never displayed and doesn't have a * file name. */ - int b_help; /* TRUE for help file buffer (when set b_p_bt + bool b_help; /* TRUE for help file buffer (when set b_p_bt is "help") */ bool b_spell; /* True for a spell file buffer, most fields are not used! Use the B_SPELL macro to @@ -925,7 +925,7 @@ struct window_S { win_T *w_prev; /* link to previous window */ win_T *w_next; /* link to next window */ - int w_closing; /* window is being closed, don't let + bool w_closing; /* window is being closed, don't let autocommands close it too. */ frame_T *w_frame; /* frame containing this window */ @@ -961,9 +961,9 @@ struct window_S { e.g. by winrestview() */ int w_topfill; /* number of filler lines above w_topline */ int w_old_topfill; /* w_topfill at last redraw */ - int w_botfill; /* TRUE when filler lines are actually + bool w_botfill; /* true when filler lines are actually below w_topline (at end of file) */ - int w_old_botfill; /* w_botfill at last redraw */ + bool w_old_botfill; /* w_botfill at last redraw */ colnr_T w_leftcol; /* window column number of the left most character in the window; used when 'wrap' is off */ @@ -1039,9 +1039,9 @@ struct window_S { wline_T *w_lines; garray_T w_folds; /* array of nested folds */ - char w_fold_manual; /* when TRUE: some folds are opened/closed + bool w_fold_manual; /* when true: some folds are opened/closed manually */ - char w_foldinvalid; /* when TRUE: folding needs to be + bool w_foldinvalid; /* when true: folding needs to be recomputed */ int w_nrwidth; /* width of 'number' and 'relativenumber' column being used */ diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 57c4aec395..f3bb3d8c73 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -978,7 +978,6 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he int mb_added = 0; int numberextra; char_u *ps; - int tab_corr = (*s == TAB); int n; // No 'linebreak', 'showbreak' and 'breakindent': return quickly. @@ -992,7 +991,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he // First get normal size, without 'linebreak' int size = win_chartabsize(wp, s, col); int c = *s; - if (tab_corr) { + if (*s == TAB) { col_adj = size - 1; } @@ -1034,7 +1033,6 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he if (col2 >= colmax) { /* doesn't fit */ size = colmax - col + col_adj; - tab_corr = FALSE; break; } } @@ -1072,12 +1070,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he if (wp->w_p_bri) added += get_breakindent_win(wp, line); - if (tab_corr) { - size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts; - } else { - size += added; - } - + size += added; if (col != 0) { added = 0; } diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 39db77bd82..18e30f8587 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1745,11 +1745,11 @@ void diff_set_topline(win_T *fromwin, win_T *towin) } // safety check (if diff info gets outdated strange things may happen) - towin->w_botfill = FALSE; + towin->w_botfill = false; if (towin->w_topline > towin->w_buffer->b_ml.ml_line_count) { towin->w_topline = towin->w_buffer->b_ml.ml_line_count; - towin->w_botfill = TRUE; + towin->w_botfill = true; } if (towin->w_topline < 1) { diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 384ca9abd8..d7910347fc 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -235,7 +235,7 @@ static int did_add_space = FALSE; /* auto_format() added an extra space * * Return TRUE if a CTRL-O command caused the return (insert mode pending). */ -int +int edit ( int cmdchar, int startln, /* if set, insert at start of line */ @@ -1224,7 +1224,7 @@ force_cindent: * Only redraw when there are no characters available. This speeds up * inserting sequences of characters (e.g., for CTRL-R). */ -static void +static void ins_redraw ( int ready /* not busy with something */ ) @@ -1440,7 +1440,7 @@ static void undisplay_dollar(void) * type == INDENT_SET set indent to "amount" * if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec). */ -void +void change_indent ( int type, int amount, @@ -1986,7 +1986,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int * NOTDONE, otherwise add it to the list and return OK. If there is an error * then FAIL is returned. */ -static int +static int ins_compl_add ( char_u *str, int len, @@ -2450,7 +2450,7 @@ void ins_compl_show_pum(void) * Add any identifiers that match the given pattern in the list of dictionary * files "dict_start" to the list of completions. */ -static void +static void ins_compl_dictionaries ( char_u *dict_start, char_u *pat, @@ -3255,7 +3255,7 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag) * Execute user defined complete function 'completefunc' or 'omnifunc', and * get matches in "matches". */ -static void +static void expand_by_function ( int type, /* CTRL_X_OMNI or CTRL_X_FUNCTION */ char_u *base @@ -3438,7 +3438,7 @@ static int ins_compl_get_exp(pos_T *ini) if (!compl_started) { FOR_ALL_BUFFERS(buf) { - buf->b_scanned = 0; + buf->b_scanned = false; } found_all = FALSE; ins_buf = curbuf; @@ -3764,7 +3764,7 @@ static int ins_compl_get_exp(pos_T *ini) /* Mark a buffer scanned when it has been scanned completely */ if (type == 0 || type == CTRL_X_PATH_PATTERNS) { assert(ins_buf); - ins_buf->b_scanned = TRUE; + ins_buf->b_scanned = true; } compl_started = FALSE; @@ -3833,7 +3833,7 @@ static void ins_compl_insert(void) * "allow_get_expansion" TRUE, which calls ins_compl_get_exp(), which in turn * calls this function with "allow_get_expansion" FALSE. */ -static int +static int ins_compl_next ( int allow_get_expansion, int count, /* repeat completion this many times; should @@ -4792,7 +4792,7 @@ int get_literal(void) /* * Insert character, taking care of special keys and mod_mask */ -static void +static void insert_special ( int c, int allow_modmask, @@ -4852,7 +4852,7 @@ insert_special ( * INSCHAR_DO_COM - format comments * INSCHAR_COM_LIST - format comments with num list or 2nd line indent */ -void +void insertchar ( int c, /* character to insert or NUL */ int flags, /* INSCHAR_FORMAT, etc. */ @@ -5055,7 +5055,7 @@ insertchar ( * If the INSCHAR_COM_LIST flag is present, then the value of second_indent * will be the comment leader length sent to open_line(). */ -static void +static void internal_format ( int textwidth, int second_indent, @@ -5376,7 +5376,7 @@ internal_format ( * The caller must have saved the cursor line for undo, following ones will be * saved here. */ -void +void auto_format ( int trailblank, /* when TRUE also format with trailing blank */ int prev_line /* may start in previous line */ @@ -5478,7 +5478,7 @@ auto_format ( * delete it now. The space must be under the cursor, just after the insert * position. */ -static void +static void check_auto_format ( int end_insert /* TRUE when ending Insert mode */ ) @@ -5513,7 +5513,7 @@ check_auto_format ( * if invalid value, use 0. * Set default to window width (maximum 79) for "gq" operator. */ -int +int comp_textwidth ( int ff /* force formatting (for "gq" command) */ ) @@ -5566,7 +5566,7 @@ static void redo_literal(int c) * start_arrow() is called when an arrow key is used in insert mode. * For undo/redo it resembles hitting the <ESC> key. */ -static void +static void start_arrow ( pos_T *end_insert_pos /* can be NULL */ ) @@ -5650,7 +5650,7 @@ int stop_arrow(void) * "end_insert_pos" is where insert ended. It is NULL when we already jumped * to another window/buffer. */ -static void +static void stop_insert ( pos_T *end_insert_pos, int esc, /* called by ins_esc() */ @@ -5910,8 +5910,8 @@ int oneleft(void) width = 1; for (;; ) { coladvance(v - width); - /* getviscol() is slow, skip it when 'showbreak' is empty, - 'breakindent' is not set and there are no multi-byte + /* getviscol() is slow, skip it when 'showbreak' is empty, + 'breakindent' is not set and there are no multi-byte characters */ if ((*p_sbr == NUL && !curwin->w_p_bri @@ -5949,7 +5949,7 @@ int oneleft(void) return OK; } -int +int cursor_up ( long n, int upd_topline /* When TRUE: update topline */ @@ -6002,7 +6002,7 @@ cursor_up ( /* * Cursor down a number of logical lines. */ -int +int cursor_down ( long n, int upd_topline /* When TRUE: update topline */ @@ -6055,7 +6055,7 @@ cursor_down ( * Last_insert actually is a copy of the redo buffer, so we * first have to remove the command. */ -int +int stuff_inserted ( int c, /* Command character to be inserted */ long count, /* Repeat this many times */ @@ -6226,7 +6226,7 @@ static int replace_pop(void) * Join the top two items on the replace stack. This removes to "off"'th NUL * encountered. */ -static void +static void replace_join ( int off /* offset for which NUL to remove */ ) @@ -6889,7 +6889,7 @@ static void ins_ctrl_hat(void) * Returns TRUE when leaving insert mode, FALSE when going to repeat the * insert. */ -static int +static int ins_esc ( long *count, int cmdchar, @@ -7730,7 +7730,7 @@ static void ins_s_right(void) vim_beep(); } -static void +static void ins_up ( int startcol /* when TRUE move to Insstart.col */ ) @@ -7777,7 +7777,7 @@ static void ins_pageup(void) vim_beep(); } -static void +static void ins_down ( int startcol /* when TRUE move to Insstart.col */ ) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8e97d8bdd9..a0e6f84259 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10695,13 +10695,13 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv) argv = xmalloc(sizeof(char_u *) * argvl); // Copy program name - argv[0] = xstrdup((char *)argvars[1].vval.v_string); + argv[0] = xstrdup((char *)get_tv_string(&argvars[1])); i = 1; // Copy arguments to the vector if (argsl > 0) { for (arg = args->lv_first; arg != NULL; arg = arg->li_next) { - argv[i++] = xstrdup((char *)arg->li_tv.vval.v_string); + argv[i++] = xstrdup((char *)get_tv_string(&arg->li_tv)); } } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ef9affcdf6..f33a96cc50 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2830,7 +2830,7 @@ do_ecmd ( if ((flags & ECMD_SET_HELP) || keep_help_flag) { char_u *p; - curbuf->b_help = TRUE; + curbuf->b_help = true; set_string_option_direct((char_u *)"buftype", -1, (char_u *)"help", OPT_FREE|OPT_LOCAL, 0); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 134def0c2c..3e9b889253 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -31,6 +31,7 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/hardcopy.h" #include "nvim/if_cscope.h" @@ -4025,7 +4026,7 @@ static void ex_blast(exarg_T *eap) goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); } -int ends_excmd(int c) +int ends_excmd(int c) FUNC_ATTR_CONST { return c == NUL || c == '|' || c == '"' || c == '\n'; } diff --git a/src/nvim/farsi.c b/src/nvim/farsi.c index 13a284e926..db167825ce 100644 --- a/src/nvim/farsi.c +++ b/src/nvim/farsi.c @@ -1,8 +1,8 @@ /// @file farsi.c /// /// Functions for Farsi language -/// +#include <stdbool.h> #include "nvim/cursor.h" #include "nvim/edit.h" @@ -26,7 +26,7 @@ #define AT_CURSOR 0 -// special Farsi text messages +// Special Farsi text messages const char_u farsi_text_1[] = { YE_, _SIN, RE, ALEF_, _FE, ' ', 'V', 'I', 'M', @@ -59,6 +59,7 @@ const char_u farsi_text_5[] = { #ifdef INCLUDE_GENERATED_DECLARATIONS # include "farsi.c.generated.h" #endif + /// Convert the given Farsi character into a _X or _X_ type /// /// @param c The character to convert. @@ -287,8 +288,8 @@ int toF_TyA(int c) /// @param src /// @param offset /// -/// @return TRUE if the character under the cursor+offset is a join type. -static int F_is_TyB_TyC_TyD(int src, int offset) +/// @return true if the character under the cursor+offset is a join type. +static bool F_is_TyB_TyC_TyD(int src, int offset) { int c; @@ -330,17 +331,17 @@ static int F_is_TyB_TyC_TyD(int src, int offset) case _IE: case _HE_: case _HE: - return TRUE; + return true; } - return FALSE; + return false; } /// Is the Farsi character one of the terminating only type. /// /// @param c The character to check. /// -/// @return TRUE if the Farsi character is one of the terminating only types. -static int F_is_TyE(int c) +/// @return true if the Farsi character is one of the terminating only types. +static bool F_is_TyE(int c) { switch (c) { case ALEF_A: @@ -353,17 +354,17 @@ static int F_is_TyE(int c) case WAW: case WAW_H: case HAMZE: - return TRUE; + return true; } - return FALSE; + return false; } /// Is the Farsi character one of the none leading type. /// /// @param c The character to check. /// -/// @return TRUE if the Farsi character is one of the none-leading types. -static int F_is_TyC_TyD(int c) +/// @return true if the Farsi character is one of the none-leading types. +static bool F_is_TyC_TyD(int c) { switch (c) { case ALEF_: @@ -377,9 +378,9 @@ static int F_is_TyC_TyD(int c) case IE_: case TEE_: case YEE_: - return TRUE; + return true; } - return FALSE; + return false; } /// Convert a none leading Farsi char into a leading type. @@ -2081,8 +2082,8 @@ static int toF_Rjoin(int c) /// /// @param c The character to check. /// -/// @return TRUE if the character can join via its left edj. -static int canF_Ljoin(int c) +/// @return true if the character can join via its left edj. +static bool canF_Ljoin(int c) { switch (c) { case _BE: @@ -2146,17 +2147,17 @@ static int canF_Ljoin(int c) case F_HE: case _HE: case _HE_: - return TRUE; + return true; } - return FALSE; + return false; } /// Can a given Farsi character join via its right edj. /// /// @param c /// -/// @return TRUE if the character can join via its right edj. -static int canF_Rjoin(int c) +/// @return true if the character can join via its right edj. +static bool canF_Rjoin(int c) { switch (c) { case ALEF: @@ -2172,9 +2173,8 @@ static int canF_Rjoin(int c) case TEE_: case WAW: case WAW_H: - return TRUE; + return true; } - return canF_Ljoin(c); } @@ -2182,8 +2182,8 @@ static int canF_Rjoin(int c) /// /// @param c /// -/// @return TRUE if the character is a terminating type. -static int F_isterm(int c) +/// @return true if the character is a terminating type. +static bool F_isterm(int c) { switch (c) { case ALEF: @@ -2199,10 +2199,9 @@ static int F_isterm(int c) case WAW_H: case TEE: case TEE_: - return TRUE; + return true; } - - return FALSE; + return false; } /// Convert the given Farsi character into an ending type. @@ -2915,34 +2914,34 @@ int cmdl_fkmap(int c) return c; } -/// F_isalpha returns TRUE if 'c' is a Farsi alphabet +/// F_isalpha returns true if 'c' is in the Farsi alphabet. /// /// @param c The character to check. /// -/// @return TRUE if 'c' is a Farsi alphabet character. -int F_isalpha(int c) +/// @return true if 'c' is a Farsi alphabet character. +bool F_isalpha(int c) { return (c >= TEE_ && c <= _YE) || (c >= ALEF_A && c <= YE) || (c >= _IE && c <= YE_); } -/// F_isdigit returns TRUE if 'c' is a Farsi digit +/// F_isdigit returns true if 'c' is a Farsi digit /// /// @param c The character to check. /// -/// @return TRUE if 'c' is a Farsi digit. -int F_isdigit(int c) +/// @return true if 'c' is a Farsi digit. +bool F_isdigit(int c) { return c >= FARSI_0 && c <= FARSI_9; } -/// F_ischar returns TRUE if 'c' is a Farsi character. +/// F_ischar returns true if 'c' is a Farsi character. /// /// @param c The character to check. /// -/// @return TRUE if 'c' is a Farsi character. -int F_ischar(int c) +/// @return true if 'c' is a Farsi character. +bool F_ischar(int c) { return c >= TEE_ && c <= YE_; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index b20150b2c9..97a357bff7 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2197,7 +2197,7 @@ static void check_marks_read(void) /* Always set b_marks_read; needed when 'viminfo' is changed to include * the ' parameter after opening a buffer. */ - curbuf->b_marks_read = TRUE; + curbuf->b_marks_read = true; } #ifdef UNIX @@ -2690,7 +2690,7 @@ buf_write ( got_int = FALSE; /* Mark the buffer as 'being saved' to prevent changed buffer warnings */ - buf->b_saving = TRUE; + buf->b_saving = true; /* * If we are not appending or filtering, the file exists, and the @@ -3665,7 +3665,7 @@ fail: nofail: /* Done saving, we accept changed buffer warnings again */ - buf->b_saving = FALSE; + buf->b_saving = false; free(backup); if (buffer != smallbuf) @@ -6489,7 +6489,7 @@ apply_autocmds_group ( { char_u *sfname = NULL; /* short file name */ char_u *tail; - int save_changed; + bool save_changed; buf_T *old_curbuf; int retval = FALSE; char_u *save_sourcing_name; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 6014dbfd15..e76aacbadc 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -485,7 +485,7 @@ static void newFoldLevelWin(win_T *wp) fp = (fold_T *)wp->w_folds.ga_data; for (int i = 0; i < wp->w_folds.ga_len; ++i) fp[i].fd_flags = FD_LEVEL; - wp->w_fold_manual = FALSE; + wp->w_fold_manual = false; } changed_window_setting_win(wp); } @@ -648,7 +648,7 @@ void foldCreate(linenr_T start, linenr_T end) if (use_level && !closed && level < curwin->w_p_fdl) closeFold(start, 1L); if (!use_level) - curwin->w_fold_manual = TRUE; + curwin->w_fold_manual = true; fp->fd_flags = FD_CLOSED; fp->fd_small = MAYBE; @@ -755,7 +755,7 @@ deleteFold ( void clearFolding(win_T *win) { deleteFoldRecurse(&win->w_folds); - win->w_foldinvalid = FALSE; + win->w_foldinvalid = false; } /* foldUpdate() {{{2 */ @@ -800,7 +800,7 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot) */ void foldUpdateAll(win_T *win) { - win->w_foldinvalid = TRUE; + win->w_foldinvalid = true; redraw_win_later(win, NOT_VALID); } @@ -1098,7 +1098,7 @@ static void checkupdate(win_T *wp) { if (wp->w_foldinvalid) { foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); /* will update all */ - wp->w_foldinvalid = FALSE; + wp->w_foldinvalid = false; } } @@ -1251,7 +1251,7 @@ setManualFoldWin ( found->fd_flags = FD_CLOSED; done |= DONE_ACTION; } - wp->w_fold_manual = TRUE; + wp->w_fold_manual = true; if (done & DONE_ACTION) changed_window_setting_win(wp); done |= DONE_FOLD; @@ -1877,7 +1877,7 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot) /* Need to update all folds. */ top = 1; bot = wp->w_buffer->b_ml.ml_line_count; - wp->w_foldinvalid = FALSE; + wp->w_foldinvalid = false; /* Mark all folds a maybe-small. */ setSmallMaybe(&wp->w_folds); @@ -2285,12 +2285,12 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level, * The new fold is closed if the fold above it is closed. * The first fold depends on the containing fold. */ if (topflags == FD_OPEN) { - flp->wp->w_fold_manual = TRUE; + flp->wp->w_fold_manual = true; fp->fd_flags = FD_OPEN; } else if (i <= 0) { fp->fd_flags = topflags; if (topflags != FD_LEVEL) - flp->wp->w_fold_manual = TRUE; + flp->wp->w_fold_manual = true; } else fp->fd_flags = (fp - 1)->fd_flags; fp->fd_small = MAYBE; diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 2ef35fdac6..1d15e30921 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -2434,20 +2434,15 @@ int mch_print_begin(prt_settings_T *psettings) double right; double top; double bottom; - struct prt_ps_resource_S *res_prolog; - struct prt_ps_resource_S *res_encoding; + struct prt_ps_resource_S res_prolog; + struct prt_ps_resource_S res_encoding; char buffer[256]; char_u *p_encoding; char_u *p; - struct prt_ps_resource_S *res_cidfont; - struct prt_ps_resource_S *res_cmap; + struct prt_ps_resource_S res_cidfont; + struct prt_ps_resource_S res_cmap; int retval = FALSE; - res_prolog = xmalloc(sizeof(struct prt_ps_resource_S)); - res_encoding = xmalloc(sizeof(struct prt_ps_resource_S)); - res_cidfont = xmalloc(sizeof(struct prt_ps_resource_S)); - res_cmap = xmalloc(sizeof(struct prt_ps_resource_S)); - /* * PS DSC Header comments - no PS code! */ @@ -2515,23 +2510,23 @@ int mch_print_begin(prt_settings_T *psettings) } /* Search for external resources VIM supplies */ - if (!prt_find_resource("prolog", res_prolog)) { + if (!prt_find_resource("prolog", &res_prolog)) { EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\"")); return FALSE; } - if (!prt_open_resource(res_prolog)) + if (!prt_open_resource(&res_prolog)) return FALSE; - if (!prt_check_resource(res_prolog, PRT_PROLOG_VERSION)) + if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION)) return FALSE; if (prt_out_mbyte) { /* Look for required version of multi-byte printing procset */ - if (!prt_find_resource("cidfont", res_cidfont)) { + if (!prt_find_resource("cidfont", &res_cidfont)) { EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\"")); return FALSE; } - if (!prt_open_resource(res_cidfont)) + if (!prt_open_resource(&res_cidfont)) return FALSE; - if (!prt_check_resource(res_cidfont, PRT_CID_PROLOG_VERSION)) + if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION)) return FALSE; } @@ -2543,25 +2538,25 @@ int mch_print_begin(prt_settings_T *psettings) if (!prt_out_mbyte) { p_encoding = enc_skip(p_penc); if (*p_encoding == NUL - || !prt_find_resource((char *)p_encoding, res_encoding)) { + || !prt_find_resource((char *)p_encoding, &res_encoding)) { /* 'printencoding' not set or not supported - find alternate */ int props; p_encoding = enc_skip(p_enc); props = enc_canon_props(p_encoding); if (!(props & ENC_8BIT) - || !prt_find_resource((char *)p_encoding, res_encoding)) { + || !prt_find_resource((char *)p_encoding, &res_encoding)) { /* 8-bit 'encoding' is not supported */ /* Use latin1 as default printing encoding */ p_encoding = (char_u *)"latin1"; - if (!prt_find_resource((char *)p_encoding, res_encoding)) { + if (!prt_find_resource((char *)p_encoding, &res_encoding)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), p_encoding); return FALSE; } } } - if (!prt_open_resource(res_encoding)) + if (!prt_open_resource(&res_encoding)) return FALSE; /* For the moment there are no checks on encoding resource files to * perform */ @@ -2571,12 +2566,12 @@ int mch_print_begin(prt_settings_T *psettings) p_encoding = enc_skip(p_enc); if (prt_use_courier) { /* Include ASCII range encoding vector */ - if (!prt_find_resource(prt_ascii_encoding, res_encoding)) { + if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), prt_ascii_encoding); return FALSE; } - if (!prt_open_resource(res_encoding)) + if (!prt_open_resource(&res_encoding)) return FALSE; /* For the moment there are no checks on encoding resource files to * perform */ @@ -2597,37 +2592,37 @@ int mch_print_begin(prt_settings_T *psettings) if (prt_out_mbyte && prt_custom_cmap) { /* Find user supplied CMap */ - if (!prt_find_resource(prt_cmap, res_cmap)) { + if (!prt_find_resource(prt_cmap, &res_cmap)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), prt_cmap); return FALSE; } - if (!prt_open_resource(res_cmap)) + if (!prt_open_resource(&res_cmap)) return FALSE; } /* List resources supplied */ - STRCPY(buffer, res_prolog->title); + STRCPY(buffer, res_prolog.title); STRCAT(buffer, " "); - STRCAT(buffer, res_prolog->version); + STRCAT(buffer, res_prolog.version); prt_dsc_resources("DocumentSuppliedResources", "procset", buffer); if (prt_out_mbyte) { - STRCPY(buffer, res_cidfont->title); + STRCPY(buffer, res_cidfont.title); STRCAT(buffer, " "); - STRCAT(buffer, res_cidfont->version); + STRCAT(buffer, res_cidfont.version); prt_dsc_resources(NULL, "procset", buffer); if (prt_custom_cmap) { - STRCPY(buffer, res_cmap->title); + STRCPY(buffer, res_cmap.title); STRCAT(buffer, " "); - STRCAT(buffer, res_cmap->version); + STRCAT(buffer, res_cmap.version); prt_dsc_resources(NULL, "cmap", buffer); } } if (!prt_out_mbyte || prt_use_courier) { - STRCPY(buffer, res_encoding->title); + STRCPY(buffer, res_encoding.title); STRCAT(buffer, " "); - STRCAT(buffer, res_encoding->version); + STRCAT(buffer, res_encoding.version); prt_dsc_resources(NULL, "encoding", buffer); } prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate, @@ -2661,20 +2656,20 @@ int mch_print_begin(prt_settings_T *psettings) prt_dsc_noarg("BeginProlog"); /* Add required procsets - NOTE: order is important! */ - if (!prt_add_resource(res_prolog)) + if (!prt_add_resource(&res_prolog)) return FALSE; if (prt_out_mbyte) { /* Add CID font procset, and any user supplied CMap */ - if (!prt_add_resource(res_cidfont)) + if (!prt_add_resource(&res_cidfont)) return FALSE; - if (prt_custom_cmap && !prt_add_resource(res_cmap)) + if (prt_custom_cmap && !prt_add_resource(&res_cmap)) return FALSE; } if (!prt_out_mbyte || prt_use_courier) /* There will be only one Roman font encoding to be included in the PS * file. */ - if (!prt_add_resource(res_encoding)) + if (!prt_add_resource(&res_encoding)) return FALSE; prt_dsc_noarg("EndProlog"); @@ -2780,11 +2775,6 @@ int mch_print_begin(prt_settings_T *psettings) /* Fail if any problems writing out to the PS file */ retval = !prt_file_error; - free(res_prolog); - free(res_encoding); - free(res_cidfont); - free(res_cmap); - return retval; } diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 91fbe62c18..e9edeb842f 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -277,9 +277,9 @@ int ml_open(buf_T *buf) * When 'updatecount' is non-zero swap file may be opened later. */ if (p_uc && buf->b_p_swf) - buf->b_may_swap = TRUE; + buf->b_may_swap = true; else - buf->b_may_swap = FALSE; + buf->b_may_swap = false; /* * Open the memfile. No swap file is created yet. @@ -495,7 +495,7 @@ void ml_open_file(buf_T *buf) fname = vim_tempname(); if (fname != NULL) (void)mf_open_file(mfp, fname); /* consumes fname! */ - buf->b_may_swap = FALSE; + buf->b_may_swap = false; return; } @@ -540,7 +540,7 @@ void ml_open_file(buf_T *buf) } /* don't try to open a swap file again */ - buf->b_may_swap = FALSE; + buf->b_may_swap = false; } /* diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 2eea48df00..310cb6faac 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1855,7 +1855,7 @@ void changed(void) */ void changed_int(void) { - curbuf->b_changed = TRUE; + curbuf->b_changed = true; ml_setflags(curbuf); check_status(curbuf); redraw_tabline = TRUE; @@ -1900,7 +1900,7 @@ static void changedOneline(buf_T *buf, linenr_T lnum) buf->b_mod_bot = lnum + 1; } else { /* set the area that must be redisplayed to one line */ - buf->b_mod_set = TRUE; + buf->b_mod_set = true; buf->b_mod_top = lnum; buf->b_mod_bot = lnum + 1; buf->b_mod_xlines = 0; @@ -2013,7 +2013,7 @@ changed_lines_buf ( buf->b_mod_xlines += xtra; } else { /* set the area that must be redisplayed */ - buf->b_mod_set = TRUE; + buf->b_mod_set = true; buf->b_mod_top = lnum; buf->b_mod_bot = lnume + xtra; buf->b_mod_xlines = xtra; @@ -2063,7 +2063,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra /* This is the first of a new sequence of undo-able changes * and it's at some distance of the last change. Use a new * position in the changelist. */ - curbuf->b_new_change = FALSE; + curbuf->b_new_change = false; if (curbuf->b_changelistlen == JUMPLISTSIZE) { /* changelist is full: remove oldest entry */ @@ -2195,7 +2195,7 @@ unchanged ( ) { if (buf->b_changed || (ff && file_ff_differs(buf, FALSE))) { - buf->b_changed = 0; + buf->b_changed = false; ml_setflags(buf); if (ff) save_file_ff(buf); @@ -2226,8 +2226,8 @@ void check_status(buf_T *buf) * If the file is readonly, give a warning message with the first change. * Don't do this for autocommands. * Don't use emsg(), because it flushes the macro buffer. - * If we have undone all changes b_changed will be FALSE, but "b_did_warn" - * will be TRUE. + * If we have undone all changes b_changed will be false, but "b_did_warn" + * will be true. * Careful: may trigger autocommands that reload the buffer. */ void @@ -2238,7 +2238,7 @@ change_warning ( { static char *w_readonly = N_("W10: Warning: Changing a readonly file"); - if (curbuf->b_did_warn == FALSE + if (curbuf->b_did_warn == false && curbufIsChanged() == 0 && !autocmd_busy && curbuf->b_p_ro) { @@ -2263,7 +2263,7 @@ change_warning ( out_flush(); ui_delay(1000L, true); /* give the user time to think about it */ } - curbuf->b_did_warn = TRUE; + curbuf->b_did_warn = true; redraw_cmdline = FALSE; /* don't redraw and erase the message */ if (msg_row < Rows - 1) showmode(); diff --git a/src/nvim/move.c b/src/nvim/move.c index c43fa1d09d..95b961e52c 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1673,7 +1673,7 @@ void scroll_cursor_halfway(int atend) curwin->w_topline = topline; curwin->w_topfill = topfill; if (old_topline > curwin->w_topline + curwin->w_height) - curwin->w_botfill = FALSE; + curwin->w_botfill = false; check_topfill(curwin, false); curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); curwin->w_valid |= VALID_TOPLINE; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 829c762c51..29070ff188 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -413,7 +413,7 @@ static int find_command(int cmdchar) /* * Execute a command in Normal mode. */ -void +void normal_cmd ( oparg_T *oap, bool toplevel /* true when called from main() */ @@ -3244,7 +3244,7 @@ static void nv_page(cmdarg_T *cap) /* * Implementation of "gd" and "gD" command. */ -static void +static void nv_gd ( oparg_T *oap, int nchar, @@ -4832,7 +4832,7 @@ static void nv_next(cmdarg_T *cap) * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). * Uses only cap->count1 and cap->oap from "cap". */ -static void +static void normal_search ( cmdarg_T *cap, int dir, @@ -7060,7 +7060,7 @@ static void nv_edit(cmdarg_T *cap) /* * Invoke edit() and take care of "restart_edit" and the return value. */ -static void +static void invoke_edit ( cmdarg_T *cap, int repl, /* "r" or "gr" command */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 207be0bd74..31f5ab7788 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2007,7 +2007,7 @@ void set_init_1(void) set_options_default(0); - curbuf->b_p_initialized = TRUE; + curbuf->b_p_initialized = true; curbuf->b_p_ar = -1; /* no local 'autoread' value */ curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; check_buf_options(curbuf); @@ -2563,7 +2563,6 @@ do_set ( /* find end of name */ key = 0; if (*arg == '<') { - nextchar = 0; opt_idx = -1; /* look out for <t_>;> */ if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) @@ -3481,7 +3480,7 @@ static void didset_options(void) (void)compile_cap_prog(curwin->w_s); /* set cedit_key */ (void)check_cedit(); - briopt_check(); + briopt_check(curwin); } /* @@ -3818,7 +3817,7 @@ did_set_string_option ( } /* 'breakindentopt' */ else if (varp == &curwin->w_p_briopt) { - if (briopt_check() == FAIL) + if (briopt_check(curwin) == FAIL) errmsg = e_invarg; } /* @@ -4977,7 +4976,7 @@ set_bool_option ( /* when 'readonly' is set may give W10 again */ if (curbuf->b_p_ro) - curbuf->b_did_warn = FALSE; + curbuf->b_did_warn = false; redraw_titles(); } @@ -5086,7 +5085,7 @@ set_bool_option ( did_set_title(FALSE); } else if ((int *)varp == &p_icon) { did_set_title(TRUE); - } else if ((int *)varp == &curbuf->b_changed) { + } else if ((bool *)varp == &curbuf->b_changed) { if (!value) save_file_ff(curbuf); /* Buffer is unchanged */ redraw_titles(); @@ -5782,7 +5781,7 @@ get_option_value ( else { /* Special case: 'modified' is b_changed, but we also want to consider * it set when 'ff' or 'fenc' changed. */ - if ((int *)varp == &curbuf->b_changed) + if ((bool *)varp == &curbuf->b_changed) *numval = curbufIsChanged(); else *numval = *(int *)varp; @@ -6173,8 +6172,8 @@ showoneopt ( varp = get_varp_scope(p, opt_flags); /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ - if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed - ? !curbufIsChanged() : !*(int *)varp)) + if ((p->flags & P_BOOL) && ((bool *)varp == &curbuf->b_changed + ? !curbufIsChanged() : !*(bool *)varp)) MSG_PUTS("no"); else if ((p->flags & P_BOOL) && *(int *)varp < 0) MSG_PUTS("--"); @@ -6771,6 +6770,7 @@ void win_copy_options(win_T *wp_from, win_T *wp_to) copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); /* Is this right? */ wp_to->w_farsi = wp_from->w_farsi; + briopt_check(wp_to); } /* @@ -7026,7 +7026,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_isk = vim_strsave(p_isk); did_isk = TRUE; buf->b_p_ts = p_ts; - buf->b_help = FALSE; + buf->b_help = false; if (buf->b_p_bt[0] == 'h') clear_string_option(&buf->b_p_bt); buf->b_p_ma = p_ma; @@ -7038,7 +7038,7 @@ void buf_copy_options(buf_T *buf, int flags) * flag that indicates that the options have been initialized. */ if (should_copy) - buf->b_p_initialized = TRUE; + buf->b_p_initialized = true; } check_buf_options(buf); /* make sure we don't have NULLs */ @@ -8143,16 +8143,15 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) } } -/* This is called when 'breakindentopt' is changed and when a window is - initialized */ -int briopt_check(void) +/// This is called when 'breakindentopt' is changed and when a window is +/// initialized +static bool briopt_check(win_T *wp) { - char_u *p; int bri_shift = 0; long bri_min = 20; bool bri_sbr = false; - p = curwin->w_p_briopt; + char_u *p = wp->w_p_briopt; while (*p != NUL) { if (STRNCMP(p, "shift:", 6) == 0 @@ -8172,15 +8171,15 @@ int briopt_check(void) bri_sbr = true; } if (*p != ',' && *p != NUL) - return FAIL; + return false; if (*p == ',') ++p; } - curwin->w_p_brishift = bri_shift; - curwin->w_p_brimin = bri_min; - curwin->w_p_brisbr = bri_sbr; + wp->w_p_brishift = bri_shift; + wp->w_p_brimin = bri_min; + wp->w_p_brisbr = bri_sbr; - return OK; + return true; } diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 19b92c5789..af2ab73dc8 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -604,7 +604,7 @@ static int pum_set_selected(int n, int repeat) } } - curbuf->b_changed = 0; + curbuf->b_changed = false; curbuf->b_p_ma = FALSE; curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 738bfb4c58..3de7f73339 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -10,6 +10,7 @@ * quickfix.c: functions for quickfix mode, using a file with error messages */ +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> @@ -798,6 +799,16 @@ qf_init_end: return retval; } +static void qf_store_title(qf_info_T *qi, char_u *title) +{ + if (title != NULL) { + char_u *p = xmalloc(STRLEN(title) + 2); + + qi->qf_lists[qi->qf_curlist].qf_title = p; + sprintf((char *)p, ":%s", (char *)title); + } +} + /* * Prepare for adding a new quickfix list. */ @@ -805,11 +816,9 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title) { int i; - /* - * If the current entry is not the last entry, delete entries below - * the current entry. This makes it possible to browse in a tree-like - * way with ":grep'. - */ + // If the current entry is not the last entry, delete entries beyond + // the current entry. This makes it possible to browse in a tree-like + // way with ":grep'. while (qi->qf_listcount > qi->qf_curlist + 1) qf_free(qi, --qi->qf_listcount); @@ -825,12 +834,7 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title) } else qi->qf_curlist = qi->qf_listcount++; memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); - if (qf_title != NULL) { - char_u *p = xmalloc(STRLEN(qf_title) + 2); - - qi->qf_lists[qi->qf_curlist].qf_title = p; - sprintf((char *)p, ":%s", (char *)qf_title); - } + qf_store_title(qi, qf_title); } /* @@ -877,7 +881,7 @@ void qf_free_all(win_T *wp) static int qf_add_entry ( qf_info_T *qi, /* quickfix list */ - qfline_T **prevp, /* pointer to previously added entry or NULL */ + qfline_T **prevp, /* nonnull pointer (to previously added entry or NULL) */ char_u *dir, /* optional directory name */ char_u *fname, /* file name or NULL */ int bufnum, /* buffer number or zero */ @@ -917,6 +921,7 @@ qf_add_entry ( qi->qf_lists[qi->qf_curlist].qf_start = qfp; qfp->qf_prev = qfp; /* first element points to itself */ } else { + assert(*prevp); qfp->qf_prev = *prevp; (*prevp)->qf_next = qfp; } @@ -2124,8 +2129,9 @@ void ex_copen(exarg_T *eap) */ qf_fill_buffer(qi); - if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) - qf_set_title(qi); + if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) { + qf_set_title_var(qi); + } curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; curwin->w_cursor.col = 0; @@ -2263,7 +2269,7 @@ static void qf_update_buffer(qf_info_T *qi) && (win = qf_find_win(qi)) != NULL) { curwin_save = curwin; curwin = win; - qf_set_title(qi); + qf_set_title_var(qi); curwin = curwin_save; } @@ -2275,7 +2281,7 @@ static void qf_update_buffer(qf_info_T *qi) } } -static void qf_set_title(qf_info_T *qi) +static void qf_set_title_var(qf_info_T *qi) { set_internal_string_var((char_u *)"w:quickfix_title", qi->qf_lists[qi->qf_curlist].qf_title); @@ -3302,8 +3308,10 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title) for (prevp = qi->qf_lists[qi->qf_curlist].qf_start; prevp->qf_next != prevp; prevp = prevp->qf_next) ; - else if (action == 'r') + else if (action == 'r') { qf_free(qi, qi->qf_curlist); + qf_store_title(qi, title); + } for (li = list->lv_first; li != NULL; li = li->li_next) { if (li->li_tv.v_type != VAR_DICT) diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index cef2e6d9bf..d57bc889ac 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1983,9 +1983,15 @@ static char_u *regatom(int *flagp) break; case 's': ret = regnode(MOPEN + 0); + if (!re_mult_next("\\zs")) { + return NULL; + } break; case 'e': ret = regnode(MCLOSE + 0); + if (!re_mult_next("\\ze")) { + return NULL; + } break; default: EMSG_RET_NULL(_("E68: Invalid character after \\z")); @@ -2460,6 +2466,15 @@ do_multibyte: return ret; } +/// Used in a place where no * or \+ can follow. +static bool re_mult_next(char *what) +{ + if (re_multi_type(peekchr()) == MULTI_MULT) { + EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what); + } + return true; +} + /* * Return TRUE if MULTIBYTECODE should be used instead of EXACTLY for * character "c". diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 2659eac762..60cdc12c92 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1084,7 +1084,6 @@ static int nfa_regatom(void) int extra = 0; int emit_range; int negated; - int result; int startc = -1; int endc = -1; int oldstartc = -1; @@ -1259,10 +1258,16 @@ static int nfa_regatom(void) switch (c) { case 's': EMIT(NFA_ZSTART); + if (!re_mult_next("\\zs")) { + return false; + } break; case 'e': EMIT(NFA_ZEND); - nfa_has_zend = TRUE; + nfa_has_zend = true; + if (!re_mult_next("\\zs")) { + return false; + } break; case '1': case '2': @@ -1446,8 +1451,8 @@ collection: * recognize that [0-9] stands for \d and [A-Za-z_] for \h, * and perform the necessary substitutions in the NFA. */ - result = nfa_recognize_char_class(regparse, endp, - extra == NFA_ADD_NL); + int result = nfa_recognize_char_class(regparse, endp, + extra == NFA_ADD_NL); if (result != FAIL) { if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL) { EMIT(result - NFA_ADD_NL); @@ -1551,7 +1556,6 @@ collection: /* Try equivalence class [=a=] and the like */ if (equiclass != 0) { nfa_emit_equi_class(equiclass); - result = OK; continue; } /* Try collating class like [. .] */ diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e217945ac3..58faac1ae7 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -554,7 +554,7 @@ void update_screen(int type) /* Reset b_mod_set flags. Going through all windows is probably faster * than going through all buffers (there could be many buffers). */ FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - wp->w_buffer->b_mod_set = FALSE; + wp->w_buffer->b_mod_set = false; } updating_screen = FALSE; @@ -1672,7 +1672,7 @@ static void win_update(win_T *wp) if (must_redraw != 0) { /* Don't update for changes in buffer again. */ i = curbuf->b_mod_set; - curbuf->b_mod_set = FALSE; + curbuf->b_mod_set = false; win_update(curwin); must_redraw = 0; curbuf->b_mod_set = i; diff --git a/src/nvim/search.c b/src/nvim/search.c index 1e275e9753..bd1811c7fb 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3973,6 +3973,7 @@ find_pattern_in_path ( char_u *startp = NULL; char_u *inc_opt = NULL; win_T *curwin_save = NULL; + const int l_g_do_tagpreview = g_do_tagpreview; regmatch.regprog = NULL; incl_regmatch.regprog = NULL; @@ -4370,7 +4371,7 @@ search_line: } else if (--count <= 0) { found = TRUE; if (depth == -1 && lnum == curwin->w_cursor.lnum - && g_do_tagpreview == 0 + && l_g_do_tagpreview == 0 ) EMSG(_("E387: Match is on current line")); else if (action == ACTION_SHOW) { @@ -4380,7 +4381,7 @@ search_line: did_show = TRUE; } else { /* ":psearch" uses the preview window */ - if (g_do_tagpreview != 0) { + if (l_g_do_tagpreview != 0) { curwin_save = curwin; prepare_tagpreview(true); } @@ -4391,7 +4392,7 @@ search_line: } if (depth == -1) { /* match in current file */ - if (g_do_tagpreview != 0) { + if (l_g_do_tagpreview != 0) { if (getfile(0, curwin_save->w_buffer->b_fname, NULL, TRUE, lnum, FALSE) > 0) break; /* failed to jump to file */ @@ -4412,7 +4413,7 @@ search_line: curwin->w_set_curswant = TRUE; } - if (g_do_tagpreview != 0 + if (l_g_do_tagpreview != 0 && curwin != curwin_save && win_valid(curwin_save)) { /* Return cursor to where we were */ validate_cursor(); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 342f121c48..ea5ce7ee0d 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -284,6 +284,7 @@ // stored as an offset to the previous number in as // few bytes as possible, see offset2bytes()) +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> @@ -303,6 +304,7 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/hashtab.h" #include "nvim/mbyte.h" @@ -1599,7 +1601,9 @@ static void find_word(matchinf_T *mip, int mode) mip->mi_compoff = (int)(p - mip->mi_fword); } } +#if 0 c = mip->mi_compoff; +#endif ++mip->mi_complen; if (flags & WF_COMPROOT) ++mip->mi_compextra; @@ -2058,7 +2062,7 @@ spell_move_to ( char_u *line; char_u *p; char_u *endp; - hlf_T attr; + hlf_T attr = HLF_COUNT; int len; int has_syntax = syntax_present(wp); int col; @@ -2094,6 +2098,7 @@ spell_move_to ( buflen = len + MAXWLEN + 2; buf = xmalloc(buflen); } + assert(buf && buflen >= len + MAXWLEN + 2); // In first line check first word for Capital. if (lnum == 1) @@ -4462,7 +4467,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) || aff->af_pref.ht_used > 0) smsg((char_u *)_("FLAG after using flags in %s line %d: %s"), fname, lnum, items[1]); - } else if (spell_info_item(items[0])) { + } else if (spell_info_item(items[0]) && itemcnt > 1) { p = (char_u *)getroom(spin, (spin->si_info == NULL ? 0 : STRLEN(spin->si_info)) + STRLEN(items[0]) @@ -5800,6 +5805,8 @@ store_aff_word ( // Get compound IDS from the affix list. get_compflags(affile, ae->ae_flags, use_pfxlist + use_pfxlen); + else + use_pfxlist[use_pfxlen] = NUL; // Combine the list of compound flags. // Concatenate them to the prefix IDs list. @@ -6066,14 +6073,17 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) /// track of them). /// The memory is cleared to all zeros. /// -/// @param len Length needed. +/// @param len Length needed (<= SBLOCKSIZE). /// @param align Align for pointer. -/// @return NULL when out of memory. +/// @return Pointer into block data. static void *getroom(spellinfo_T *spin, size_t len, bool align) + FUNC_ATTR_NONNULL_RET { char_u *p; sblock_T *bl = spin->si_blocks; + assert(len <= SBLOCKSIZE); + if (align && bl != NULL) // Round size up for alignment. On some systems structures need to be // aligned to the size of a pointer (e.g., SPARC). @@ -6081,11 +6091,8 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align) & ~(sizeof(char *) - 1); if (bl == NULL || bl->sb_used + len > SBLOCKSIZE) { - if (len >= SBLOCKSIZE) - bl = NULL; - else - // Allocate a block of memory. It is not freed until much later. - bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE)); + // Allocate a block of memory. It is not freed until much later. + bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE)); bl->sb_next = spin->si_blocks; spin->si_blocks = bl; bl->sb_used = 0; @@ -12496,8 +12503,9 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) char_u *p; int wbadword[MAXWLEN]; int wgoodword[MAXWLEN]; + const int l_has_mbyte = has_mbyte; - if (has_mbyte) { + if (l_has_mbyte) { // Get the characters from the multi-byte strings and put them in an // int array for easy access. for (p = badword, badlen = 0; *p != NUL; ) @@ -12522,7 +12530,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) for (i = 1; i <= badlen; ++i) { CNT(i, 0) = CNT(i - 1, 0) + SCORE_DEL; for (j = 1; j <= goodlen; ++j) { - if (has_mbyte) { + if (l_has_mbyte) { bc = wbadword[i - 1]; gc = wgoodword[j - 1]; } else { @@ -12546,7 +12554,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) } if (i > 1 && j > 1) { - if (has_mbyte) { + if (l_has_mbyte) { pbc = wbadword[i - 2]; pgc = wgoodword[j - 2]; } else { diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e0c9628985..6c5c0f37b1 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -2851,15 +2851,16 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T { int r; proftime_T pt; + const int l_syn_time_on = syn_time_on; - if (syn_time_on) { + if (l_syn_time_on) { pt = profile_start(); } rmp->rmm_maxcol = syn_buf->b_p_smc; r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL); - if (syn_time_on) { + if (l_syn_time_on) { pt = profile_end(pt); st->total = profile_add(st->total, pt); if (profile_cmp(pt, st->slowest) < 0) { @@ -5105,7 +5106,7 @@ get_id_list ( * parse the arguments after "contains" */ count = 0; - while (!ends_excmd(*p)) { + do { for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end) ; name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */ @@ -5198,7 +5199,7 @@ get_id_list ( if (*p != ',') break; p = skipwhite(p + 1); /* skip comma in between arguments */ - } + } while (!ends_excmd(*p)); if (failed) break; if (round == 1) { diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a123e9b902..e267280bbd 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1180,7 +1180,7 @@ find_tags ( * Initialize a few variables */ if (help_only) /* want tags from help file */ - curbuf->b_help = TRUE; /* will be restored later */ + curbuf->b_help = true; /* will be restored later */ orgpat.len = (int)STRLEN(pat); if (curbuf->b_help) { diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 521fbc19cf..9ca2c9688a 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -34,6 +34,7 @@ SCRIPTS := test_autoformat_join.out \ test_options.out \ test_listlbr.out test_listlbr_utf8.out \ test_changelist.out \ + test_qf_title.out \ test_breakindent.out \ test_insertcount.out \ test_utf8.out diff --git a/src/nvim/testdir/test64.in b/src/nvim/testdir/test64.in index 2abdcd1c08..f2452fc0f3 100644 --- a/src/nvim/testdir/test64.in +++ b/src/nvim/testdir/test64.in @@ -459,7 +459,7 @@ STARTTEST : let text = t[2] : let matchidx = 3 : for engine in [0, 1, 2] -: if engine == 2 && re == 0 || engine == 1 && re ==1 +: if engine == 2 && re == 0 || engine == 1 && re == 1 : continue : endif : let ®expengine = engine @@ -608,6 +608,17 @@ yeGopA END:" "ayb20gg/..\%$ "bybGo"apo"bp:" :" +:" Check for detecting error +:set regexpengine=2 +:for pat in [' \ze*', ' \zs*'] +: try +: let l = matchlist('x x', pat) +: $put ='E888 NOT detected for ' . pat +: catch +: $put ='E888 detected for ' . pat +: endtry +:endfor +:" :""""" Write the results """"""""""""" :/\%#=1^Results/,$wq! test.out ENDTEST diff --git a/src/nvim/testdir/test64.ok b/src/nvim/testdir/test64.ok index e7d173141a..ffc0b5341f 100644 --- a/src/nvim/testdir/test64.ok +++ b/src/nvim/testdir/test64.ok @@ -1097,3 +1097,5 @@ Test Test END EN E +E888 detected for \ze* +E888 detected for \zs* diff --git a/src/nvim/testdir/test_breakindent.in b/src/nvim/testdir/test_breakindent.in index 8f40e4f7e5..150c9430db 100644 --- a/src/nvim/testdir/test_breakindent.in +++ b/src/nvim/testdir/test_breakindent.in @@ -27,6 +27,7 @@ STARTTEST : $put =g:line1 : wincmd p :endfu +:set briopt=min:0 :let g:test="Test 1: Simple breakindent" :let line1=ScreenChar(8) :call DoRecordScreen() @@ -73,6 +74,23 @@ STARTTEST :let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times :$put =g:test :$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width) +:" +:" Test, that the string " a\tb\tc\td\te" is correctly +:" displayed in a 20 column wide window (see bug report +:" https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ +:only +:vert 20new +:set all& nocp breakindent briopt=min:10 +:call setline(1, [" a\tb\tc\td\te", " z y x w v"]) +:/^\s*a +fbgjyl:let line1 = @0 +:?^\s*z +fygjyl:let line2 = @0 +:quit! +:$put ='Test 12: breakindent with wrapping Tab' +:$put =line1 +:$put =line2 +:" :%w! test.out :qa! ENDTEST diff --git a/src/nvim/testdir/test_breakindent.ok b/src/nvim/testdir/test_breakindent.ok index 723cb25012..d89d424fb3 100644 --- a/src/nvim/testdir/test_breakindent.ok +++ b/src/nvim/testdir/test_breakindent.ok @@ -53,3 +53,6 @@ Test 4: Simple breakindent + min width: 18 Test 11: strdisplaywidth when breakindent is on strdisplaywidth: 46 == calculated: 64 +Test 12: breakindent with wrapping Tab +d +w diff --git a/src/nvim/testdir/test_qf_title.in b/src/nvim/testdir/test_qf_title.in new file mode 100644 index 0000000000..fce0c260e3 --- /dev/null +++ b/src/nvim/testdir/test_qf_title.in @@ -0,0 +1,18 @@ +Tests for quickfix window's title vim: set ft=vim : + +STARTTEST +:so small.vim +:if !has('quickfix') | e! test.ok | wq! test.out | endif +:set efm=%E%f:%l:%c:%m +:cgetexpr ['file:1:1:message'] +:let qflist=getqflist() +:call setqflist(qflist, 'r') +:copen +:let g:quickfix_title=w:quickfix_title +:wincmd p +:$put =g:quickfix_title +:/^Results/,$w test.out +:qa! +ENDTEST + +Results of test_qf_title: diff --git a/src/nvim/testdir/test_qf_title.ok b/src/nvim/testdir/test_qf_title.ok new file mode 100644 index 0000000000..4ebdbeff3b --- /dev/null +++ b/src/nvim/testdir/test_qf_title.ok @@ -0,0 +1,2 @@ +Results of test_qf_title: +:setqflist() diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 7a57f70498..2ab31b6cfd 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -80,6 +80,7 @@ #define UH_MAGIC 0x18dade /* value for uh_magic when in use */ #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ +#include <assert.h> #include <inttypes.h> #include <errno.h> #include <stdbool.h> @@ -369,11 +370,11 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload) size = bot - top - 1; /* - * If curbuf->b_u_synced == TRUE make a new header. + * If curbuf->b_u_synced == true make a new header. */ if (curbuf->b_u_synced) { /* Need to create new entry in b_changelist. */ - curbuf->b_new_change = TRUE; + curbuf->b_new_change = true; if (get_undolevel() >= 0) { /* @@ -424,7 +425,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload) if (uhp == NULL) { /* no undo at all */ if (old_curhead != NULL) u_freebranch(curbuf, old_curhead, NULL); - curbuf->b_u_synced = FALSE; + curbuf->b_u_synced = false; return OK; } @@ -510,7 +511,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload) * entry now. Following deleted/inserted lines go to * the re-used entry. */ u_getbot(); - curbuf->b_u_synced = FALSE; + curbuf->b_u_synced = false; /* Move the found entry to become the last entry. The * order of undo/redo doesn't matter for the entries @@ -581,7 +582,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload) uep->ue_array = NULL; uep->ue_next = curbuf->b_u_newhead->uh_entry; curbuf->b_u_newhead->uh_entry = uep; - curbuf->b_u_synced = FALSE; + curbuf->b_u_synced = false; undo_undoes = FALSE; #ifdef U_DEBUG @@ -1461,7 +1462,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name) curbuf->b_u_save_nr_last = last_save_nr; curbuf->b_u_save_nr_cur = last_save_nr; - curbuf->b_u_synced = TRUE; + curbuf->b_u_synced = true; free(uhp_table); #ifdef U_DEBUG @@ -1506,7 +1507,7 @@ void u_undo(int count) * original vi. If this happens twice in one macro the result will not * be compatible. */ - if (curbuf->b_u_synced == FALSE) { + if (curbuf->b_u_synced == false) { u_sync(TRUE); count = 1; } @@ -1618,7 +1619,7 @@ void undo_time(long step, int sec, int file, int absolute) int did_undo = TRUE; /* First make sure the current undoable change is synced. */ - if (curbuf->b_u_synced == FALSE) + if (curbuf->b_u_synced == false) u_sync(TRUE); u_newcount = 0; @@ -2219,7 +2220,7 @@ u_sync ( if (curbuf->b_u_synced || (!force && no_u_sync > 0)) return; if (get_undolevel() < 0) - curbuf->b_u_synced = TRUE; /* no entries, nothing to do */ + curbuf->b_u_synced = true; /* no entries, nothing to do */ else { u_getbot(); /* compute ue_bot of previous u_save */ curbuf->b_u_curhead = NULL; @@ -2354,7 +2355,7 @@ void ex_undojoin(exarg_T *eap) else { /* Go back to the last entry */ curbuf->b_u_curhead = curbuf->b_u_newhead; - curbuf->b_u_synced = FALSE; /* no entries, nothing to do */ + curbuf->b_u_synced = false; /* no entries, nothing to do */ } } @@ -2365,7 +2366,7 @@ void ex_undojoin(exarg_T *eap) void u_unchanged(buf_T *buf) { u_unch_branch(buf->b_u_oldhead); - buf->b_did_warn = FALSE; + buf->b_did_warn = false; } /* @@ -2446,7 +2447,7 @@ static u_entry_T *u_get_headentry(void) /* * u_getbot(): compute the line number of the previous u_save - * It is called only when b_u_synced is FALSE. + * It is called only when b_u_synced is false. */ static void u_getbot(void) { @@ -2477,7 +2478,7 @@ static void u_getbot(void) curbuf->b_u_newhead->uh_getbot_entry = NULL; } - curbuf->b_u_synced = TRUE; + curbuf->b_u_synced = true; } /* @@ -2602,7 +2603,7 @@ static void u_freeentry(u_entry_T *uep, long n) void u_clearall(buf_T *buf) { buf->b_u_newhead = buf->b_u_oldhead = buf->b_u_curhead = NULL; - buf->b_u_synced = TRUE; + buf->b_u_synced = true; buf->b_u_numhead = 0; buf->b_u_line_ptr = NULL; buf->b_u_line_lnum = 0; @@ -2682,8 +2683,11 @@ void u_undoline(void) */ void u_blockfree(buf_T *buf) { - while (buf->b_u_oldhead != NULL) + while (buf->b_u_oldhead != NULL) { + u_header_T *previous_oldhead = buf->b_u_oldhead; u_freeheader(buf, buf->b_u_oldhead, NULL); + assert(buf->b_u_oldhead != previous_oldhead); + } free(buf->b_u_line_ptr); } diff --git a/src/nvim/version.c b/src/nvim/version.c index 5b30dd3de7..c2818edcc5 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -228,7 +228,7 @@ static int included_patches[] = { 440, 439, //438, - //437, + 437, 436, //435, //434, @@ -244,12 +244,12 @@ static int included_patches[] = { //424 NA //423, //422, - //421, + 421, //420 NA 419, 418, - //417, - //416, + 417, + 416, 415, 414, //413 NA @@ -287,7 +287,7 @@ static int included_patches[] = { 381, //380 NA 379, - //378, + 378, 377, 376, 375, diff --git a/src/nvim/window.c b/src/nvim/window.c index fe40cd2a95..9345d740d1 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1849,19 +1849,19 @@ int win_close(win_T *win, int free_buf) */ if (wp->w_buffer != curbuf) { other_buffer = TRUE; - win->w_closing = TRUE; + win->w_closing = true; apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); if (!win_valid(win)) return FAIL; - win->w_closing = FALSE; + win->w_closing = false; if (last_window()) return FAIL; } - win->w_closing = TRUE; + win->w_closing = true; apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); if (!win_valid(win)) return FAIL; - win->w_closing = FALSE; + win->w_closing = false; if (last_window()) return FAIL; /* autocmds may abort script processing */ @@ -1878,10 +1878,10 @@ int win_close(win_T *win, int free_buf) * Close the link to the buffer. */ if (win->w_buffer != NULL) { - win->w_closing = TRUE; + win->w_closing = true; close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE); if (win_valid(win)) - win->w_closing = FALSE; + win->w_closing = false; } if (only_one_window() && win_valid(win) && win->w_buffer == NULL @@ -5404,7 +5404,7 @@ int match_add(win_T *wp, char_u *grp, char_u *pat, int prio, int id, list_T *pos wp->w_buffer->b_mod_bot = botlnum; } } else { - wp->w_buffer->b_mod_set = TRUE; + wp->w_buffer->b_mod_set = true; wp->w_buffer->b_mod_top = toplnum; wp->w_buffer->b_mod_bot = botlnum; wp->w_buffer->b_mod_xlines = 0; @@ -5478,7 +5478,7 @@ int match_delete(win_T *wp, int id, int perr) wp->w_buffer->b_mod_bot = cur->pos.botlnum; } } else { - wp->w_buffer->b_mod_set = TRUE; + wp->w_buffer->b_mod_set = true; wp->w_buffer->b_mod_top = cur->pos.toplnum; wp->w_buffer->b_mod_bot = cur->pos.botlnum; wp->w_buffer->b_mod_xlines = 0; |