mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 14:55:33 +00:00
Merge pull request #12073 from janlazo/vim-8.2.0027
vim-patch:8.1.{2366,2378,2387,2387},8.2.{27,560}
This commit is contained in:
@@ -253,7 +253,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
|
||||
if (execute) {
|
||||
int save_msg_scroll = msg_scroll;
|
||||
|
||||
/* Avoid a 1 second delay when the keys start Insert mode. */
|
||||
// Avoid a 1 second delay when the keys start Insert mode.
|
||||
msg_scroll = false;
|
||||
if (!dangerous) {
|
||||
ex_normal_busy++;
|
||||
|
||||
@@ -23,26 +23,26 @@
|
||||
#define NL '\012'
|
||||
#define NL_STR "\012"
|
||||
#define FF '\014'
|
||||
#define CAR '\015' /* CR is used by Mac OS X */
|
||||
#define CAR '\015' // CR is used by Mac OS X
|
||||
#define ESC '\033'
|
||||
#define ESC_STR "\033"
|
||||
#define DEL 0x7f
|
||||
#define DEL_STR "\177"
|
||||
#define CSI 0x9b // Control Sequence Introducer
|
||||
#define CSI_STR "\233"
|
||||
#define DCS 0x90 /* Device Control String */
|
||||
#define STERM 0x9c /* String Terminator */
|
||||
#define DCS 0x90 // Device Control String
|
||||
#define STERM 0x9c // String Terminator
|
||||
|
||||
#define POUND 0xA3
|
||||
|
||||
#define Ctrl_chr(x) (TOUPPER_ASC(x) ^ 0x40) /* '?' -> DEL, '@' -> ^@, etc. */
|
||||
#define Ctrl_chr(x) (TOUPPER_ASC(x) ^ 0x40) // '?' -> DEL, '@' -> ^@, etc.
|
||||
#define Meta(x) ((x) | 0x80)
|
||||
|
||||
#define CTRL_F_STR "\006"
|
||||
#define CTRL_H_STR "\010"
|
||||
#define CTRL_V_STR "\026"
|
||||
|
||||
#define Ctrl_AT 0 /* @ */
|
||||
#define Ctrl_AT 0 // @
|
||||
#define Ctrl_A 1
|
||||
#define Ctrl_B 2
|
||||
#define Ctrl_C 3
|
||||
@@ -69,16 +69,14 @@
|
||||
#define Ctrl_X 24
|
||||
#define Ctrl_Y 25
|
||||
#define Ctrl_Z 26
|
||||
/* CTRL- [ Left Square Bracket == ESC*/
|
||||
#define Ctrl_BSL 28 /* \ BackSLash */
|
||||
#define Ctrl_RSB 29 /* ] Right Square Bracket */
|
||||
#define Ctrl_HAT 30 /* ^ */
|
||||
// CTRL- [ Left Square Bracket == ESC
|
||||
#define Ctrl_BSL 28 // \ BackSLash
|
||||
#define Ctrl_RSB 29 // ] Right Square Bracket
|
||||
#define Ctrl_HAT 30 // ^
|
||||
#define Ctrl__ 31
|
||||
|
||||
|
||||
/*
|
||||
* Character that separates dir names in a path.
|
||||
*/
|
||||
// Character that separates dir names in a path.
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
# define PATHSEP psepc
|
||||
# define PATHSEPSTR pseps
|
||||
@@ -168,4 +166,4 @@ static inline bool ascii_isspace(int c)
|
||||
return (c >= 9 && c <= 13) || c == ' ';
|
||||
}
|
||||
|
||||
#endif /* NVIM_ASCII_H */
|
||||
#endif // NVIM_ASCII_H
|
||||
|
||||
@@ -67,14 +67,14 @@ typedef struct {
|
||||
* off off w_botline not valid
|
||||
* on off not possible
|
||||
*/
|
||||
#define VALID_WROW 0x01 /* w_wrow (window row) is valid */
|
||||
#define VALID_WCOL 0x02 /* w_wcol (window col) is valid */
|
||||
#define VALID_VIRTCOL 0x04 /* w_virtcol (file col) is valid */
|
||||
#define VALID_CHEIGHT 0x08 /* w_cline_height and w_cline_folded valid */
|
||||
#define VALID_CROW 0x10 /* w_cline_row is valid */
|
||||
#define VALID_BOTLINE 0x20 /* w_botine and w_empty_rows are valid */
|
||||
#define VALID_BOTLINE_AP 0x40 /* w_botine is approximated */
|
||||
#define VALID_TOPLINE 0x80 /* w_topline is valid (for cursor position) */
|
||||
#define VALID_WROW 0x01 // w_wrow (window row) is valid
|
||||
#define VALID_WCOL 0x02 // w_wcol (window col) is valid
|
||||
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
|
||||
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
|
||||
#define VALID_CROW 0x10 // w_cline_row is valid
|
||||
#define VALID_BOTLINE 0x20 // w_botine and w_empty_rows are valid
|
||||
#define VALID_BOTLINE_AP 0x40 // w_botine is approximated
|
||||
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
|
||||
|
||||
// flags for b_flags
|
||||
#define BF_RECOVERED 0x01 // buffer has been recovered
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
#define BF_DUMMY 0x80 // dummy buffer, only used internally
|
||||
#define BF_PRESERVED 0x100 // ":preserve" was used
|
||||
|
||||
/* Mask to check for flags that prevent normal writing */
|
||||
// Mask to check for flags that prevent normal writing
|
||||
#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR)
|
||||
|
||||
typedef struct window_S win_T;
|
||||
@@ -160,11 +160,11 @@ typedef struct
|
||||
*/
|
||||
typedef struct {
|
||||
int wo_arab;
|
||||
# define w_p_arab w_onebuf_opt.wo_arab /* 'arabic' */
|
||||
# define w_p_arab w_onebuf_opt.wo_arab // 'arabic'
|
||||
int wo_bri;
|
||||
# define w_p_bri w_onebuf_opt.wo_bri // 'breakindent'
|
||||
char_u *wo_briopt;
|
||||
# define w_p_briopt w_onebuf_opt.wo_briopt /* 'breakindentopt' */
|
||||
# define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt'
|
||||
int wo_diff;
|
||||
# define w_p_diff w_onebuf_opt.wo_diff // 'diff'
|
||||
char_u *wo_fdc;
|
||||
@@ -172,78 +172,80 @@ typedef struct {
|
||||
char_u *wo_fdc_save;
|
||||
# define w_p_fdc_save w_onebuf_opt.wo_fdc_save // 'fdc' saved for diff mode
|
||||
int wo_fen;
|
||||
# define w_p_fen w_onebuf_opt.wo_fen /* 'foldenable' */
|
||||
# define w_p_fen w_onebuf_opt.wo_fen // 'foldenable'
|
||||
int wo_fen_save;
|
||||
# define w_p_fen_save w_onebuf_opt.wo_fen_save /* 'foldenable' saved for diff mode */
|
||||
// 'foldenable' saved for diff mode
|
||||
# define w_p_fen_save w_onebuf_opt.wo_fen_save
|
||||
char_u *wo_fdi;
|
||||
# define w_p_fdi w_onebuf_opt.wo_fdi /* 'foldignore' */
|
||||
# define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore'
|
||||
long wo_fdl;
|
||||
# define w_p_fdl w_onebuf_opt.wo_fdl /* 'foldlevel' */
|
||||
# define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel'
|
||||
int wo_fdl_save;
|
||||
# define w_p_fdl_save w_onebuf_opt.wo_fdl_save /* 'foldlevel' state saved for diff mode */
|
||||
// 'foldlevel' state saved for diff mode
|
||||
# define w_p_fdl_save w_onebuf_opt.wo_fdl_save
|
||||
char_u *wo_fdm;
|
||||
# define w_p_fdm w_onebuf_opt.wo_fdm /* 'foldmethod' */
|
||||
# define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod'
|
||||
char_u *wo_fdm_save;
|
||||
# define w_p_fdm_save w_onebuf_opt.wo_fdm_save /* 'fdm' saved for diff mode */
|
||||
# define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode
|
||||
long wo_fml;
|
||||
# define w_p_fml w_onebuf_opt.wo_fml /* 'foldminlines' */
|
||||
# define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines'
|
||||
long wo_fdn;
|
||||
# define w_p_fdn w_onebuf_opt.wo_fdn /* 'foldnestmax' */
|
||||
# define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax'
|
||||
char_u *wo_fde;
|
||||
# define w_p_fde w_onebuf_opt.wo_fde /* 'foldexpr' */
|
||||
# define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
|
||||
char_u *wo_fdt;
|
||||
# define w_p_fdt w_onebuf_opt.wo_fdt /* 'foldtext' */
|
||||
# define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext'
|
||||
char_u *wo_fmr;
|
||||
# define w_p_fmr w_onebuf_opt.wo_fmr /* 'foldmarker' */
|
||||
# define w_p_fmr w_onebuf_opt.wo_fmr // 'foldmarker'
|
||||
int wo_lbr;
|
||||
# define w_p_lbr w_onebuf_opt.wo_lbr /* 'linebreak' */
|
||||
# define w_p_lbr w_onebuf_opt.wo_lbr // 'linebreak'
|
||||
int wo_list;
|
||||
#define w_p_list w_onebuf_opt.wo_list /* 'list' */
|
||||
#define w_p_list w_onebuf_opt.wo_list // 'list'
|
||||
int wo_nu;
|
||||
#define w_p_nu w_onebuf_opt.wo_nu /* 'number' */
|
||||
#define w_p_nu w_onebuf_opt.wo_nu // 'number'
|
||||
int wo_rnu;
|
||||
#define w_p_rnu w_onebuf_opt.wo_rnu /* 'relativenumber' */
|
||||
#define w_p_rnu w_onebuf_opt.wo_rnu // 'relativenumber'
|
||||
long wo_nuw;
|
||||
# define w_p_nuw w_onebuf_opt.wo_nuw /* 'numberwidth' */
|
||||
# define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth'
|
||||
int wo_wfh;
|
||||
# define w_p_wfh w_onebuf_opt.wo_wfh /* 'winfixheight' */
|
||||
# define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
|
||||
int wo_wfw;
|
||||
# define w_p_wfw w_onebuf_opt.wo_wfw /* 'winfixwidth' */
|
||||
# define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
|
||||
int wo_pvw;
|
||||
# define w_p_pvw w_onebuf_opt.wo_pvw /* 'previewwindow' */
|
||||
# define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow'
|
||||
int wo_rl;
|
||||
# define w_p_rl w_onebuf_opt.wo_rl /* 'rightleft' */
|
||||
# define w_p_rl w_onebuf_opt.wo_rl // 'rightleft'
|
||||
char_u *wo_rlc;
|
||||
# define w_p_rlc w_onebuf_opt.wo_rlc /* 'rightleftcmd' */
|
||||
# define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd'
|
||||
long wo_scr;
|
||||
#define w_p_scr w_onebuf_opt.wo_scr /* 'scroll' */
|
||||
#define w_p_scr w_onebuf_opt.wo_scr // 'scroll'
|
||||
int wo_spell;
|
||||
# define w_p_spell w_onebuf_opt.wo_spell /* 'spell' */
|
||||
# define w_p_spell w_onebuf_opt.wo_spell // 'spell'
|
||||
int wo_cuc;
|
||||
# define w_p_cuc w_onebuf_opt.wo_cuc /* 'cursorcolumn' */
|
||||
# define w_p_cuc w_onebuf_opt.wo_cuc // 'cursorcolumn'
|
||||
int wo_cul;
|
||||
# define w_p_cul w_onebuf_opt.wo_cul /* 'cursorline' */
|
||||
# define w_p_cul w_onebuf_opt.wo_cul // 'cursorline'
|
||||
char_u *wo_cc;
|
||||
# define w_p_cc w_onebuf_opt.wo_cc /* 'colorcolumn' */
|
||||
# define w_p_cc w_onebuf_opt.wo_cc // 'colorcolumn'
|
||||
char_u *wo_stl;
|
||||
#define w_p_stl w_onebuf_opt.wo_stl /* 'statusline' */
|
||||
#define w_p_stl w_onebuf_opt.wo_stl // 'statusline'
|
||||
int wo_scb;
|
||||
# define w_p_scb w_onebuf_opt.wo_scb /* 'scrollbind' */
|
||||
int wo_diff_saved; /* options were saved for starting diff mode */
|
||||
# define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind'
|
||||
int wo_diff_saved; // options were saved for starting diff mode
|
||||
# define w_p_diff_saved w_onebuf_opt.wo_diff_saved
|
||||
int wo_scb_save; /* 'scrollbind' saved for diff mode*/
|
||||
int wo_scb_save; // 'scrollbind' saved for diff mode
|
||||
# define w_p_scb_save w_onebuf_opt.wo_scb_save
|
||||
int wo_wrap;
|
||||
#define w_p_wrap w_onebuf_opt.wo_wrap /* 'wrap' */
|
||||
int wo_wrap_save; /* 'wrap' state saved for diff mode*/
|
||||
#define w_p_wrap w_onebuf_opt.wo_wrap // 'wrap'
|
||||
int wo_wrap_save; // 'wrap' state saved for diff mode
|
||||
# define w_p_wrap_save w_onebuf_opt.wo_wrap_save
|
||||
char_u *wo_cocu; /* 'concealcursor' */
|
||||
char_u *wo_cocu; // 'concealcursor'
|
||||
# define w_p_cocu w_onebuf_opt.wo_cocu
|
||||
long wo_cole; /* 'conceallevel' */
|
||||
long wo_cole; // 'conceallevel'
|
||||
# define w_p_cole w_onebuf_opt.wo_cole
|
||||
int wo_crb;
|
||||
# define w_p_crb w_onebuf_opt.wo_crb /* 'cursorbind' */
|
||||
int wo_crb_save; /* 'cursorbind' state saved for diff mode*/
|
||||
# define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind'
|
||||
int wo_crb_save; // 'cursorbind' state saved for diff mode
|
||||
# define w_p_crb_save w_onebuf_opt.wo_crb_save
|
||||
char_u *wo_scl;
|
||||
# define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn'
|
||||
@@ -271,14 +273,14 @@ typedef struct {
|
||||
* most-recently-used order.
|
||||
*/
|
||||
struct wininfo_S {
|
||||
wininfo_T *wi_next; /* next entry or NULL for last entry */
|
||||
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 */
|
||||
bool wi_optset; /* true when wi_opt has useful values */
|
||||
winopt_T wi_opt; /* local window options */
|
||||
bool wi_fold_manual; /* copy of w_fold_manual */
|
||||
garray_T wi_folds; /* clone of w_folds */
|
||||
wininfo_T *wi_next; // next entry or NULL for last entry
|
||||
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
|
||||
bool wi_optset; // true when wi_opt has useful values
|
||||
winopt_T wi_opt; // local window options
|
||||
bool wi_fold_manual; // copy of w_fold_manual
|
||||
garray_T wi_folds; // clone of w_folds
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -288,8 +290,8 @@ struct wininfo_S {
|
||||
* TODO: move struct arglist to another header
|
||||
*/
|
||||
typedef struct arglist {
|
||||
garray_T al_ga; /* growarray with the array of file names */
|
||||
int al_refcount; /* number of windows using this arglist */
|
||||
garray_T al_ga; // growarray with the array of file names
|
||||
int al_refcount; // number of windows using this arglist
|
||||
int id; ///< id of this arglist
|
||||
} alist_T;
|
||||
|
||||
@@ -301,8 +303,8 @@ typedef struct arglist {
|
||||
* TODO: move aentry_T to another header
|
||||
*/
|
||||
typedef struct argentry {
|
||||
char_u *ae_fname; /* file name as specified */
|
||||
int ae_fnum; /* buffer number with expanded file name */
|
||||
char_u *ae_fname; // file name as specified
|
||||
int ae_fnum; // buffer number with expanded file name
|
||||
} aentry_T;
|
||||
|
||||
# define ALIST(win) (win)->w_alist
|
||||
@@ -318,21 +320,21 @@ typedef struct argentry {
|
||||
* Used for the typeahead buffer: typebuf.
|
||||
*/
|
||||
typedef struct {
|
||||
char_u *tb_buf; /* buffer for typed characters */
|
||||
char_u *tb_noremap; /* mapping flags for characters in tb_buf[] */
|
||||
int tb_buflen; /* size of tb_buf[] */
|
||||
int tb_off; /* current position in tb_buf[] */
|
||||
int tb_len; /* number of valid bytes in tb_buf[] */
|
||||
int tb_maplen; /* nr of mapped bytes in tb_buf[] */
|
||||
int tb_silent; /* nr of silently mapped bytes in tb_buf[] */
|
||||
int tb_no_abbr_cnt; /* nr of bytes without abbrev. in tb_buf[] */
|
||||
int tb_change_cnt; /* nr of time tb_buf was changed; never zero */
|
||||
char_u *tb_buf; // buffer for typed characters
|
||||
char_u *tb_noremap; // mapping flags for characters in tb_buf[]
|
||||
int tb_buflen; // size of tb_buf[]
|
||||
int tb_off; // current position in tb_buf[]
|
||||
int tb_len; // number of valid bytes in tb_buf[]
|
||||
int tb_maplen; // nr of mapped bytes in tb_buf[]
|
||||
int tb_silent; // nr of silently mapped bytes in tb_buf[]
|
||||
int tb_no_abbr_cnt; // nr of bytes without abbrev. in tb_buf[]
|
||||
int tb_change_cnt; // nr of time tb_buf was changed; never zero
|
||||
} typebuf_T;
|
||||
|
||||
/* Struct to hold the saved typeahead for save_typeahead(). */
|
||||
// Struct to hold the saved typeahead for save_typeahead().
|
||||
typedef struct {
|
||||
typebuf_T save_typebuf;
|
||||
int typebuf_valid; /* TRUE when save_typebuf valid */
|
||||
int typebuf_valid; // TRUE when save_typebuf valid
|
||||
int old_char;
|
||||
int old_mod_mask;
|
||||
buffheader_T save_readbuf1;
|
||||
@@ -363,15 +365,15 @@ struct mapblock {
|
||||
*/
|
||||
struct stl_hlrec {
|
||||
char_u *start;
|
||||
int userhl; /* 0: no HL, 1-9: User HL, < 0 for syn ID */
|
||||
int userhl; // 0: no HL, 1-9: User HL, < 0 for syn ID
|
||||
};
|
||||
|
||||
/* values for b_syn_spell: what to do with toplevel text */
|
||||
#define SYNSPL_DEFAULT 0 /* spell check if @Spell not defined */
|
||||
#define SYNSPL_TOP 1 /* spell check toplevel text */
|
||||
#define SYNSPL_NOTOP 2 /* don't spell check toplevel text */
|
||||
// values for b_syn_spell: what to do with toplevel text
|
||||
#define SYNSPL_DEFAULT 0 // spell check if @Spell not defined
|
||||
#define SYNSPL_TOP 1 // spell check toplevel text
|
||||
#define SYNSPL_NOTOP 2 // don't spell check toplevel text
|
||||
|
||||
/* avoid #ifdefs for when b_spell is not available */
|
||||
// avoid #ifdefs for when b_spell is not available
|
||||
# define B_SPELL(buf) ((buf)->b_spell)
|
||||
|
||||
typedef struct qf_info_S qf_info_T;
|
||||
@@ -380,10 +382,10 @@ typedef struct qf_info_S qf_info_T;
|
||||
* Used for :syntime: timing of executing a syntax pattern.
|
||||
*/
|
||||
typedef struct {
|
||||
proftime_T total; /* total time used */
|
||||
proftime_T slowest; /* time of slowest call */
|
||||
long count; /* nr of times used */
|
||||
long match; /* nr of times matched */
|
||||
proftime_T total; // total time used
|
||||
proftime_T slowest; // time of slowest call
|
||||
long count; // nr of times used
|
||||
long match; // nr of times matched
|
||||
} syn_time_T;
|
||||
|
||||
/*
|
||||
@@ -411,25 +413,23 @@ typedef struct {
|
||||
char_u *b_syn_linecont_pat; // line continuation pattern
|
||||
regprog_T *b_syn_linecont_prog; // line continuation program
|
||||
syn_time_T b_syn_linecont_time;
|
||||
int b_syn_linecont_ic; /* ignore-case flag for above */
|
||||
int b_syn_topgrp; /* for ":syntax include" */
|
||||
int b_syn_conceal; /* auto-conceal for :syn cmds */
|
||||
int b_syn_folditems; /* number of patterns with the HL_FOLD
|
||||
flag set */
|
||||
/*
|
||||
* b_sst_array[] contains the state stack for a number of lines, for the
|
||||
* start of that line (col == 0). This avoids having to recompute the
|
||||
* syntax state too often.
|
||||
* b_sst_array[] is allocated to hold the state for all displayed lines,
|
||||
* and states for 1 out of about 20 other lines.
|
||||
* b_sst_array pointer to an array of synstate_T
|
||||
* b_sst_len number of entries in b_sst_array[]
|
||||
* b_sst_first pointer to first used entry in b_sst_array[] or NULL
|
||||
* b_sst_firstfree pointer to first free entry in b_sst_array[] or NULL
|
||||
* b_sst_freecount number of free entries in b_sst_array[]
|
||||
* b_sst_check_lnum entries after this lnum need to be checked for
|
||||
* validity (MAXLNUM means no check needed)
|
||||
*/
|
||||
int b_syn_linecont_ic; // ignore-case flag for above
|
||||
int b_syn_topgrp; // for ":syntax include"
|
||||
int b_syn_conceal; // auto-conceal for :syn cmds
|
||||
int b_syn_folditems; // number of patterns with the HL_FOLD
|
||||
// flag set
|
||||
// b_sst_array[] contains the state stack for a number of lines, for the
|
||||
// start of that line (col == 0). This avoids having to recompute the
|
||||
// syntax state too often.
|
||||
// b_sst_array[] is allocated to hold the state for all displayed lines,
|
||||
// and states for 1 out of about 20 other lines.
|
||||
// b_sst_array pointer to an array of synstate_T
|
||||
// b_sst_len number of entries in b_sst_array[]
|
||||
// b_sst_first pointer to first used entry in b_sst_array[] or NULL
|
||||
// b_sst_firstfree pointer to first free entry in b_sst_array[] or NULL
|
||||
// b_sst_freecount number of free entries in b_sst_array[]
|
||||
// b_sst_check_lnum entries after this lnum need to be checked for
|
||||
// validity (MAXLNUM means no check needed)
|
||||
synstate_T *b_sst_array;
|
||||
int b_sst_len;
|
||||
synstate_T *b_sst_first;
|
||||
@@ -488,10 +488,10 @@ struct file_buffer {
|
||||
|
||||
memline_T b_ml; // associated memline (also contains line count
|
||||
|
||||
buf_T *b_next; /* links in list of buffers */
|
||||
buf_T *b_next; // links in list of buffers
|
||||
buf_T *b_prev;
|
||||
|
||||
int b_nwindows; /* nr of windows open on this buffer */
|
||||
int b_nwindows; // nr of windows open on this buffer
|
||||
|
||||
int b_flags; // various BF_ flags
|
||||
int b_locked; // Buffer is being closed or referenced, don't
|
||||
@@ -532,24 +532,23 @@ struct file_buffer {
|
||||
*/
|
||||
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
|
||||
change */
|
||||
long b_mod_xlines; /* number of extra buffer lines inserted;
|
||||
negative when lines were deleted */
|
||||
linenr_T b_mod_top; // topmost lnum that was changed
|
||||
linenr_T b_mod_bot; // lnum below last changed line, AFTER the
|
||||
// change
|
||||
long b_mod_xlines; // number of extra buffer lines inserted;
|
||||
// negative when lines were deleted
|
||||
wininfo_T *b_wininfo; // list of last used info for each window
|
||||
|
||||
wininfo_T *b_wininfo; /* list of last used info for each window */
|
||||
long b_mtime; // last change time of original file
|
||||
long b_mtime_read; // last change time when reading
|
||||
uint64_t b_orig_size; // size of original file in bytes
|
||||
int b_orig_mode; // mode of original file
|
||||
|
||||
long b_mtime; /* last change time of original file */
|
||||
long b_mtime_read; /* last change time when reading */
|
||||
uint64_t b_orig_size; /* size of original file in bytes */
|
||||
int b_orig_mode; /* mode of original file */
|
||||
fmark_T b_namedm[NMARKS]; // current named marks (mark.c)
|
||||
|
||||
fmark_T b_namedm[NMARKS]; /* current named marks (mark.c) */
|
||||
|
||||
/* These variables are set when VIsual_active becomes FALSE */
|
||||
// These variables are set when VIsual_active becomes FALSE
|
||||
visualinfo_T b_visual;
|
||||
int b_visual_mode_eval; /* b_visual.vi_mode for visualmode() */
|
||||
int b_visual_mode_eval; // b_visual.vi_mode for visualmode()
|
||||
|
||||
fmark_T b_last_cursor; // cursor position when last unloading this
|
||||
// buffer
|
||||
@@ -560,8 +559,8 @@ struct file_buffer {
|
||||
* the changelist contains old change positions
|
||||
*/
|
||||
fmark_T b_changelist[JUMPLISTSIZE];
|
||||
int b_changelistlen; /* number of active entries */
|
||||
bool b_new_change; /* set by u_savecommon() */
|
||||
int b_changelistlen; // number of active entries
|
||||
bool b_new_change; // set by u_savecommon()
|
||||
|
||||
/*
|
||||
* Character table, only used in charset.c for 'iskeyword'
|
||||
@@ -572,9 +571,9 @@ struct file_buffer {
|
||||
// Table used for mappings local to a buffer.
|
||||
mapblock_T *(b_maphash[MAX_MAPHASH]);
|
||||
|
||||
/* First abbreviation local to a buffer. */
|
||||
// First abbreviation local to a buffer.
|
||||
mapblock_T *b_first_abbr;
|
||||
/* User commands local to the buffer. */
|
||||
// User commands local to the buffer.
|
||||
garray_T b_ucmds;
|
||||
/*
|
||||
* start and end of an operator, also used for '[ and ']
|
||||
@@ -583,31 +582,31 @@ struct file_buffer {
|
||||
pos_T b_op_start_orig; // used for Insstart_orig
|
||||
pos_T b_op_end;
|
||||
|
||||
bool b_marks_read; /* Have we read ShaDa marks yet? */
|
||||
bool b_marks_read; // Have we read ShaDa marks yet?
|
||||
|
||||
/*
|
||||
* The following only used in undo.c.
|
||||
*/
|
||||
u_header_T *b_u_oldhead; /* pointer to oldest header */
|
||||
u_header_T *b_u_newhead; /* pointer to newest header; may not be valid
|
||||
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 */
|
||||
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 */
|
||||
time_t b_u_time_cur; /* uh_time of header below which we are now */
|
||||
long b_u_save_nr_cur; /* file write nr after which we are now */
|
||||
u_header_T *b_u_oldhead; // pointer to oldest header
|
||||
u_header_T *b_u_newhead; // pointer to newest header; may not be valid
|
||||
// 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
|
||||
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
|
||||
time_t b_u_time_cur; // uh_time of header below which we are now
|
||||
long b_u_save_nr_cur; // file write nr after which we are now
|
||||
|
||||
/*
|
||||
* variables for "U" command in undo.c
|
||||
*/
|
||||
char_u *b_u_line_ptr; /* saved line for "U" command */
|
||||
linenr_T b_u_line_lnum; /* line number of line in u_line */
|
||||
colnr_T b_u_line_colnr; /* optional column number */
|
||||
char_u *b_u_line_ptr; // saved line for "U" command
|
||||
linenr_T b_u_line_lnum; // line number of line in u_line
|
||||
colnr_T b_u_line_colnr; // optional column number
|
||||
|
||||
bool 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
|
||||
@@ -617,10 +616,10 @@ struct file_buffer {
|
||||
#define B_IMODE_LMAP 1 // Input via langmap
|
||||
# define B_IMODE_LAST 1
|
||||
|
||||
short b_kmap_state; /* using "lmap" mappings */
|
||||
# define KEYMAP_INIT 1 /* 'keymap' was set, call keymap_init() */
|
||||
# define KEYMAP_LOADED 2 /* 'keymap' mappings have been loaded */
|
||||
garray_T b_kmap_ga; /* the keymap table */
|
||||
int16_t b_kmap_state; // using "lmap" mappings
|
||||
# define KEYMAP_INIT 1 // 'keymap' was set, call keymap_init()
|
||||
# define KEYMAP_LOADED 2 // 'keymap' mappings have been loaded
|
||||
garray_T b_kmap_ga; // the keymap table
|
||||
|
||||
/*
|
||||
* Options local to a buffer.
|
||||
@@ -720,9 +719,9 @@ struct file_buffer {
|
||||
int b_p_udf; ///< 'undofile'
|
||||
char_u *b_p_lw; ///< 'lispwords' local value
|
||||
|
||||
/* end of buffer options */
|
||||
// end of buffer options
|
||||
|
||||
/* values set from b_p_cino */
|
||||
// values set from b_p_cino
|
||||
int b_ind_level;
|
||||
int b_ind_open_imag;
|
||||
int b_ind_no_brace;
|
||||
@@ -763,11 +762,11 @@ struct file_buffer {
|
||||
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary
|
||||
* write should not have an end-of-line */
|
||||
|
||||
int b_start_eol; /* last line had eol when it was read */
|
||||
int b_start_ffc; /* first char of 'ff' when edit started */
|
||||
char_u *b_start_fenc; /* 'fileencoding' when edit started or NULL */
|
||||
int b_bad_char; /* "++bad=" argument when edit started or 0 */
|
||||
int b_start_bomb; /* 'bomb' when it was read */
|
||||
int b_start_eol; // last line had eol when it was read
|
||||
int b_start_ffc; // first char of 'ff' when edit started
|
||||
char_u *b_start_fenc; // 'fileencoding' when edit started or NULL
|
||||
int b_bad_char; // "++bad=" argument when edit started or 0
|
||||
int b_start_bomb; // 'bomb' when it was read
|
||||
|
||||
ScopeDictDictItem b_bufvar; ///< Variable for "b:" Dictionary.
|
||||
dict_T *b_vars; ///< b: scope dictionary.
|
||||
@@ -866,8 +865,8 @@ struct file_buffer {
|
||||
typedef struct diffblock_S diff_T;
|
||||
struct diffblock_S {
|
||||
diff_T *df_next;
|
||||
linenr_T df_lnum[DB_COUNT]; /* line number in buffer */
|
||||
linenr_T df_count[DB_COUNT]; /* nr of inserted/changed lines */
|
||||
linenr_T df_lnum[DB_COUNT]; // line number in buffer
|
||||
linenr_T df_count[DB_COUNT]; // nr of inserted/changed lines
|
||||
};
|
||||
|
||||
#define SNAP_HELP_IDX 0
|
||||
@@ -915,11 +914,11 @@ struct tabpage_S {
|
||||
* wl_lnum and wl_lastlnum are invalid too.
|
||||
*/
|
||||
typedef struct w_line {
|
||||
linenr_T wl_lnum; /* buffer line number for logical line */
|
||||
uint16_t wl_size; /* height in screen lines */
|
||||
char wl_valid; /* TRUE values are valid for text in buffer */
|
||||
char wl_folded; /* TRUE when this is a range of folded lines */
|
||||
linenr_T wl_lastlnum; /* last buffer line number for logical line */
|
||||
linenr_T wl_lnum; // buffer line number for logical line
|
||||
uint16_t wl_size; // height in screen lines
|
||||
char wl_valid; // TRUE values are valid for text in buffer
|
||||
char wl_folded; // TRUE when this is a range of folded lines
|
||||
linenr_T wl_lastlnum; // last buffer line number for logical line
|
||||
} wline_T;
|
||||
|
||||
/*
|
||||
@@ -942,9 +941,9 @@ struct frame_S {
|
||||
win_T *fr_win; // window that fills this frame
|
||||
};
|
||||
|
||||
#define FR_LEAF 0 /* frame is a leaf */
|
||||
#define FR_ROW 1 /* frame with a row of windows */
|
||||
#define FR_COL 2 /* frame with a column of windows */
|
||||
#define FR_LEAF 0 // frame is a leaf
|
||||
#define FR_ROW 1 // frame with a row of windows
|
||||
#define FR_COL 2 // frame with a column of windows
|
||||
|
||||
/*
|
||||
* Struct used for highlighting 'hlsearch' matches, matches defined by
|
||||
@@ -1145,16 +1144,16 @@ struct window_S {
|
||||
top of the window */
|
||||
char w_topline_was_set; /* flag set to TRUE when topline is set,
|
||||
e.g. by winrestview() */
|
||||
int w_topfill; /* number of filler lines above w_topline */
|
||||
int w_old_topfill; /* w_topfill at last redraw */
|
||||
bool w_botfill; /* true when filler lines are actually
|
||||
below w_topline (at end of file) */
|
||||
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 */
|
||||
colnr_T w_skipcol; /* starting column when a single line
|
||||
doesn't fit in the window */
|
||||
int w_topfill; // number of filler lines above w_topline
|
||||
int w_old_topfill; // w_topfill at last redraw
|
||||
bool w_botfill; // true when filler lines are actually
|
||||
// below w_topline (at end of file)
|
||||
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
|
||||
colnr_T w_skipcol; // starting column when a single line
|
||||
// doesn't fit in the window
|
||||
|
||||
//
|
||||
// Layout of the window in the screen.
|
||||
@@ -1188,7 +1187,7 @@ struct window_S {
|
||||
int w_valid;
|
||||
pos_T w_valid_cursor; /* last known position of w_cursor, used
|
||||
to adjust w_valid */
|
||||
colnr_T w_valid_leftcol; /* last known w_leftcol */
|
||||
colnr_T w_valid_leftcol; // last known w_leftcol
|
||||
|
||||
bool w_viewport_invalid;
|
||||
|
||||
@@ -1196,10 +1195,10 @@ struct window_S {
|
||||
* w_cline_height is the number of physical lines taken by the buffer line
|
||||
* that the cursor is on. We use this to avoid extra calls to plines().
|
||||
*/
|
||||
int w_cline_height; /* current size of cursor line */
|
||||
bool w_cline_folded; /* cursor line is folded */
|
||||
int w_cline_height; // current size of cursor line
|
||||
bool w_cline_folded; // cursor line is folded
|
||||
|
||||
int w_cline_row; /* starting row of the cursor line */
|
||||
int w_cline_row; // starting row of the cursor line
|
||||
|
||||
colnr_T w_virtcol; // column number of the cursor in the
|
||||
// buffer line, as opposed to the column
|
||||
@@ -1213,7 +1212,7 @@ struct window_S {
|
||||
* This is related to positions in the window, not in the display or
|
||||
* buffer, thus w_wrow is relative to w_winrow.
|
||||
*/
|
||||
int w_wrow, w_wcol; /* cursor position in window */
|
||||
int w_wrow, w_wcol; // cursor position in window
|
||||
|
||||
linenr_T w_botline; // number of the line below the bottom of
|
||||
// the window
|
||||
@@ -1231,42 +1230,42 @@ struct window_S {
|
||||
* what is currently displayed. wl_valid is reset to indicated this.
|
||||
* This is used for efficient redrawing.
|
||||
*/
|
||||
int w_lines_valid; /* number of valid entries */
|
||||
int w_lines_valid; // number of valid entries
|
||||
wline_T *w_lines;
|
||||
|
||||
garray_T w_folds; /* array of nested folds */
|
||||
bool w_fold_manual; /* when true: some folds are opened/closed
|
||||
manually */
|
||||
bool w_foldinvalid; /* when true: folding needs to be
|
||||
recomputed */
|
||||
int w_nrwidth; /* width of 'number' and 'relativenumber'
|
||||
column being used */
|
||||
garray_T w_folds; // array of nested folds
|
||||
bool w_fold_manual; // when true: some folds are opened/closed
|
||||
// manually
|
||||
bool w_foldinvalid; // when true: folding needs to be
|
||||
// recomputed
|
||||
int w_nrwidth; // width of 'number' and 'relativenumber'
|
||||
// column being used
|
||||
|
||||
/*
|
||||
* === end of cached values ===
|
||||
*/
|
||||
|
||||
int w_redr_type; /* type of redraw to be performed on win */
|
||||
int w_upd_rows; /* number of window lines to update when
|
||||
w_redr_type is REDRAW_TOP */
|
||||
linenr_T w_redraw_top; /* when != 0: first line needing redraw */
|
||||
linenr_T w_redraw_bot; /* when != 0: last line needing redraw */
|
||||
int w_redr_status; /* if TRUE status line must be redrawn */
|
||||
int w_redr_type; // type of redraw to be performed on win
|
||||
int w_upd_rows; // number of window lines to update when
|
||||
// w_redr_type is REDRAW_TOP
|
||||
linenr_T w_redraw_top; // when != 0: first line needing redraw
|
||||
linenr_T w_redraw_bot; // when != 0: last line needing redraw
|
||||
int w_redr_status; // if TRUE status line must be redrawn
|
||||
|
||||
/* remember what is shown in the ruler for this window (if 'ruler' set) */
|
||||
pos_T w_ru_cursor; /* cursor position shown in ruler */
|
||||
colnr_T w_ru_virtcol; /* virtcol shown in ruler */
|
||||
linenr_T w_ru_topline; /* topline shown in ruler */
|
||||
linenr_T w_ru_line_count; /* line count used for ruler */
|
||||
int w_ru_topfill; /* topfill shown in ruler */
|
||||
char w_ru_empty; /* TRUE if ruler shows 0-1 (empty line) */
|
||||
// remember what is shown in the ruler for this window (if 'ruler' set)
|
||||
pos_T w_ru_cursor; // cursor position shown in ruler
|
||||
colnr_T w_ru_virtcol; // virtcol shown in ruler
|
||||
linenr_T w_ru_topline; // topline shown in ruler
|
||||
linenr_T w_ru_line_count; // line count used for ruler
|
||||
int w_ru_topfill; // topfill shown in ruler
|
||||
char w_ru_empty; // TRUE if ruler shows 0-1 (empty line)
|
||||
|
||||
int w_alt_fnum; /* alternate file (for # and CTRL-^) */
|
||||
int w_alt_fnum; // alternate file (for # and CTRL-^)
|
||||
|
||||
alist_T *w_alist; /* pointer to arglist for this window */
|
||||
int w_arg_idx; /* current index in argument list (can be
|
||||
out of range!) */
|
||||
int w_arg_idx_invalid; /* editing another file than w_arg_idx */
|
||||
alist_T *w_alist; // pointer to arglist for this window
|
||||
int w_arg_idx; // current index in argument list (can be
|
||||
// out of range!)
|
||||
int w_arg_idx_invalid; // editing another file than w_arg_idx
|
||||
|
||||
char_u *w_localdir; /* absolute path of local directory or
|
||||
NULL */
|
||||
@@ -1304,20 +1303,20 @@ struct window_S {
|
||||
* a new line after setting the w_pcmark. If not, then we revert to
|
||||
* using the previous w_pcmark.
|
||||
*/
|
||||
pos_T w_pcmark; /* previous context mark */
|
||||
pos_T w_prev_pcmark; /* previous w_pcmark */
|
||||
pos_T w_pcmark; // previous context mark
|
||||
pos_T w_prev_pcmark; // previous w_pcmark
|
||||
|
||||
/*
|
||||
* the jumplist contains old cursor positions
|
||||
*/
|
||||
xfmark_T w_jumplist[JUMPLISTSIZE];
|
||||
int w_jumplistlen; /* number of active entries */
|
||||
int w_jumplistidx; /* current position */
|
||||
int w_jumplistlen; // number of active entries
|
||||
int w_jumplistidx; // current position
|
||||
|
||||
int w_changelistidx; /* current position in b_changelist */
|
||||
int w_changelistidx; // current position in b_changelist
|
||||
|
||||
matchitem_T *w_match_head; /* head of match list */
|
||||
int w_next_match_id; /* next match ID */
|
||||
matchitem_T *w_match_head; // head of match list
|
||||
int w_next_match_id; // next match ID
|
||||
|
||||
/*
|
||||
* the tagstack grows from 0 upwards:
|
||||
@@ -1325,9 +1324,9 @@ struct window_S {
|
||||
* entry 1: newer
|
||||
* entry 2: newest
|
||||
*/
|
||||
taggy_T w_tagstack[TAGSTACKSIZE]; /* the tag stack */
|
||||
int w_tagstackidx; /* idx just below active entry */
|
||||
int w_tagstacklen; /* number of tags on stack */
|
||||
taggy_T w_tagstack[TAGSTACKSIZE]; // the tag stack
|
||||
int w_tagstackidx; // idx just below active entry
|
||||
int w_tagstacklen; // number of tags on stack
|
||||
|
||||
ScreenGrid w_grid; // the grid specific to the window
|
||||
bool w_pos_changed; // true if window position changed
|
||||
@@ -1345,13 +1344,11 @@ struct window_S {
|
||||
|
||||
linenr_T w_nrwidth_line_count; /* line count when ml_nrwidth_width
|
||||
* was computed. */
|
||||
int w_nrwidth_width; /* nr of chars to print line count. */
|
||||
int w_nrwidth_width; // nr of chars to print line count.
|
||||
|
||||
qf_info_T *w_llist; /* Location list for this window */
|
||||
/*
|
||||
* Location list reference used in the location list window.
|
||||
* In a non-location list window, w_llist_ref is NULL.
|
||||
*/
|
||||
qf_info_T *w_llist; // Location list for this window
|
||||
// Location list reference used in the location list window.
|
||||
// In a non-location list window, w_llist_ref is NULL.
|
||||
qf_info_T *w_llist_ref;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ SHAPE_HOR = 1, ///< horizontal bar cursor
|
||||
SHAPE_VER = 2 ///< vertical bar cursor
|
||||
} CursorShape;
|
||||
|
||||
#define MSHAPE_NUMBERED 1000 /* offset for shapes identified by number */
|
||||
#define MSHAPE_HIDE 1 /* hide mouse pointer */
|
||||
#define MSHAPE_NUMBERED 1000 // offset for shapes identified by number
|
||||
#define MSHAPE_HIDE 1 // hide mouse pointer
|
||||
|
||||
#define SHAPE_MOUSE 1 /* used for mouse pointer shape */
|
||||
#define SHAPE_CURSOR 2 /* used for text cursor shape */
|
||||
#define SHAPE_MOUSE 1 // used for mouse pointer shape
|
||||
#define SHAPE_CURSOR 2 // used for text cursor shape
|
||||
|
||||
typedef struct cursor_entry {
|
||||
char *full_name; ///< mode description
|
||||
|
||||
@@ -648,8 +648,8 @@ void diff_redraw(bool dofold)
|
||||
foldUpdateAll(wp);
|
||||
}
|
||||
|
||||
/* A change may have made filler lines invalid, need to take care
|
||||
* of that for other windows. */
|
||||
// A change may have made filler lines invalid, need to take care
|
||||
// of that for other windows.
|
||||
int n = diff_check(wp, wp->w_topline);
|
||||
|
||||
if (((wp != curwin) && (wp->w_topfill > 0)) || (n > 0)) {
|
||||
|
||||
1302
src/nvim/edit.c
1302
src/nvim/edit.c
File diff suppressed because it is too large
Load Diff
471
src/nvim/eval.c
471
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@@ -971,15 +971,16 @@ static void f_col(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
fp = var2fpos(&argvars[0], FALSE, &fnum);
|
||||
if (fp != NULL && fnum == curbuf->b_fnum) {
|
||||
if (fp->col == MAXCOL) {
|
||||
/* '> can be MAXCOL, get the length of the line then */
|
||||
if (fp->lnum <= curbuf->b_ml.ml_line_count)
|
||||
// '> can be MAXCOL, get the length of the line then
|
||||
if (fp->lnum <= curbuf->b_ml.ml_line_count) {
|
||||
col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1;
|
||||
else
|
||||
} else {
|
||||
col = MAXCOL;
|
||||
}
|
||||
} else {
|
||||
col = fp->col + 1;
|
||||
/* col(".") when the cursor is on the NUL at the end of the line
|
||||
* because of "coladd" can be seen as an extra column. */
|
||||
// col(".") when the cursor is on the NUL at the end of the line
|
||||
// because of "coladd" can be seen as an extra column.
|
||||
if (virtual_active() && fp == &curwin->w_cursor) {
|
||||
char_u *p = get_cursor_pos_ptr();
|
||||
|
||||
@@ -1664,25 +1665,29 @@ static void f_diff_hlID(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
int filler_lines;
|
||||
int col;
|
||||
|
||||
if (lnum < 0) /* ignore type error in {lnum} arg */
|
||||
if (lnum < 0) { // ignore type error in {lnum} arg
|
||||
lnum = 0;
|
||||
}
|
||||
if (lnum != prev_lnum
|
||||
|| changedtick != buf_get_changedtick(curbuf)
|
||||
|| fnum != curbuf->b_fnum) {
|
||||
/* New line, buffer, change: need to get the values. */
|
||||
// New line, buffer, change: need to get the values.
|
||||
filler_lines = diff_check(curwin, lnum);
|
||||
if (filler_lines < 0) {
|
||||
if (filler_lines == -1) {
|
||||
change_start = MAXCOL;
|
||||
change_end = -1;
|
||||
if (diff_find_change(curwin, lnum, &change_start, &change_end))
|
||||
hlID = HLF_ADD; /* added line */
|
||||
else
|
||||
hlID = HLF_CHD; /* changed line */
|
||||
} else
|
||||
hlID = HLF_ADD; /* added line */
|
||||
} else
|
||||
if (diff_find_change(curwin, lnum, &change_start, &change_end)) {
|
||||
hlID = HLF_ADD; // added line
|
||||
} else {
|
||||
hlID = HLF_CHD; // changed line
|
||||
}
|
||||
} else {
|
||||
hlID = HLF_ADD; // added line
|
||||
}
|
||||
} else {
|
||||
hlID = (hlf_T)0;
|
||||
}
|
||||
prev_lnum = lnum;
|
||||
changedtick = buf_get_changedtick(curbuf);
|
||||
fnum = curbuf->b_fnum;
|
||||
@@ -2060,8 +2065,8 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
} else
|
||||
rettv->vval.v_string = result;
|
||||
} else {
|
||||
/* When the optional second argument is non-zero, don't remove matches
|
||||
* for 'wildignore' and don't put matches for 'suffixes' at the end. */
|
||||
// When the optional second argument is non-zero, don't remove matches
|
||||
// for 'wildignore' and don't put matches for 'suffixes' at the end.
|
||||
if (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& tv_get_number_chk(&argvars[1], &error)) {
|
||||
options |= WILD_KEEP_ALL;
|
||||
@@ -2480,9 +2485,9 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Find interesting text in this line. */
|
||||
// Find interesting text in this line.
|
||||
s = skipwhite(ml_get(lnum));
|
||||
/* skip C comment-start */
|
||||
// skip C comment-start
|
||||
if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) {
|
||||
s = skipwhite(s + 2);
|
||||
if (*skipwhite(s) == NUL && lnum + 1 < foldend) {
|
||||
@@ -2500,7 +2505,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
sprintf((char *)r, txt, dashes, count);
|
||||
len = (int)STRLEN(r);
|
||||
STRCAT(r, s);
|
||||
/* remove 'foldmarker' and 'commentstring' */
|
||||
// remove 'foldmarker' and 'commentstring'
|
||||
foldtext_cleanup(r + len);
|
||||
rettv->vval.v_string = r;
|
||||
}
|
||||
@@ -2925,10 +2930,10 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
rettv->vval.v_number = n;
|
||||
if (IS_SPECIAL(n) || mod_mask != 0) {
|
||||
char_u temp[10]; /* modifier: 3, mbyte-char: 6, NUL: 1 */
|
||||
char_u temp[10]; // modifier: 3, mbyte-char: 6, NUL: 1
|
||||
int i = 0;
|
||||
|
||||
/* Turn a special key into three bytes, plus modifier. */
|
||||
// Turn a special key into three bytes, plus modifier.
|
||||
if (mod_mask != 0) {
|
||||
temp[i++] = K_SPECIAL;
|
||||
temp[i++] = KS_MODIFIER;
|
||||
@@ -3277,7 +3282,7 @@ static void f_getfsize(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
} else {
|
||||
rettv->vval.v_number = (varnumber_T)filesize;
|
||||
|
||||
/* non-perfect check for overflow */
|
||||
// non-perfect check for overflow
|
||||
if ((uint64_t)rettv->vval.v_number != filesize) {
|
||||
rettv->vval.v_number = -2;
|
||||
}
|
||||
@@ -4026,7 +4031,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
"dialog_con",
|
||||
"diff",
|
||||
"digraphs",
|
||||
"eval", /* always present, of course! */
|
||||
"eval", // always present, of course!
|
||||
"ex_extra",
|
||||
"extra_search",
|
||||
"file_in_path",
|
||||
@@ -4094,7 +4099,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
"textobjects",
|
||||
"timers",
|
||||
"title",
|
||||
"user-commands", /* was accidentally included in 5.4 */
|
||||
"user-commands", // was accidentally included in 5.4
|
||||
"user_commands",
|
||||
"vertsplit",
|
||||
"virtualedit",
|
||||
@@ -4550,9 +4555,9 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
msg_start();
|
||||
msg_row = Rows - 1; /* for when 'cmdheight' > 1 */
|
||||
lines_left = Rows; /* avoid more prompt */
|
||||
msg_scroll = TRUE;
|
||||
msg_row = Rows - 1; // for when 'cmdheight' > 1
|
||||
lines_left = Rows; // avoid more prompt
|
||||
msg_scroll = true;
|
||||
msg_clr_eos();
|
||||
|
||||
TV_LIST_ITER_CONST(argvars[0].vval.v_list, li, {
|
||||
@@ -5426,7 +5431,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
|
||||
long idx = 0;
|
||||
char_u *tofree = NULL;
|
||||
|
||||
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
|
||||
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = (char_u *)"";
|
||||
|
||||
@@ -5492,12 +5497,12 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
|
||||
start = 0;
|
||||
if (start > len)
|
||||
goto theend;
|
||||
/* When "count" argument is there ignore matches before "start",
|
||||
* otherwise skip part of the string. Differs when pattern is "^"
|
||||
* or "\<". */
|
||||
if (argvars[3].v_type != VAR_UNKNOWN)
|
||||
// When "count" argument is there ignore matches before "start",
|
||||
// otherwise skip part of the string. Differs when pattern is "^"
|
||||
// or "\<".
|
||||
if (argvars[3].v_type != VAR_UNKNOWN) {
|
||||
startcol = start;
|
||||
else {
|
||||
} else {
|
||||
str += start;
|
||||
len -= start;
|
||||
}
|
||||
@@ -5536,7 +5541,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
|
||||
if (l == NULL && !match)
|
||||
break;
|
||||
|
||||
/* Advance to just after the match. */
|
||||
// Advance to just after the match.
|
||||
if (l != NULL) {
|
||||
li = TV_LIST_ITEM_NEXT(l, li);
|
||||
idx++;
|
||||
@@ -6309,12 +6314,12 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
bool binary = false;
|
||||
FILE *fd;
|
||||
char_u buf[(IOSIZE/256)*256]; /* rounded to avoid odd + 1 */
|
||||
char_u buf[(IOSIZE/256) * 256]; // rounded to avoid odd + 1
|
||||
int io_size = sizeof(buf);
|
||||
int readlen; /* size of last fread() */
|
||||
char_u *prev = NULL; /* previously read bytes, if any */
|
||||
long prevlen = 0; /* length of data in prev */
|
||||
long prevsize = 0; /* size of prev buffer */
|
||||
int readlen; // size of last fread()
|
||||
char_u *prev = NULL; // previously read bytes, if any
|
||||
long prevlen = 0; // length of data in prev
|
||||
long prevsize = 0; // size of prev buffer
|
||||
long maxline = MAXLNUM;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
@@ -6353,14 +6358,17 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
char_u *s = NULL;
|
||||
size_t len = p - start;
|
||||
|
||||
/* Finished a line. Remove CRs before NL. */
|
||||
// Finished a line. Remove CRs before NL.
|
||||
if (readlen > 0 && !binary) {
|
||||
while (len > 0 && start[len - 1] == '\r')
|
||||
--len;
|
||||
/* removal may cross back to the "prev" string */
|
||||
if (len == 0)
|
||||
while (prevlen > 0 && prev[prevlen - 1] == '\r')
|
||||
--prevlen;
|
||||
while (len > 0 && start[len - 1] == '\r') {
|
||||
len--;
|
||||
}
|
||||
// removal may cross back to the "prev" string
|
||||
if (len == 0) {
|
||||
while (prevlen > 0 && prev[prevlen - 1] == '\r') {
|
||||
prevlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prevlen == 0) {
|
||||
assert(len < INT_MAX);
|
||||
@@ -6372,7 +6380,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
s = xrealloc(prev, prevlen + len + 1);
|
||||
memcpy(s + prevlen, start, len);
|
||||
s[prevlen + len] = NUL;
|
||||
prev = NULL; /* the list will own the string */
|
||||
prev = NULL; // the list will own the string
|
||||
prevlen = prevsize = 0;
|
||||
}
|
||||
|
||||
@@ -6411,13 +6419,12 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
if (back2 == 0xef && back1 == 0xbb) {
|
||||
char_u *dest = p - 2;
|
||||
|
||||
/* Usually a BOM is at the beginning of a file, and so at
|
||||
* the beginning of a line; then we can just step over it.
|
||||
*/
|
||||
if (start == dest)
|
||||
// Usually a BOM is at the beginning of a file, and so at
|
||||
// the beginning of a line; then we can just step over it.
|
||||
if (start == dest) {
|
||||
start = p + 1;
|
||||
else {
|
||||
/* have to shuffle buf to close gap */
|
||||
} else {
|
||||
// have to shuffle buf to close gap
|
||||
int adjust_prevlen = 0;
|
||||
|
||||
if (dest < buf) { // -V782
|
||||
@@ -6433,13 +6440,13 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* for */
|
||||
} // for
|
||||
|
||||
if ((maxline >= 0 && tv_list_len(l) >= maxline) || readlen <= 0) {
|
||||
break;
|
||||
}
|
||||
if (start < p) {
|
||||
/* There's part of a line in buf, store it in "prev". */
|
||||
// There's part of a line in buf, store it in "prev".
|
||||
if (p - start + prevlen >= prevsize) {
|
||||
/* A common use case is ordinary text files and "prev" gets a
|
||||
* fragment of a line, so the first allocation is made
|
||||
@@ -6454,11 +6461,11 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
prev = xrealloc(prev, prevsize);
|
||||
}
|
||||
/* Add the line part to end of "prev". */
|
||||
// Add the line part to end of "prev".
|
||||
memmove(prev + prevlen, start, p - start);
|
||||
prevlen += (long)(p - start);
|
||||
}
|
||||
} /* while */
|
||||
} // while
|
||||
|
||||
xfree(prev);
|
||||
fclose(fd);
|
||||
@@ -6950,7 +6957,7 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
|
||||
pos_T save_cursor;
|
||||
bool save_p_ws = p_ws;
|
||||
int dir;
|
||||
int retval = 0; /* default: FAIL */
|
||||
int retval = 0; // default: FAIL
|
||||
long lnum_stop = 0;
|
||||
proftime_T tm;
|
||||
long time_limit = 0;
|
||||
@@ -6974,7 +6981,7 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
|
||||
options |= SEARCH_COL;
|
||||
}
|
||||
|
||||
/* Optional arguments: line number to stop searching and timeout. */
|
||||
// Optional arguments: line number to stop searching and timeout.
|
||||
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) {
|
||||
lnum_stop = tv_get_number_chk(&argvars[2], NULL);
|
||||
if (lnum_stop < 0) {
|
||||
@@ -6988,7 +6995,7 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the time limit, if there is one. */
|
||||
// Set the time limit, if there is one.
|
||||
tm = profile_setlimit(time_limit);
|
||||
|
||||
/*
|
||||
@@ -7018,20 +7025,21 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
|
||||
setpcmark();
|
||||
curwin->w_cursor = pos;
|
||||
if (match_pos != NULL) {
|
||||
/* Store the match cursor position */
|
||||
// Store the match cursor position
|
||||
match_pos->lnum = pos.lnum;
|
||||
match_pos->col = pos.col + 1;
|
||||
}
|
||||
/* "/$" will put the cursor after the end of the line, may need to
|
||||
* correct that here */
|
||||
// "/$" will put the cursor after the end of the line, may need to
|
||||
// correct that here
|
||||
check_cursor();
|
||||
}
|
||||
|
||||
/* If 'n' flag is used: restore cursor position. */
|
||||
if (flags & SP_NOMOVE)
|
||||
// If 'n' flag is used: restore cursor position.
|
||||
if (flags & SP_NOMOVE) {
|
||||
curwin->w_cursor = save_cursor;
|
||||
else
|
||||
curwin->w_set_curswant = TRUE;
|
||||
} else {
|
||||
curwin->w_set_curswant = true;
|
||||
}
|
||||
theend:
|
||||
p_ws = save_p_ws;
|
||||
|
||||
@@ -7370,7 +7378,7 @@ static void f_searchdecl(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
int thisblock = 0;
|
||||
bool error = false;
|
||||
|
||||
rettv->vval.v_number = 1; /* default: FAIL */
|
||||
rettv->vval.v_number = 1; // default: FAIL
|
||||
|
||||
const char *const name = tv_get_string_chk(&argvars[0]);
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
@@ -7528,11 +7536,11 @@ do_searchpair(
|
||||
size_t pat2_len;
|
||||
size_t pat3_len;
|
||||
|
||||
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
|
||||
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = empty_option;
|
||||
|
||||
/* Set the time limit, if there is one. */
|
||||
// Set the time limit, if there is one.
|
||||
tm = profile_setlimit(time_limit);
|
||||
|
||||
// Make two search patterns: start/end (pat2, for in nested pairs) and
|
||||
@@ -7580,17 +7588,18 @@ do_searchpair(
|
||||
if (firstpos.lnum == 0)
|
||||
firstpos = pos;
|
||||
if (equalpos(pos, foundpos)) {
|
||||
/* Found the same position again. Can happen with a pattern that
|
||||
* has "\zs" at the end and searching backwards. Advance one
|
||||
* character and try again. */
|
||||
if (dir == BACKWARD)
|
||||
// Found the same position again. Can happen with a pattern that
|
||||
// has "\zs" at the end and searching backwards. Advance one
|
||||
// character and try again.
|
||||
if (dir == BACKWARD) {
|
||||
decl(&pos);
|
||||
else
|
||||
} else {
|
||||
incl(&pos);
|
||||
}
|
||||
}
|
||||
foundpos = pos;
|
||||
|
||||
/* clear the start flag to avoid getting stuck here */
|
||||
// clear the start flag to avoid getting stuck here
|
||||
options &= ~SEARCH_START;
|
||||
|
||||
// If the skip pattern matches, ignore this match.
|
||||
@@ -7601,7 +7610,7 @@ do_searchpair(
|
||||
const bool r = eval_expr_to_bool(skip, &err);
|
||||
curwin->w_cursor = save_pos;
|
||||
if (err) {
|
||||
/* Evaluating {skip} caused an error, break here. */
|
||||
// Evaluating {skip} caused an error, break here.
|
||||
curwin->w_cursor = save_cursor;
|
||||
retval = -1;
|
||||
break;
|
||||
@@ -7611,49 +7620,54 @@ do_searchpair(
|
||||
}
|
||||
|
||||
if ((dir == BACKWARD && n == 3) || (dir == FORWARD && n == 2)) {
|
||||
/* Found end when searching backwards or start when searching
|
||||
* forward: nested pair. */
|
||||
++nest;
|
||||
pat = pat2; /* nested, don't search for middle */
|
||||
// Found end when searching backwards or start when searching
|
||||
// forward: nested pair.
|
||||
nest++;
|
||||
pat = pat2; // nested, don't search for middle
|
||||
} else {
|
||||
/* Found end when searching forward or start when searching
|
||||
* backward: end of (nested) pair; or found middle in outer pair. */
|
||||
if (--nest == 1)
|
||||
pat = pat3; /* outer level, search for middle */
|
||||
// Found end when searching forward or start when searching
|
||||
// backward: end of (nested) pair; or found middle in outer pair.
|
||||
if (--nest == 1) {
|
||||
pat = pat3; // outer level, search for middle
|
||||
}
|
||||
}
|
||||
|
||||
if (nest == 0) {
|
||||
/* Found the match: return matchcount or line number. */
|
||||
if (flags & SP_RETCOUNT)
|
||||
++retval;
|
||||
else
|
||||
// Found the match: return matchcount or line number.
|
||||
if (flags & SP_RETCOUNT) {
|
||||
retval++;
|
||||
} else {
|
||||
retval = pos.lnum;
|
||||
if (flags & SP_SETPCMARK)
|
||||
}
|
||||
if (flags & SP_SETPCMARK) {
|
||||
setpcmark();
|
||||
}
|
||||
curwin->w_cursor = pos;
|
||||
if (!(flags & SP_REPEAT))
|
||||
break;
|
||||
nest = 1; /* search for next unmatched */
|
||||
nest = 1; // search for next unmatched
|
||||
}
|
||||
}
|
||||
|
||||
if (match_pos != NULL) {
|
||||
/* Store the match cursor position */
|
||||
// Store the match cursor position
|
||||
match_pos->lnum = curwin->w_cursor.lnum;
|
||||
match_pos->col = curwin->w_cursor.col + 1;
|
||||
}
|
||||
|
||||
/* If 'n' flag is used or search failed: restore cursor position. */
|
||||
if ((flags & SP_NOMOVE) || retval == 0)
|
||||
// If 'n' flag is used or search failed: restore cursor position.
|
||||
if ((flags & SP_NOMOVE) || retval == 0) {
|
||||
curwin->w_cursor = save_cursor;
|
||||
}
|
||||
|
||||
xfree(pat2);
|
||||
xfree(pat3);
|
||||
if (p_cpo == empty_option)
|
||||
if (p_cpo == empty_option) {
|
||||
p_cpo = save_cpo;
|
||||
else
|
||||
/* Darn, evaluating the {skip} expression changed the value. */
|
||||
} else {
|
||||
// Darn, evaluating the {skip} expression changed the value.
|
||||
free_string_option(save_cpo);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -9031,7 +9045,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
|
||||
info.item_compare_selfdict = NULL;
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
/* optional second argument: {func} */
|
||||
// optional second argument: {func}
|
||||
if (argvars[1].v_type == VAR_FUNC) {
|
||||
info.item_compare_func = (const char *)argvars[1].vval.v_string;
|
||||
} else if (argvars[1].v_type == VAR_PARTIAL) {
|
||||
@@ -9292,7 +9306,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
bool keepempty = false;
|
||||
bool typeerr = false;
|
||||
|
||||
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
|
||||
// Make 'cpoptions' empty, the 'l' flag should not be used here.
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = (char_u *)"";
|
||||
|
||||
@@ -9480,10 +9494,10 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
struct tm curtime;
|
||||
struct tm *curtime_ptr = os_localtime_r(&seconds, &curtime);
|
||||
/* MSVC returns NULL for an invalid value of seconds. */
|
||||
if (curtime_ptr == NULL)
|
||||
// MSVC returns NULL for an invalid value of seconds.
|
||||
if (curtime_ptr == NULL) {
|
||||
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
|
||||
else {
|
||||
} else {
|
||||
vimconv_T conv;
|
||||
char_u *enc;
|
||||
|
||||
@@ -10180,7 +10194,7 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar)
|
||||
for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
|
||||
wp != twin; wp = wp->w_next) {
|
||||
if (wp == NULL) {
|
||||
/* didn't find it in this tabpage */
|
||||
// didn't find it in this tabpage
|
||||
nr = 0;
|
||||
break;
|
||||
}
|
||||
@@ -10769,9 +10783,10 @@ static void f_visualmode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
str[1] = NUL;
|
||||
rettv->vval.v_string = vim_strsave(str);
|
||||
|
||||
/* A non-zero number or non-empty string argument: reset mode. */
|
||||
if (non_zero_arg(&argvars[0]))
|
||||
// A non-zero number or non-empty string argument: reset mode.
|
||||
if (non_zero_arg(&argvars[0])) {
|
||||
curbuf->b_visual_mode_eval = NUL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -197,7 +197,7 @@ static void save_dbg_stuff(struct dbg_stuff *dsp)
|
||||
|
||||
static void restore_dbg_stuff(struct dbg_stuff *dsp)
|
||||
{
|
||||
suppress_errthrow = FALSE;
|
||||
suppress_errthrow = false;
|
||||
trylevel = dsp->trylevel;
|
||||
force_abort = dsp->force_abort;
|
||||
caught_stack = dsp->caught_stack;
|
||||
@@ -394,8 +394,8 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
|
||||
* Initialize "force_abort" and "suppress_errthrow" at the top level.
|
||||
*/
|
||||
if (!recursive) {
|
||||
force_abort = FALSE;
|
||||
suppress_errthrow = FALSE;
|
||||
force_abort = false;
|
||||
suppress_errthrow = false;
|
||||
}
|
||||
|
||||
// If requested, store and reset the global values controlling the
|
||||
@@ -879,16 +879,14 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
|
||||
xfree(sourcing_name);
|
||||
sourcing_name = saved_sourcing_name;
|
||||
sourcing_lnum = saved_sourcing_lnum;
|
||||
} else if (got_int || (did_emsg && force_abort)) {
|
||||
// On an interrupt or an aborting error not converted to an exception,
|
||||
// disable the conversion of errors to exceptions. (Interrupts are not
|
||||
// converted any more, here.) This enables also the interrupt message
|
||||
// when force_abort is set and did_emsg unset in case of an interrupt
|
||||
// from a finally clause after an error.
|
||||
suppress_errthrow = true;
|
||||
}
|
||||
/*
|
||||
* On an interrupt or an aborting error not converted to an exception,
|
||||
* disable the conversion of errors to exceptions. (Interrupts are not
|
||||
* converted any more, here.) This enables also the interrupt message
|
||||
* when force_abort is set and did_emsg unset in case of an interrupt
|
||||
* from a finally clause after an error.
|
||||
*/
|
||||
else if (got_int || (did_emsg && force_abort))
|
||||
suppress_errthrow = TRUE;
|
||||
}
|
||||
|
||||
// The current cstack will be freed when do_cmdline() returns. An uncaught
|
||||
|
||||
@@ -508,7 +508,7 @@ static int throw_exception(void *value, except_type_T type, char_u *cmdname)
|
||||
|
||||
nomem:
|
||||
xfree(excp);
|
||||
suppress_errthrow = TRUE;
|
||||
suppress_errthrow = true;
|
||||
EMSG(_(e_outofmem));
|
||||
fail:
|
||||
current_exception = NULL;
|
||||
|
||||
@@ -2447,9 +2447,10 @@ redraw:
|
||||
/* make following messages go to the next line */
|
||||
msg_didout = FALSE;
|
||||
msg_col = 0;
|
||||
if (msg_row < Rows - 1)
|
||||
++msg_row;
|
||||
emsg_on_display = FALSE; /* don't want os_delay() */
|
||||
if (msg_row < Rows - 1) {
|
||||
msg_row++;
|
||||
}
|
||||
emsg_on_display = false; // don't want os_delay()
|
||||
|
||||
if (got_int)
|
||||
ga_clear(&line_ga);
|
||||
|
||||
@@ -220,7 +220,7 @@ EXTERN int did_emsg_syntax; // did_emsg set because of a
|
||||
// syntax error
|
||||
EXTERN int called_emsg; // always set by emsg()
|
||||
EXTERN int ex_exitval INIT(= 0); // exit value for ex mode
|
||||
EXTERN int emsg_on_display INIT(= false); // there is an error message
|
||||
EXTERN bool emsg_on_display INIT(= false); // there is an error message
|
||||
EXTERN int rc_did_emsg INIT(= false); // vim_regcomp() called emsg()
|
||||
|
||||
EXTERN int no_wait_return INIT(= 0); // don't wait for return for now
|
||||
@@ -296,7 +296,7 @@ EXTERN struct msglist **msg_list INIT(= NULL);
|
||||
/// interrupt message or reporting an exception that is still uncaught at the
|
||||
/// top level (which has already been discarded then). Also used for the error
|
||||
/// message when no exception can be thrown.
|
||||
EXTERN int suppress_errthrow INIT(= false);
|
||||
EXTERN bool suppress_errthrow INIT(= false);
|
||||
|
||||
/// The stack of all caught and not finished exceptions. The exception on the
|
||||
/// top of the stack is the one got by evaluation of v:exception. The complete
|
||||
@@ -638,7 +638,7 @@ EXTERN int arrow_used; // Normally false, set to true after
|
||||
// hitting cursor key in insert mode.
|
||||
// Used by vgetorpeek() to decide when
|
||||
// to call u_sync()
|
||||
EXTERN int ins_at_eol INIT(= false); // put cursor after eol when
|
||||
EXTERN bool ins_at_eol INIT(= false); // put cursor after eol when
|
||||
// restarting edit after CTRL-O
|
||||
EXTERN char_u *edit_submode INIT(= NULL); // msg for CTRL-X submode
|
||||
EXTERN char_u *edit_submode_pre INIT(= NULL); // prepended to edit_submode
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -71,10 +71,10 @@ static void cs_usage_msg(csid_e x)
|
||||
|
||||
|
||||
static enum {
|
||||
EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
|
||||
EXP_SCSCOPE_SUBCMD, /* expand ":scscope" sub-commands */
|
||||
EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
|
||||
EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
|
||||
EXP_CSCOPE_SUBCMD, // expand ":cscope" sub-commands
|
||||
EXP_SCSCOPE_SUBCMD, // expand ":scscope" sub-commands
|
||||
EXP_CSCOPE_FIND, // expand ":cscope find" arguments
|
||||
EXP_CSCOPE_KILL // expand ":cscope kill" arguments
|
||||
} expand_what;
|
||||
|
||||
/*
|
||||
@@ -87,13 +87,13 @@ char_u *get_cscope_name(expand_T *xp, int idx)
|
||||
|
||||
switch (expand_what) {
|
||||
case EXP_CSCOPE_SUBCMD:
|
||||
/* Complete with sub-commands of ":cscope":
|
||||
* add, find, help, kill, reset, show */
|
||||
// Complete with sub-commands of ":cscope":
|
||||
// add, find, help, kill, reset, show
|
||||
return (char_u *)cs_cmds[idx].name;
|
||||
case EXP_SCSCOPE_SUBCMD:
|
||||
{
|
||||
/* Complete with sub-commands of ":scscope": same sub-commands as
|
||||
* ":cscope" but skip commands which don't support split windows */
|
||||
// Complete with sub-commands of ":scscope": same sub-commands as
|
||||
// ":cscope" but skip commands which don't support split windows
|
||||
int i;
|
||||
for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
|
||||
if (cs_cmds[i].cansplit)
|
||||
@@ -118,10 +118,10 @@ char_u *get_cscope_name(expand_T *xp, int idx)
|
||||
{
|
||||
static char connection[5];
|
||||
|
||||
/* ":cscope kill" accepts connection numbers or partial names of
|
||||
* the pathname of the cscope database as argument. Only complete
|
||||
* with connection numbers. -1 can also be used to kill all
|
||||
* connections. */
|
||||
// ":cscope kill" accepts connection numbers or partial names of
|
||||
// the pathname of the cscope database as argument. Only complete
|
||||
// with connection numbers. -1 can also be used to kill all
|
||||
// connections.
|
||||
size_t i;
|
||||
for (i = 0, current_idx = 0; i < csinfo_size; i++) {
|
||||
if (csinfo[i].fname == NULL)
|
||||
@@ -149,7 +149,7 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
|
||||
expand_what = ((cmdidx == CMD_scscope)
|
||||
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD);
|
||||
|
||||
/* (part of) subcommand already typed */
|
||||
// (part of) subcommand already typed
|
||||
if (*arg != NUL) {
|
||||
const char *p = (const char *)skiptowhite((const char_u *)arg);
|
||||
if (*p != NUL) { // Past first word.
|
||||
@@ -175,7 +175,7 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
|
||||
static void
|
||||
do_cscope_general(
|
||||
exarg_T *eap,
|
||||
int make_split /* whether to split window */
|
||||
int make_split // whether to split window
|
||||
)
|
||||
{
|
||||
cscmd_T *cmdp;
|
||||
@@ -276,17 +276,19 @@ void ex_cstag(exarg_T *eap)
|
||||
/// This simulates a vim_fgets(), but for cscope, returns the next line
|
||||
/// from the cscope output. should only be called from find_tags()
|
||||
///
|
||||
/// @return TRUE if eof, FALSE otherwise
|
||||
int cs_fgets(char_u *buf, int size)
|
||||
/// @return true if eof, FALSE otherwise
|
||||
bool cs_fgets(char_u *buf, int size)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *p;
|
||||
|
||||
if ((p = cs_manage_matches(NULL, NULL, 0, Get)) == NULL)
|
||||
if ((p = cs_manage_matches(NULL, NULL, 0, Get)) == NULL) {
|
||||
return true;
|
||||
}
|
||||
STRLCPY(buf, p, size);
|
||||
|
||||
return FALSE;
|
||||
} /* cs_fgets */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// Called only from do_tag(), when popping the tag stack.
|
||||
@@ -328,48 +330,53 @@ void cs_print_tags(void)
|
||||
*
|
||||
* Note: All string comparisons are case sensitive!
|
||||
*/
|
||||
int cs_connection(int num, char_u *dbpath, char_u *ppath)
|
||||
bool cs_connection(int num, char_u *dbpath, char_u *ppath)
|
||||
{
|
||||
if (num < 0 || num > 4 || (num > 0 && !dbpath))
|
||||
if (num < 0 || num > 4 || (num > 0 && !dbpath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < csinfo_size; i++) {
|
||||
if (!csinfo[i].fname)
|
||||
if (!csinfo[i].fname) {
|
||||
continue;
|
||||
|
||||
if (num == 0)
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
if (num == 0) {
|
||||
return true;
|
||||
}
|
||||
switch (num) {
|
||||
case 1:
|
||||
if (strstr(csinfo[i].fname, (char *)dbpath))
|
||||
return TRUE;
|
||||
if (strstr(csinfo[i].fname, (char *)dbpath)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (strcmp(csinfo[i].fname, (char *)dbpath) == 0)
|
||||
return TRUE;
|
||||
if (strcmp(csinfo[i].fname, (char *)dbpath) == 0) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (strstr(csinfo[i].fname, (char *)dbpath)
|
||||
&& ((!ppath && !csinfo[i].ppath)
|
||||
|| (ppath
|
||||
&& csinfo[i].ppath
|
||||
&& strstr(csinfo[i].ppath, (char *)ppath))))
|
||||
return TRUE;
|
||||
&& strstr(csinfo[i].ppath, (char *)ppath)))) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if ((strcmp(csinfo[i].fname, (char *)dbpath) == 0)
|
||||
&& ((!ppath && !csinfo[i].ppath)
|
||||
|| (ppath
|
||||
&& csinfo[i].ppath
|
||||
&& (strcmp(csinfo[i].ppath, (char *)ppath) == 0))))
|
||||
return TRUE;
|
||||
&& (strcmp(csinfo[i].ppath, (char *)ppath) == 0)))) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} /* cs_connection */
|
||||
return false;
|
||||
} // cs_connection
|
||||
|
||||
|
||||
/*
|
||||
@@ -419,7 +426,7 @@ cs_add_common(
|
||||
size_t usedlen = 0;
|
||||
char_u *fbuf = NULL;
|
||||
|
||||
/* get the filename (arg1), expand it, and try to stat it */
|
||||
// get the filename (arg1), expand it, and try to stat it
|
||||
fname = xmalloc(MAXPATHL + 1);
|
||||
|
||||
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
|
||||
@@ -451,7 +458,7 @@ staterr:
|
||||
}
|
||||
|
||||
int i;
|
||||
/* if filename is a directory, append the cscope database name to it */
|
||||
// if filename is a directory, append the cscope database name to it
|
||||
if ((file_info.stat.st_mode & S_IFMT) == S_IFDIR) {
|
||||
fname2 = (char *)xmalloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2);
|
||||
|
||||
@@ -512,18 +519,18 @@ add_err:
|
||||
xfree(fname);
|
||||
xfree(ppath);
|
||||
return CSCOPE_FAILURE;
|
||||
} /* cs_add_common */
|
||||
}
|
||||
|
||||
|
||||
static int cs_check_for_connections(void)
|
||||
{
|
||||
return cs_cnt_connections() > 0;
|
||||
} /* cs_check_for_connections */
|
||||
}
|
||||
|
||||
static int cs_check_for_tags(void)
|
||||
{
|
||||
return p_tags[0] != NUL && curbuf->b_p_tags != NULL;
|
||||
} /* cs_check_for_tags */
|
||||
}
|
||||
|
||||
/// Count the number of cscope connections.
|
||||
static size_t cs_cnt_connections(void)
|
||||
@@ -535,10 +542,10 @@ static size_t cs_cnt_connections(void)
|
||||
cnt++;
|
||||
}
|
||||
return cnt;
|
||||
} /* cs_cnt_connections */
|
||||
}
|
||||
|
||||
static void cs_reading_emsg(
|
||||
size_t idx /* connection index */
|
||||
size_t idx // connection index
|
||||
)
|
||||
{
|
||||
EMSGU(_("E262: error reading cscope connection %" PRIu64), idx);
|
||||
@@ -602,7 +609,7 @@ static int cs_cnt_matches(size_t idx)
|
||||
|
||||
xfree(buf);
|
||||
return nlines;
|
||||
} /* cs_cnt_matches */
|
||||
}
|
||||
|
||||
|
||||
/// Creates the actual cscope command query from what the user entered.
|
||||
@@ -646,8 +653,8 @@ static char *cs_create_cmd(char *csoption, char *pattern)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Skip white space before the patter, except for text and pattern search,
|
||||
* they may want to use the leading white space. */
|
||||
// Skip white space before the patter, except for text and pattern search,
|
||||
// they may want to use the leading white space.
|
||||
pat = pattern;
|
||||
if (search != 4 && search != 6)
|
||||
while (ascii_iswhite(*pat))
|
||||
@@ -658,7 +665,7 @@ static char *cs_create_cmd(char *csoption, char *pattern)
|
||||
(void)sprintf(cmd, "%d%s", search, pat);
|
||||
|
||||
return cmd;
|
||||
} /* cs_create_cmd */
|
||||
}
|
||||
|
||||
|
||||
/// This piece of code was taken/adapted from nvi. do we need to add
|
||||
@@ -694,15 +701,18 @@ err_closing:
|
||||
case -1:
|
||||
(void)EMSG(_("E622: Could not fork for cscope"));
|
||||
goto err_closing;
|
||||
case 0: /* child: run cscope. */
|
||||
if (dup2(to_cs[0], STDIN_FILENO) == -1)
|
||||
case 0: // child: run cscope.
|
||||
if (dup2(to_cs[0], STDIN_FILENO) == -1) {
|
||||
PERROR("cs_create_connection 1");
|
||||
if (dup2(from_cs[1], STDOUT_FILENO) == -1)
|
||||
}
|
||||
if (dup2(from_cs[1], STDOUT_FILENO) == -1) {
|
||||
PERROR("cs_create_connection 2");
|
||||
if (dup2(from_cs[1], STDERR_FILENO) == -1)
|
||||
}
|
||||
if (dup2(from_cs[1], STDERR_FILENO) == -1) {
|
||||
PERROR("cs_create_connection 3");
|
||||
}
|
||||
|
||||
/* close unused */
|
||||
// close unused
|
||||
(void)close(to_cs[1]);
|
||||
(void)close(from_cs[0]);
|
||||
#else
|
||||
@@ -735,14 +745,14 @@ err_closing:
|
||||
return CSCOPE_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/* expand the cscope exec for env var's */
|
||||
// expand the cscope exec for env var's
|
||||
prog = xmalloc(MAXPATHL + 1);
|
||||
expand_env(p_csprg, (char_u *)prog, MAXPATHL);
|
||||
|
||||
/* alloc space to hold the cscope command */
|
||||
// alloc space to hold the cscope command
|
||||
size_t len = strlen(prog) + strlen(csinfo[i].fname) + 32;
|
||||
if (csinfo[i].ppath) {
|
||||
/* expand the prepend path for env var's */
|
||||
// expand the prepend path for env var's
|
||||
ppath = xmalloc(MAXPATHL + 1);
|
||||
expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
|
||||
|
||||
@@ -754,12 +764,12 @@ err_closing:
|
||||
|
||||
cmd = xmalloc(len);
|
||||
|
||||
/* run the cscope command; is there execl for non-unix systems? */
|
||||
// run the cscope command; is there execl for non-unix systems?
|
||||
#if defined(UNIX)
|
||||
(void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
|
||||
(void)snprintf(cmd, len, "exec %s -dl -f %s", prog, csinfo[i].fname);
|
||||
#else
|
||||
/* WIN32 */
|
||||
(void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
|
||||
// WIN32
|
||||
(void)snprintf(cmd, len, "%s -dl -f %s", prog, csinfo[i].fname);
|
||||
#endif
|
||||
if (csinfo[i].ppath != NULL) {
|
||||
(void)strcat(cmd, " -P");
|
||||
@@ -770,14 +780,14 @@ err_closing:
|
||||
(void)strcat(cmd, csinfo[i].flags);
|
||||
}
|
||||
# ifdef UNIX
|
||||
/* on Win32 we still need prog */
|
||||
// on Win32 we still need prog
|
||||
xfree(prog);
|
||||
# endif
|
||||
xfree(ppath);
|
||||
|
||||
#if defined(UNIX)
|
||||
# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
|
||||
/* Change our process group to avoid cscope receiving SIGWINCH. */
|
||||
// Change our process group to avoid cscope receiving SIGWINCH.
|
||||
# if defined(HAVE_SETSID)
|
||||
(void)setsid();
|
||||
# else
|
||||
@@ -789,18 +799,18 @@ err_closing:
|
||||
PERROR(_("cs_create_connection exec failed"));
|
||||
|
||||
exit(127);
|
||||
/* NOTREACHED */
|
||||
default: /* parent. */
|
||||
/*
|
||||
* Save the file descriptors for later duplication, and
|
||||
* reopen as streams.
|
||||
*/
|
||||
if ((csinfo[i].to_fp = fdopen(to_cs[1], "w")) == NULL)
|
||||
// NOTREACHED
|
||||
default: // parent.
|
||||
// Save the file descriptors for later duplication, and
|
||||
// reopen as streams.
|
||||
if ((csinfo[i].to_fp = fdopen(to_cs[1], "w")) == NULL) {
|
||||
PERROR(_("cs_create_connection: fdopen for to_fp failed"));
|
||||
if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
|
||||
}
|
||||
if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL) {
|
||||
PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
|
||||
}
|
||||
|
||||
/* close unused */
|
||||
// close unused
|
||||
(void)close(to_cs[0]);
|
||||
(void)close(from_cs[1]);
|
||||
|
||||
@@ -808,11 +818,11 @@ err_closing:
|
||||
}
|
||||
|
||||
#else
|
||||
/* WIN32 */
|
||||
/* Create a new process to run cscope and use pipes to talk with it */
|
||||
// WIN32
|
||||
// Create a new process to run cscope and use pipes to talk with it
|
||||
GetStartupInfo(&si);
|
||||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_HIDE; /* Hide child application window */
|
||||
si.wShowWindow = SW_HIDE; // Hide child application window
|
||||
si.hStdOutput = stdout_wr;
|
||||
si.hStdError = stdout_wr;
|
||||
si.hStdInput = stdin_rd;
|
||||
@@ -826,7 +836,7 @@ err_closing:
|
||||
(void)EMSG(_("E623: Could not spawn cscope process"));
|
||||
goto err_closing;
|
||||
}
|
||||
/* else */
|
||||
// else
|
||||
csinfo[i].pid = pi.dwProcessId;
|
||||
csinfo[i].hProc = pi.hProcess;
|
||||
CloseHandle(pi.hThread);
|
||||
@@ -844,10 +854,10 @@ err_closing:
|
||||
CloseHandle(stdin_rd);
|
||||
CloseHandle(stdout_wr);
|
||||
|
||||
#endif /* !UNIX */
|
||||
#endif // !UNIX
|
||||
|
||||
return CSCOPE_SUCCESS;
|
||||
} /* cs_create_connection */
|
||||
}
|
||||
|
||||
|
||||
/// Query cscope using command line interface. Parse the output and use tselect
|
||||
@@ -882,9 +892,9 @@ static int cs_find(exarg_T *eap)
|
||||
if (NUL == eap->arg[i])
|
||||
eap->arg[i] = ' ';
|
||||
|
||||
return cs_find_common(opt, pat, eap->forceit, TRUE,
|
||||
eap->cmdidx == CMD_lcscope, *eap->cmdlinep);
|
||||
} /* cs_find */
|
||||
return cs_find_common(opt, pat, eap->forceit, true,
|
||||
eap->cmdidx == CMD_lcscope, *eap->cmdlinep);
|
||||
}
|
||||
|
||||
|
||||
/// Common code for cscope find, shared by cs_find() and ex_cstag().
|
||||
@@ -897,7 +907,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
char cmdletter;
|
||||
char *qfpos;
|
||||
|
||||
/* get cmd letter */
|
||||
// get cmd letter
|
||||
switch (opt[0]) {
|
||||
case '0':
|
||||
cmdletter = 's';
|
||||
@@ -933,10 +943,10 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
qfpos = (char *)vim_strchr(p_csqf, cmdletter);
|
||||
if (qfpos != NULL) {
|
||||
qfpos++;
|
||||
/* next symbol must be + or - */
|
||||
// next symbol must be + or -
|
||||
if (strchr(CSQF_FLAGS, *qfpos) == NULL) {
|
||||
char *nf = _("E469: invalid cscopequickfix flag %c for %c");
|
||||
/* strlen will be enough because we use chars */
|
||||
// strlen will be enough because we use chars
|
||||
char *buf = xmalloc(strlen(nf));
|
||||
|
||||
sprintf(buf, nf, *qfpos, *(qfpos-1));
|
||||
@@ -954,23 +964,24 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
}
|
||||
}
|
||||
|
||||
/* create the actual command to send to cscope */
|
||||
// create the actual command to send to cscope
|
||||
cmd = cs_create_cmd(opt, pat);
|
||||
if (cmd == NULL)
|
||||
return FALSE;
|
||||
|
||||
nummatches = xmalloc(sizeof(int) * csinfo_size);
|
||||
|
||||
/* Send query to all open connections, then count the total number
|
||||
* of matches so we can alloc all in one swell foop. */
|
||||
for (size_t i = 0; i < csinfo_size; i++)
|
||||
// Send query to all open connections, then count the total number
|
||||
// of matches so we can alloc all in one swell foop.
|
||||
for (size_t i = 0; i < csinfo_size; i++) {
|
||||
nummatches[i] = 0;
|
||||
}
|
||||
totmatches = 0;
|
||||
for (size_t i = 0; i < csinfo_size; i++) {
|
||||
if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
|
||||
continue;
|
||||
|
||||
/* send cmd to cscope */
|
||||
// send cmd to cscope
|
||||
(void)fprintf(csinfo[i].to_fp, "%s\n", cmd);
|
||||
(void)fflush(csinfo[i].to_fp);
|
||||
|
||||
@@ -1014,8 +1025,9 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
} else {
|
||||
cs_file_results(f, nummatches);
|
||||
fclose(f);
|
||||
if (use_ll) /* Use location list */
|
||||
if (use_ll) { // Use location list
|
||||
wp = curwin;
|
||||
}
|
||||
// '-' starts a new error list
|
||||
if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m",
|
||||
*qfpos == '-', cmdline, NULL) > 0) {
|
||||
@@ -1046,7 +1058,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
char **matches = NULL, **contexts = NULL;
|
||||
size_t matched = 0;
|
||||
|
||||
/* read output */
|
||||
// read output
|
||||
cs_fill_results((char *)pat, totmatches, nummatches, &matches,
|
||||
&contexts, &matched);
|
||||
xfree(nummatches);
|
||||
@@ -1057,8 +1069,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
|
||||
return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose);
|
||||
}
|
||||
|
||||
} /* cs_find_common */
|
||||
}
|
||||
|
||||
/// Print help.
|
||||
static int cs_help(exarg_T *eap)
|
||||
@@ -1070,9 +1081,10 @@ static int cs_help(exarg_T *eap)
|
||||
char *help = _(cmdp->help);
|
||||
int space_cnt = 30 - vim_strsize((char_u *)help);
|
||||
|
||||
/* Use %*s rather than %30s to ensure proper alignment in utf-8 */
|
||||
if (space_cnt < 0)
|
||||
// Use %*s rather than %30s to ensure proper alignment in utf-8
|
||||
if (space_cnt < 0) {
|
||||
space_cnt = 0;
|
||||
}
|
||||
(void)smsg(_("%-5s: %s%*s (Usage: %s)"),
|
||||
cmdp->name,
|
||||
help, space_cnt, " ",
|
||||
@@ -1094,7 +1106,7 @@ static int cs_help(exarg_T *eap)
|
||||
|
||||
wait_return(TRUE);
|
||||
return CSCOPE_SUCCESS;
|
||||
} /* cs_help */
|
||||
}
|
||||
|
||||
|
||||
static void clear_csinfo(size_t i)
|
||||
@@ -1124,7 +1136,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
|
||||
}
|
||||
|
||||
if (csinfo[j].fname == NULL && !empty_found) {
|
||||
i = j; /* remember first empty entry */
|
||||
i = j; // remember first empty entry
|
||||
empty_found = true;
|
||||
}
|
||||
}
|
||||
@@ -1132,13 +1144,13 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
|
||||
if (!empty_found) {
|
||||
i = csinfo_size;
|
||||
if (csinfo_size == 0) {
|
||||
/* First time allocation: allocate only 1 connection. It should
|
||||
* be enough for most users. If more is needed, csinfo will be
|
||||
* reallocated. */
|
||||
// First time allocation: allocate only 1 connection. It should
|
||||
// be enough for most users. If more is needed, csinfo will be
|
||||
// reallocated.
|
||||
csinfo_size = 1;
|
||||
csinfo = xcalloc(1, sizeof(csinfo_T));
|
||||
} else {
|
||||
/* Reallocate space for more connections. */
|
||||
// Reallocate space for more connections.
|
||||
csinfo_size *= 2;
|
||||
csinfo = xrealloc(csinfo, sizeof(csinfo_T)*csinfo_size);
|
||||
}
|
||||
@@ -1165,7 +1177,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
|
||||
os_fileinfo_id(file_info, &(csinfo[i].file_id));
|
||||
assert(i <= INT_MAX);
|
||||
return (int)i;
|
||||
} /* cs_insert_filelist */
|
||||
}
|
||||
|
||||
|
||||
/// Find cscope command in command table.
|
||||
@@ -1178,7 +1190,7 @@ static cscmd_T * cs_lookup_cmd(exarg_T *eap)
|
||||
if (eap->arg == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Store length of eap->arg before it gets modified by strtok(). */
|
||||
// Store length of eap->arg before it gets modified by strtok().
|
||||
eap_arg_len = (int)STRLEN(eap->arg);
|
||||
|
||||
if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
|
||||
@@ -1190,7 +1202,7 @@ static cscmd_T * cs_lookup_cmd(exarg_T *eap)
|
||||
return cmdp;
|
||||
}
|
||||
return NULL;
|
||||
} /* cs_lookup_cmd */
|
||||
}
|
||||
|
||||
|
||||
/// Nuke em.
|
||||
@@ -1247,13 +1259,13 @@ static int cs_kill(exarg_T *eap)
|
||||
}
|
||||
|
||||
return CSCOPE_SUCCESS;
|
||||
} /* cs_kill */
|
||||
}
|
||||
|
||||
|
||||
/// Actually kills a specific cscope connection.
|
||||
static void cs_kill_execute(
|
||||
size_t i, /* cscope table index */
|
||||
char *cname /* cscope database name */
|
||||
size_t i, // cscope table index
|
||||
char *cname // cscope database name
|
||||
)
|
||||
{
|
||||
if (p_csverbose) {
|
||||
@@ -1284,17 +1296,16 @@ static void cs_kill_execute(
|
||||
static char *cs_make_vim_style_matches(char *fname, char *slno, char *search,
|
||||
char *tagstr)
|
||||
{
|
||||
/* vim style is ctags:
|
||||
*
|
||||
* <tagstr>\t<filename>\t<linenum_or_search>"\t<extra>
|
||||
*
|
||||
* but as mentioned above, we'll always use the line number and
|
||||
* put the search pattern (if one exists) as "extra"
|
||||
*
|
||||
* buf is used as part of vim's method of handling tags, and
|
||||
* (i think) vim frees it when you pop your tags and get replaced
|
||||
* by new ones on the tag stack.
|
||||
*/
|
||||
// vim style is ctags:
|
||||
//
|
||||
// <tagstr>\t<filename>\t<linenum_or_search>"\t<extra>
|
||||
//
|
||||
// but as mentioned above, we'll always use the line number and
|
||||
// put the search pattern (if one exists) as "extra"
|
||||
//
|
||||
// buf is used as part of vim's method of handling tags, and
|
||||
// (i think) vim frees it when you pop your tags and get replaced
|
||||
// by new ones on the tag stack.
|
||||
char *buf;
|
||||
size_t amt;
|
||||
|
||||
@@ -1311,7 +1322,7 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search,
|
||||
}
|
||||
|
||||
return buf;
|
||||
} /* cs_make_vim_style_matches */
|
||||
}
|
||||
|
||||
|
||||
/// This is kind of hokey, but i don't see an easy way round this.
|
||||
@@ -1381,7 +1392,7 @@ static char *cs_manage_matches(char **matches, char **contexts,
|
||||
}
|
||||
|
||||
return p;
|
||||
} /* cs_manage_matches */
|
||||
}
|
||||
|
||||
|
||||
/// Parse cscope output.
|
||||
@@ -1408,7 +1419,7 @@ retry:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If the line's too long for the buffer, discard it. */
|
||||
// If the line's too long for the buffer, discard it.
|
||||
if ((p = strchr(buf, '\n')) == NULL) {
|
||||
while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n')
|
||||
;
|
||||
@@ -1427,15 +1438,15 @@ retry:
|
||||
return NULL;
|
||||
if ((*linenumber = strtok(NULL, (const char *)" ")) == NULL)
|
||||
return NULL;
|
||||
*search = *linenumber + strlen(*linenumber) + 1; /* +1 to skip \0 */
|
||||
*search = *linenumber + strlen(*linenumber) + 1; // +1 to skip \0
|
||||
|
||||
/* --- nvi ---
|
||||
* If the file is older than the cscope database, that is,
|
||||
* the database was built since the file was last modified,
|
||||
* or there wasn't a search string, use the line number.
|
||||
*/
|
||||
if (strcmp(*search, "<unknown>") == 0)
|
||||
// --- nvi ---
|
||||
// If the file is older than the cscope database, that is,
|
||||
// the database was built since the file was last modified,
|
||||
// or there wasn't a search string, use the line number.
|
||||
if (strcmp(*search, "<unknown>") == 0) {
|
||||
*search = NULL;
|
||||
}
|
||||
|
||||
name = cs_resolve_file(cnumber, name);
|
||||
return name;
|
||||
@@ -1474,11 +1485,10 @@ static void cs_file_results(FILE *f, int *nummatches_a)
|
||||
|
||||
xfree(context);
|
||||
xfree(fullname);
|
||||
} /* for all matches */
|
||||
} // for all matches
|
||||
|
||||
(void)cs_read_prompt(i);
|
||||
|
||||
} /* for all cscope connections */
|
||||
} // for all cscope connections
|
||||
xfree(buf);
|
||||
}
|
||||
|
||||
@@ -1539,10 +1549,10 @@ static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a,
|
||||
*cntxts_p = cntxts;
|
||||
|
||||
xfree(buf);
|
||||
} // cs_fill_results
|
||||
}
|
||||
|
||||
|
||||
/* get the requested path components */
|
||||
// get the requested path components
|
||||
static char *cs_pathcomponents(char *path)
|
||||
{
|
||||
if (p_cspc == 0) {
|
||||
@@ -1688,7 +1698,7 @@ static int cs_read_prompt(size_t i)
|
||||
static char *eprompt = "Press the RETURN key to continue:";
|
||||
size_t epromptlen = strlen(eprompt);
|
||||
|
||||
/* compute maximum allowed len for Cscope error message */
|
||||
// compute maximum allowed len for Cscope error message
|
||||
assert(IOSIZE >= cs_emsg_len);
|
||||
size_t maxlen = IOSIZE - cs_emsg_len;
|
||||
|
||||
@@ -1738,11 +1748,12 @@ static int cs_read_prompt(size_t i)
|
||||
}
|
||||
if (ch == EOF) {
|
||||
PERROR("cs_read_prompt EOF");
|
||||
if (buf != NULL && buf[0] != NUL)
|
||||
if (buf != NULL && buf[0] != NUL) {
|
||||
(void)EMSG2(cs_emsg, buf);
|
||||
else if (p_csverbose)
|
||||
cs_reading_emsg(i); /* don't have additional information */
|
||||
cs_release_csp(i, TRUE);
|
||||
} else if (p_csverbose) {
|
||||
cs_reading_emsg(i); // don't have additional information
|
||||
}
|
||||
cs_release_csp(i, true);
|
||||
xfree(buf);
|
||||
return CSCOPE_FAILURE;
|
||||
}
|
||||
@@ -1753,9 +1764,10 @@ static int cs_read_prompt(size_t i)
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == EOF)
|
||||
continue; /* didn't find the prompt */
|
||||
break; /* did find the prompt */
|
||||
if (ch == EOF) {
|
||||
continue; // didn't find the prompt
|
||||
}
|
||||
break; // did find the prompt
|
||||
}
|
||||
|
||||
xfree(buf);
|
||||
@@ -1766,8 +1778,9 @@ static int cs_read_prompt(size_t i)
|
||||
/*
|
||||
* Used to catch and ignore SIGALRM below.
|
||||
*/
|
||||
static void sig_handler(int s) {
|
||||
/* do nothing */
|
||||
static void sig_handler(int s)
|
||||
{
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1775,7 +1788,7 @@ static void sig_handler(int s) {
|
||||
|
||||
/// Does the actual free'ing for the cs ptr with an optional flag of whether
|
||||
/// or not to free the filename. Called by cs_kill and cs_reset.
|
||||
static void cs_release_csp(size_t i, int freefnpp)
|
||||
static void cs_release_csp(size_t i, bool freefnpp)
|
||||
{
|
||||
// Trying to exit normally (not sure whether it is fit to Unix cscope)
|
||||
if (csinfo[i].to_fp != NULL) {
|
||||
@@ -1791,7 +1804,7 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
# if defined(HAVE_SIGACTION)
|
||||
struct sigaction sa, old;
|
||||
|
||||
/* Use sigaction() to limit the waiting time to two seconds. */
|
||||
// Use sigaction() to limit the waiting time to two seconds.
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = sig_handler;
|
||||
# ifdef SA_NODEFER
|
||||
@@ -1800,27 +1813,28 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
sa.sa_flags = 0;
|
||||
# endif
|
||||
sigaction(SIGALRM, &sa, &old);
|
||||
alarm(2); /* 2 sec timeout */
|
||||
alarm(2); // 2 sec timeout
|
||||
|
||||
/* Block until cscope exits or until timer expires */
|
||||
// Block until cscope exits or until timer expires
|
||||
pid = waitpid(csinfo[i].pid, &pstat, 0);
|
||||
waitpid_errno = errno;
|
||||
|
||||
/* cancel pending alarm if still there and restore signal */
|
||||
// cancel pending alarm if still there and restore signal
|
||||
alarm(0);
|
||||
sigaction(SIGALRM, &old, NULL);
|
||||
# else
|
||||
int waited;
|
||||
|
||||
/* Can't use sigaction(), loop for two seconds. First yield the CPU
|
||||
* to give cscope a chance to exit quickly. */
|
||||
// Can't use sigaction(), loop for two seconds. First yield the CPU
|
||||
// to give cscope a chance to exit quickly.
|
||||
sleep(0);
|
||||
for (waited = 0; waited < 40; ++waited) {
|
||||
pid = waitpid(csinfo[i].pid, &pstat, WNOHANG);
|
||||
waitpid_errno = errno;
|
||||
if (pid != 0)
|
||||
break; /* break unless the process is still running */
|
||||
os_delay(50L, false); /* sleep 50 ms */
|
||||
if (pid != 0) {
|
||||
break; // break unless the process is still running
|
||||
}
|
||||
os_delay(50L, false); // sleep 50 ms
|
||||
}
|
||||
# endif
|
||||
/*
|
||||
@@ -1830,7 +1844,7 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
*/
|
||||
if (pid < 0 && csinfo[i].pid > 1) {
|
||||
# ifdef ECHILD
|
||||
int alive = TRUE;
|
||||
bool alive = true;
|
||||
|
||||
if (waitpid_errno == ECHILD) {
|
||||
/*
|
||||
@@ -1845,13 +1859,13 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
int waited;
|
||||
|
||||
sleep(0);
|
||||
for (waited = 0; waited < 40; ++waited) {
|
||||
/* Check whether cscope process is still alive */
|
||||
for (waited = 0; waited < 40; waited++) {
|
||||
// Check whether cscope process is still alive
|
||||
if (kill(csinfo[i].pid, 0) != 0) {
|
||||
alive = FALSE; /* cscope process no longer exists */
|
||||
alive = false; // cscope process no longer exists
|
||||
break;
|
||||
}
|
||||
os_delay(50L, false); /* sleep 50ms */
|
||||
os_delay(50L, false); // sleep 50ms
|
||||
}
|
||||
}
|
||||
if (alive)
|
||||
@@ -1862,11 +1876,12 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else /* !UNIX */
|
||||
#else // !UNIX
|
||||
if (csinfo[i].hProc != NULL) {
|
||||
/* Give cscope a chance to exit normally */
|
||||
if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
|
||||
// Give cscope a chance to exit normally
|
||||
if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT) {
|
||||
TerminateProcess(csinfo[i].hProc, 0);
|
||||
}
|
||||
CloseHandle(csinfo[i].hProc);
|
||||
}
|
||||
#endif
|
||||
@@ -1883,7 +1898,7 @@ static void cs_release_csp(size_t i, int freefnpp)
|
||||
}
|
||||
|
||||
clear_csinfo(i);
|
||||
} /* cs_release_csp */
|
||||
}
|
||||
|
||||
|
||||
/// Calls cs_kill on all cscope connections then reinits.
|
||||
@@ -1895,7 +1910,7 @@ static int cs_reset(exarg_T *eap)
|
||||
if (csinfo_size == 0)
|
||||
return CSCOPE_SUCCESS;
|
||||
|
||||
/* malloc our db and ppath list */
|
||||
// malloc our db and ppath list
|
||||
dblist = xmalloc(csinfo_size * sizeof(char *));
|
||||
pplist = xmalloc(csinfo_size * sizeof(char *));
|
||||
fllist = xmalloc(csinfo_size * sizeof(char *));
|
||||
@@ -1908,15 +1923,14 @@ static int cs_reset(exarg_T *eap)
|
||||
cs_release_csp(i, FALSE);
|
||||
}
|
||||
|
||||
/* rebuild the cscope connection list */
|
||||
// rebuild the cscope connection list
|
||||
for (size_t i = 0; i < csinfo_size; i++) {
|
||||
if (dblist[i] != NULL) {
|
||||
cs_add_common(dblist[i], pplist[i], fllist[i]);
|
||||
if (p_csverbose) {
|
||||
/* don't use smsg_attr() because we want to display the
|
||||
* connection number in the same line as
|
||||
* "Added cscope database..."
|
||||
*/
|
||||
// don't use smsg_attr() because we want to display the
|
||||
// connection number in the same line as
|
||||
// "Added cscope database..."
|
||||
snprintf(buf, ARRAY_SIZE(buf), " (#%zu)", i);
|
||||
MSG_PUTS_ATTR(buf, HL_ATTR(HLF_R));
|
||||
}
|
||||
@@ -1933,7 +1947,7 @@ static int cs_reset(exarg_T *eap)
|
||||
msg_attr(_("All cscope databases reset"), HL_ATTR(HLF_R) | MSG_HIST);
|
||||
}
|
||||
return CSCOPE_SUCCESS;
|
||||
} /* cs_reset */
|
||||
}
|
||||
|
||||
|
||||
/// Construct the full pathname to a file found in the cscope database.
|
||||
@@ -1954,11 +1968,11 @@ static char *cs_resolve_file(size_t i, char *name)
|
||||
* copied into the tag buffer used by Vim.
|
||||
*/
|
||||
size_t len = strlen(name) + 2;
|
||||
if (csinfo[i].ppath != NULL)
|
||||
if (csinfo[i].ppath != NULL) {
|
||||
len += strlen(csinfo[i].ppath);
|
||||
else if (p_csre && csinfo[i].fname != NULL) {
|
||||
/* If 'cscoperelative' is set and ppath is not set, use cscope.out
|
||||
* path in path resolution. */
|
||||
} else if (p_csre && csinfo[i].fname != NULL) {
|
||||
// If 'cscoperelative' is set and ppath is not set, use cscope.out
|
||||
// path in path resolution.
|
||||
csdir = xmalloc(MAXPATHL);
|
||||
STRLCPY(csdir, csinfo[i].fname,
|
||||
path_tail((char_u *)csinfo[i].fname)
|
||||
@@ -1966,9 +1980,9 @@ static char *cs_resolve_file(size_t i, char *name)
|
||||
len += STRLEN(csdir);
|
||||
}
|
||||
|
||||
/* Note/example: this won't work if the cscope output already starts
|
||||
* "../.." and the prefix path is also "../..". if something like this
|
||||
* happens, you are screwed up and need to fix how you're using cscope. */
|
||||
// Note/example: this won't work if the cscope output already starts
|
||||
// "../.." and the prefix path is also "../..". if something like this
|
||||
// happens, you are screwed up and need to fix how you're using cscope.
|
||||
if (csinfo[i].ppath != NULL
|
||||
&& (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
|
||||
&& (name[0] != '/')
|
||||
@@ -1976,9 +1990,9 @@ static char *cs_resolve_file(size_t i, char *name)
|
||||
fullname = xmalloc(len);
|
||||
(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
|
||||
} else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) {
|
||||
/* Check for csdir to be non empty to avoid empty path concatenated to
|
||||
* cscope output. */
|
||||
fullname = concat_fnames((char *)csdir, name, TRUE);
|
||||
// Check for csdir to be non empty to avoid empty path concatenated to
|
||||
// cscope output.
|
||||
fullname = concat_fnames((char *)csdir, name, true);
|
||||
} else {
|
||||
fullname = xstrdup(name);
|
||||
}
|
||||
@@ -2013,7 +2027,7 @@ static int cs_show(exarg_T *eap)
|
||||
|
||||
wait_return(TRUE);
|
||||
return CSCOPE_SUCCESS;
|
||||
} /* cs_show */
|
||||
}
|
||||
|
||||
|
||||
/// Only called when VIM exits to quit any cscope sessions.
|
||||
@@ -2025,4 +2039,4 @@ void cs_end(void)
|
||||
csinfo_size = 0;
|
||||
}
|
||||
|
||||
/* the end */
|
||||
// the end
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
#ifndef NVIM_IF_CSCOPE_DEFS_H
|
||||
#define NVIM_IF_CSCOPE_DEFS_H
|
||||
|
||||
/*
|
||||
* CSCOPE support for Vim added by Andy Kahn <kahn@zk3.dec.com>
|
||||
* Ported to Win32 by Sergey Khorev <sergey.khorev@gmail.com>
|
||||
*
|
||||
* The basic idea/structure of cscope for Vim was borrowed from Nvi.
|
||||
* There might be a few lines of code that look similar to what Nvi
|
||||
* has. If this is a problem and requires inclusion of the annoying
|
||||
* BSD license, then sue me; I'm not worth much anyway.
|
||||
*/
|
||||
|
||||
// CSCOPE support for Vim added by Andy Kahn <kahn@zk3.dec.com>
|
||||
// Ported to Win32 by Sergey Khorev <sergey.khorev@gmail.com>
|
||||
//
|
||||
// The basic idea/structure of cscope for Vim was borrowed from Nvi.
|
||||
// There might be a few lines of code that look similar to what Nvi
|
||||
// has. If this is a problem and requires inclusion of the annoying
|
||||
// BSD license, then sue me; I'm not worth much anyway.
|
||||
|
||||
#if defined(UNIX)
|
||||
# include <sys/types.h> /* pid_t */
|
||||
# include <sys/types.h> // pid_t
|
||||
#endif
|
||||
|
||||
#include "nvim/os/os_defs.h"
|
||||
@@ -33,13 +30,13 @@ typedef struct {
|
||||
int (*func)(exarg_T *eap);
|
||||
char * help;
|
||||
char * usage;
|
||||
int cansplit; /* if supports splitting window */
|
||||
int cansplit; // if supports splitting window
|
||||
} cscmd_T;
|
||||
|
||||
typedef struct csi {
|
||||
char * fname; /* cscope db name */
|
||||
char * ppath; /* path to prepend (the -P option) */
|
||||
char * flags; /* additional cscope flags/options (e.g, -p2) */
|
||||
char * fname; // cscope db name
|
||||
char * ppath; // path to prepend (the -P option)
|
||||
char * flags; // additional cscope flags/options (e.g, -p2)
|
||||
#if defined(UNIX)
|
||||
pid_t pid; // PID of the connected cscope process
|
||||
#else
|
||||
@@ -51,8 +48,8 @@ typedef struct csi {
|
||||
#endif
|
||||
FileID file_id;
|
||||
|
||||
FILE * fr_fp; /* from cscope: FILE. */
|
||||
FILE * to_fp; /* to cscope: FILE. */
|
||||
FILE * fr_fp; // from cscope: FILE.
|
||||
FILE * to_fp; // to cscope: FILE.
|
||||
} csinfo_T;
|
||||
|
||||
typedef enum { Add, Find, Help, Kill, Reset, Show } csid_e;
|
||||
|
||||
@@ -56,7 +56,8 @@ int get_indent_buf(buf_T *buf, linenr_T lnum)
|
||||
// Count the size (in window cells) of the indent in line "ptr", with
|
||||
// 'tabstop' at "ts".
|
||||
// If @param list is TRUE, count only screen size for tabs.
|
||||
int get_indent_str(char_u *ptr, int ts, int list)
|
||||
int get_indent_str(const char_u *ptr, int ts, int list)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
@@ -375,12 +376,12 @@ int get_number_indent(linenr_T lnum)
|
||||
* parameters into account. Window must be specified, since it is not
|
||||
* necessarily always the current one.
|
||||
*/
|
||||
int get_breakindent_win(win_T *wp, char_u *line)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
int get_breakindent_win(win_T *wp, const char_u *line)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
static int prev_indent = 0; // Cached indent value.
|
||||
static long prev_ts = 0; // Cached tabstop value.
|
||||
static char_u *prev_line = NULL; // cached pointer to line.
|
||||
static const char_u *prev_line = NULL; // cached pointer to line.
|
||||
static varnumber_T prev_tick = 0; // Changedtick of cached value.
|
||||
int bri = 0;
|
||||
// window width minus window margin space, i.e. what rests for text
|
||||
@@ -389,7 +390,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
|
||||
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
|
||||
? number_width(wp) + 1 : 0);
|
||||
|
||||
/* used cached indent, unless pointer or 'tabstop' changed */
|
||||
// used cached indent, unless pointer or 'tabstop' changed
|
||||
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|
||||
|| prev_tick != buf_get_changedtick(wp->w_buffer)) {
|
||||
prev_line = line;
|
||||
@@ -399,21 +400,22 @@ int get_breakindent_win(win_T *wp, char_u *line)
|
||||
}
|
||||
bri = prev_indent + wp->w_p_brishift;
|
||||
|
||||
/* indent minus the length of the showbreak string */
|
||||
if (wp->w_p_brisbr)
|
||||
// indent minus the length of the showbreak string
|
||||
if (wp->w_p_brisbr) {
|
||||
bri -= vim_strsize(p_sbr);
|
||||
|
||||
/* Add offset for number column, if 'n' is in 'cpoptions' */
|
||||
}
|
||||
// Add offset for number column, if 'n' is in 'cpoptions'
|
||||
bri += win_col_off2(wp);
|
||||
|
||||
/* never indent past left window margin */
|
||||
if (bri < 0)
|
||||
// never indent past left window margin
|
||||
if (bri < 0) {
|
||||
bri = 0;
|
||||
/* always leave at least bri_min characters on the left,
|
||||
* if text width is sufficient */
|
||||
else if (bri > eff_wwidth - wp->w_p_brimin)
|
||||
} else if (bri > eff_wwidth - wp->w_p_brimin) {
|
||||
// always leave at least bri_min characters on the left,
|
||||
// if text width is sufficient
|
||||
bri = (eff_wwidth - wp->w_p_brimin < 0)
|
||||
? 0 : eff_wwidth - wp->w_p_brimin;
|
||||
}
|
||||
|
||||
return bri;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* For MSDOS some keys produce codes larger than 0xff. They are split into two
|
||||
* chars, the first one is K_NUL.
|
||||
*/
|
||||
#define K_NUL (0xce) /* for MSDOS: special key follows */
|
||||
#define K_NUL (0xce) // for MSDOS: special key follows
|
||||
|
||||
/*
|
||||
* K_SPECIAL is the first byte of a special key code and is always followed by
|
||||
@@ -78,13 +78,13 @@
|
||||
#define KS_SELECT 245
|
||||
#define K_SELECT_STRING (char_u *)"\200\365X"
|
||||
|
||||
/* Used a termcap entry that produces a normal character. */
|
||||
// Used a termcap entry that produces a normal character.
|
||||
#define KS_KEY 242
|
||||
|
||||
/* Used for click in a tab pages label. */
|
||||
// Used for click in a tab pages label.
|
||||
#define KS_TABLINE 240
|
||||
|
||||
/* Used for menu in a tab pages line. */
|
||||
// Used for menu in a tab pages line.
|
||||
#define KS_TABMENU 239
|
||||
|
||||
/*
|
||||
@@ -274,13 +274,13 @@ enum key_extra {
|
||||
#define K_TAB TERMCAP2KEY(KS_EXTRA, KE_TAB)
|
||||
#define K_S_TAB TERMCAP2KEY('k', 'B')
|
||||
|
||||
/* extra set of function keys F1-F4, for vt100 compatible xterm */
|
||||
// extra set of function keys F1-F4, for vt100 compatible xterm
|
||||
#define K_XF1 TERMCAP2KEY(KS_EXTRA, KE_XF1)
|
||||
#define K_XF2 TERMCAP2KEY(KS_EXTRA, KE_XF2)
|
||||
#define K_XF3 TERMCAP2KEY(KS_EXTRA, KE_XF3)
|
||||
#define K_XF4 TERMCAP2KEY(KS_EXTRA, KE_XF4)
|
||||
|
||||
/* extra set of cursor keys for vt100 compatible xterm */
|
||||
// extra set of cursor keys for vt100 compatible xterm
|
||||
#define K_XUP TERMCAP2KEY(KS_EXTRA, KE_XUP)
|
||||
#define K_XDOWN TERMCAP2KEY(KS_EXTRA, KE_XDOWN)
|
||||
#define K_XLEFT TERMCAP2KEY(KS_EXTRA, KE_XLEFT)
|
||||
@@ -327,7 +327,7 @@ enum key_extra {
|
||||
#define K_F36 TERMCAP2KEY('F', 'Q')
|
||||
#define K_F37 TERMCAP2KEY('F', 'R')
|
||||
|
||||
/* extra set of shifted function keys F1-F4, for vt100 compatible xterm */
|
||||
// extra set of shifted function keys F1-F4, for vt100 compatible xterm
|
||||
#define K_S_XF1 TERMCAP2KEY(KS_EXTRA, KE_S_XF1)
|
||||
#define K_S_XF2 TERMCAP2KEY(KS_EXTRA, KE_S_XF2)
|
||||
#define K_S_XF3 TERMCAP2KEY(KS_EXTRA, KE_S_XF3)
|
||||
@@ -346,7 +346,7 @@ enum key_extra {
|
||||
|
||||
#define K_S_F11 TERMCAP2KEY(KS_EXTRA, KE_S_F11)
|
||||
#define K_S_F12 TERMCAP2KEY(KS_EXTRA, KE_S_F12)
|
||||
/* K_S_F13 to K_S_F37 are currently not used */
|
||||
// K_S_F13 to K_S_F37 are currently not used
|
||||
|
||||
#define K_HELP TERMCAP2KEY('%', '1')
|
||||
#define K_UNDO TERMCAP2KEY('&', '8')
|
||||
@@ -443,8 +443,8 @@ enum key_extra {
|
||||
#define K_EVENT TERMCAP2KEY(KS_EXTRA, KE_EVENT)
|
||||
#define K_COMMAND TERMCAP2KEY(KS_EXTRA, KE_COMMAND)
|
||||
|
||||
/* Bits for modifier mask */
|
||||
/* 0x01 cannot be used, because the modifier must be 0x02 or higher */
|
||||
// Bits for modifier mask
|
||||
// 0x01 cannot be used, because the modifier must be 0x02 or higher
|
||||
#define MOD_MASK_SHIFT 0x02
|
||||
#define MOD_MASK_CTRL 0x04
|
||||
#define MOD_MASK_ALT 0x08 // aka META
|
||||
|
||||
@@ -36,38 +36,34 @@
|
||||
#define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == \
|
||||
NUL)
|
||||
|
||||
/*
|
||||
* toupper() and tolower() that use the current locale.
|
||||
* Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
|
||||
* range 0 - 255. toupper()/tolower() on some systems can't handle others.
|
||||
* Note: It is often better to use mb_tolower() and mb_toupper(), because many
|
||||
* toupper() and tolower() implementations only work for ASCII.
|
||||
*/
|
||||
// toupper() and tolower() that use the current locale.
|
||||
// Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
|
||||
// range 0 - 255. toupper()/tolower() on some systems can't handle others.
|
||||
// Note: It is often better to use mb_tolower() and mb_toupper(), because many
|
||||
// toupper() and tolower() implementations only work for ASCII.
|
||||
#define TOUPPER_LOC toupper
|
||||
#define TOLOWER_LOC tolower
|
||||
|
||||
/* toupper() and tolower() for ASCII only and ignore the current locale. */
|
||||
// toupper() and tolower() for ASCII only and ignore the current locale.
|
||||
# define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
|
||||
# define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
|
||||
|
||||
/* Like isalpha() but reject non-ASCII characters. Can't be used with a
|
||||
* special key (negative value). */
|
||||
// Like isalpha() but reject non-ASCII characters. Can't be used with a
|
||||
// special key (negative value).
|
||||
# define ASCII_ISLOWER(c) ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')
|
||||
# define ASCII_ISUPPER(c) ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')
|
||||
# define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
|
||||
# define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || ascii_isdigit(c))
|
||||
|
||||
/* Returns empty string if it is NULL. */
|
||||
// Returns empty string if it is NULL.
|
||||
#define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"")
|
||||
|
||||
/*
|
||||
* Adjust chars in a language according to 'langmap' option.
|
||||
* NOTE that there is no noticeable overhead if 'langmap' is not set.
|
||||
* When set the overhead for characters < 256 is small.
|
||||
* Don't apply 'langmap' if the character comes from the Stuff buffer or from a
|
||||
* mapping and the langnoremap option was set.
|
||||
* The do-while is just to ignore a ';' after the macro.
|
||||
*/
|
||||
// Adjust chars in a language according to 'langmap' option.
|
||||
// NOTE that there is no noticeable overhead if 'langmap' is not set.
|
||||
// When set the overhead for characters < 256 is small.
|
||||
// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
|
||||
// mapping and the langnoremap option was set.
|
||||
// The do-while is just to ignore a ';' after the macro.
|
||||
# define LANGMAP_ADJUST(c, condition) \
|
||||
do { \
|
||||
if (*p_langmap \
|
||||
@@ -83,12 +79,12 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITEBIN "wb" /* no CR-LF translation */
|
||||
#define WRITEBIN "wb" // no CR-LF translation
|
||||
#define READBIN "rb"
|
||||
#define APPENDBIN "ab"
|
||||
|
||||
/* mch_open_rw(): invoke os_open() with third argument for user R/W. */
|
||||
#if defined(UNIX) /* open in rw------- mode */
|
||||
// mch_open_rw(): invoke os_open() with third argument for user R/W.
|
||||
#if defined(UNIX) // open in rw------- mode
|
||||
# define mch_open_rw(n, f) os_open((n), (f), (mode_t)0600)
|
||||
#elif defined(WIN32)
|
||||
# define mch_open_rw(n, f) os_open((n), (f), S_IREAD | S_IWRITE)
|
||||
@@ -100,7 +96,7 @@
|
||||
|
||||
# define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
|
||||
|
||||
/* Whether to draw the vertical bar on the right side of the cell. */
|
||||
// Whether to draw the vertical bar on the right side of the cell.
|
||||
# define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
|
||||
|
||||
// MB_PTR_ADV(): advance a pointer to the next character, taking care of
|
||||
|
||||
@@ -73,7 +73,8 @@ static garray_T ga_users = GA_EMPTY_INIT_VALUE;
|
||||
* If "include_space" is set, include trailing whitespace while calculating the
|
||||
* length.
|
||||
*/
|
||||
int get_leader_len(char_u *line, char_u **flags, int backward, int include_space)
|
||||
int get_leader_len(char_u *line, char_u **flags,
|
||||
bool backward, bool include_space)
|
||||
{
|
||||
int i, j;
|
||||
int result;
|
||||
|
||||
@@ -91,7 +91,7 @@ typedef struct {
|
||||
char_u *regmust;
|
||||
int regmlen;
|
||||
char_u reghasz;
|
||||
char_u program[1]; /* actually longer.. */
|
||||
char_u program[1]; // actually longer..
|
||||
} bt_regprog_T;
|
||||
|
||||
// Structure representing a NFA state.
|
||||
@@ -102,7 +102,7 @@ struct nfa_state {
|
||||
nfa_state_T *out;
|
||||
nfa_state_T *out1;
|
||||
int id;
|
||||
int lastlist[2]; /* 0: normal, 1: recursive */
|
||||
int lastlist[2]; // 0: normal, 1: recursive
|
||||
int val;
|
||||
};
|
||||
|
||||
@@ -116,19 +116,19 @@ typedef struct {
|
||||
unsigned re_engine;
|
||||
unsigned re_flags; ///< Second argument for vim_regcomp().
|
||||
|
||||
nfa_state_T *start; /* points into state[] */
|
||||
nfa_state_T *start; // points into state[]
|
||||
|
||||
int reganch; /* pattern starts with ^ */
|
||||
int regstart; /* char at start of pattern */
|
||||
char_u *match_text; /* plain text to match with */
|
||||
int reganch; // pattern starts with ^
|
||||
int regstart; // char at start of pattern
|
||||
char_u *match_text; // plain text to match with
|
||||
|
||||
int has_zend; /* pattern contains \ze */
|
||||
int has_backref; /* pattern contains \1 .. \9 */
|
||||
int has_zend; // pattern contains \ze
|
||||
int has_backref; // pattern contains \1 .. \9
|
||||
int reghasz;
|
||||
char_u *pattern;
|
||||
int nsubexp; /* number of () */
|
||||
int nsubexp; // number of ()
|
||||
int nstate;
|
||||
nfa_state_T state[1]; /* actually longer.. */
|
||||
nfa_state_T state[1]; // actually longer..
|
||||
} nfa_regprog_T;
|
||||
|
||||
/*
|
||||
|
||||
@@ -6105,9 +6105,10 @@ void check_for_delay(int check_msg_scroll)
|
||||
&& emsg_silent == 0) {
|
||||
ui_flush();
|
||||
os_delay(1000L, true);
|
||||
emsg_on_display = FALSE;
|
||||
if (check_msg_scroll)
|
||||
msg_scroll = FALSE;
|
||||
emsg_on_display = false;
|
||||
if (check_msg_scroll) {
|
||||
msg_scroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* #ifdef __cplusplus */
|
||||
#endif // #ifdef __cplusplus
|
||||
|
||||
/* xpparm_t.flags */
|
||||
// xpparm_t.flags
|
||||
#define XDF_NEED_MINIMAL (1 << 0)
|
||||
|
||||
#define XDF_IGNORE_WHITESPACE (1 << 1)
|
||||
@@ -48,22 +48,22 @@ extern "C" {
|
||||
|
||||
#define XDF_INDENT_HEURISTIC (1 << 23)
|
||||
|
||||
/* xdemitconf_t.flags */
|
||||
// xdemitconf_t.flags
|
||||
#define XDL_EMIT_FUNCNAMES (1 << 0)
|
||||
#define XDL_EMIT_FUNCCONTEXT (1 << 2)
|
||||
|
||||
/* merge simplification levels */
|
||||
// merge simplification levels
|
||||
#define XDL_MERGE_MINIMAL 0
|
||||
#define XDL_MERGE_EAGER 1
|
||||
#define XDL_MERGE_ZEALOUS 2
|
||||
#define XDL_MERGE_ZEALOUS_ALNUM 3
|
||||
|
||||
/* merge favor modes */
|
||||
// merge favor modes
|
||||
#define XDL_MERGE_FAVOR_OURS 1
|
||||
#define XDL_MERGE_FAVOR_THEIRS 2
|
||||
#define XDL_MERGE_FAVOR_UNION 3
|
||||
|
||||
/* merge output styles */
|
||||
// merge output styles
|
||||
#define XDL_MERGE_DIFF3 1
|
||||
|
||||
typedef struct s_mmfile {
|
||||
@@ -79,7 +79,7 @@ typedef struct s_mmbuffer {
|
||||
typedef struct s_xpparam {
|
||||
unsigned long flags;
|
||||
|
||||
/* See Documentation/diff-options.txt. */
|
||||
// See Documentation/diff-options.txt.
|
||||
char **anchors;
|
||||
size_t anchors_nr;
|
||||
} xpparam_t;
|
||||
@@ -126,9 +126,9 @@ typedef struct s_xmparam {
|
||||
int level;
|
||||
int favor;
|
||||
int style;
|
||||
const char *ancestor; /* label for orig */
|
||||
const char *file1; /* label for mf1 */
|
||||
const char *file2; /* label for mf2 */
|
||||
const char *ancestor; // label for orig
|
||||
const char *file1; // label for mf1
|
||||
const char *file2; // label for mf2
|
||||
} xmparam_t;
|
||||
|
||||
#define DEFAULT_CONFLICT_MARKER_SIZE 7
|
||||
@@ -138,6 +138,6 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* #ifdef __cplusplus */
|
||||
#endif // #ifdef __cplusplus
|
||||
|
||||
#endif /* #if !defined(XDIFF_H) */
|
||||
#endif // #if !defined(XDIFF_H)
|
||||
|
||||
@@ -418,24 +418,24 @@ static int xget_indent(xrecord_t *rec)
|
||||
ret += 1;
|
||||
else if (c == '\t')
|
||||
ret += 8 - ret % 8;
|
||||
/* ignore other whitespace characters */
|
||||
// ignore other whitespace characters
|
||||
|
||||
if (ret >= MAX_INDENT)
|
||||
return MAX_INDENT;
|
||||
}
|
||||
|
||||
/* The line contains only whitespace. */
|
||||
// The line contains only whitespace.
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If more than this number of consecutive blank rows are found, just return this
|
||||
* value. This avoids requiring O(N^2) work for pathological cases, and also
|
||||
* ensures that the output of score_split fits in an int.
|
||||
* If more than this number of consecutive blank rows are found, just return
|
||||
* this value. This avoids requiring O(N^2) work for pathological cases, and
|
||||
* also ensures that the output of score_split fits in an int.
|
||||
*/
|
||||
#define MAX_BLANKS 20
|
||||
|
||||
/* Characteristics measured about a hypothetical split position. */
|
||||
// Characteristics measured about a hypothetical split position.
|
||||
struct split_measurement {
|
||||
/*
|
||||
* Is the split at the end of the file (aside from any blank lines)?
|
||||
@@ -472,10 +472,10 @@ struct split_measurement {
|
||||
};
|
||||
|
||||
struct split_score {
|
||||
/* The effective indent of this split (smaller is preferred). */
|
||||
// The effective indent of this split (smaller is preferred).
|
||||
int effective_indent;
|
||||
|
||||
/* Penalty for this split (smaller is preferred). */
|
||||
// Penalty for this split (smaller is preferred).
|
||||
int penalty;
|
||||
};
|
||||
|
||||
@@ -534,16 +534,16 @@ static void measure_split(const xdfile_t *xdf, long split,
|
||||
* integer math.
|
||||
*/
|
||||
|
||||
/* Penalty if there are no non-blank lines before the split */
|
||||
// Penalty if there are no non-blank lines before the split
|
||||
#define START_OF_FILE_PENALTY 1
|
||||
|
||||
/* Penalty if there are no non-blank lines after the split */
|
||||
// Penalty if there are no non-blank lines after the split
|
||||
#define END_OF_FILE_PENALTY 21
|
||||
|
||||
/* Multiplier for the number of blank lines around the split */
|
||||
// Multiplier for the number of blank lines around the split
|
||||
#define TOTAL_BLANK_WEIGHT (-30)
|
||||
|
||||
/* Multiplier for the number of blank lines after the split */
|
||||
// Multiplier for the number of blank lines after the split
|
||||
#define POST_BLANK_WEIGHT 6
|
||||
|
||||
/*
|
||||
@@ -610,7 +610,7 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
|
||||
post_blank = (m->indent == -1) ? 1 + m->post_blank : 0;
|
||||
total_blank = m->pre_blank + post_blank;
|
||||
|
||||
/* Penalties based on nearby blank lines: */
|
||||
// Penalties based on nearby blank lines:
|
||||
s->penalty += TOTAL_BLANK_WEIGHT * total_blank;
|
||||
s->penalty += POST_BLANK_WEIGHT * post_blank;
|
||||
|
||||
@@ -621,13 +621,13 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
|
||||
|
||||
any_blanks = (total_blank != 0);
|
||||
|
||||
/* Note that the effective indent is -1 at the end of the file: */
|
||||
// Note that the effective indent is -1 at the end of the file:
|
||||
s->effective_indent += indent;
|
||||
|
||||
if (indent == -1) {
|
||||
/* No additional adjustments needed. */
|
||||
// No additional adjustments needed.
|
||||
} else if (m->pre_indent == -1) {
|
||||
/* No additional adjustments needed. */
|
||||
// No additional adjustments needed.
|
||||
} else if (indent > m->pre_indent) {
|
||||
/*
|
||||
* The line is indented more than its predecessor.
|
||||
@@ -669,7 +669,7 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
|
||||
|
||||
static int score_cmp(struct split_score *s1, struct split_score *s2)
|
||||
{
|
||||
/* -1 if s1.effective_indent < s2->effective_indent, etc. */
|
||||
// -1 if s1.effective_indent < s2->effective_indent, etc.
|
||||
int cmp_indents = ((s1->effective_indent > s2->effective_indent) -
|
||||
(s1->effective_indent < s2->effective_indent));
|
||||
|
||||
@@ -809,7 +809,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
|
||||
group_init(xdfo, &go);
|
||||
|
||||
while (1) {
|
||||
/* If the group is empty in the to-be-compacted file, skip it: */
|
||||
// If the group is empty in the to-be-compacted file, skip it:
|
||||
if (g.end == g.start)
|
||||
goto next;
|
||||
|
||||
@@ -828,7 +828,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
|
||||
*/
|
||||
end_matching_other = -1;
|
||||
|
||||
/* Shift the group backward as much as possible: */
|
||||
// Shift the group backward as much as possible:
|
||||
while (!group_slide_up(xdf, &g, flags))
|
||||
if (group_previous(xdfo, &go))
|
||||
xdl_bug("group sync broken sliding up");
|
||||
@@ -842,7 +842,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
|
||||
if (go.end > go.start)
|
||||
end_matching_other = g.end;
|
||||
|
||||
/* Now shift the group forward as far as possible: */
|
||||
// Now shift the group forward as far as possible:
|
||||
while (1) {
|
||||
if (group_slide_down(xdf, &g, flags))
|
||||
break;
|
||||
@@ -863,7 +863,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
|
||||
*/
|
||||
|
||||
if (g.end == earliest_end) {
|
||||
/* no shifting was possible */
|
||||
// no shifting was possible
|
||||
} else if (end_matching_other != -1) {
|
||||
/*
|
||||
* Move the possibly merged group of changes back to line
|
||||
@@ -921,7 +921,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
|
||||
}
|
||||
|
||||
next:
|
||||
/* Move past the just-processed group: */
|
||||
// Move past the just-processed group:
|
||||
if (group_next(xdf, &g))
|
||||
break;
|
||||
if (group_next(xdfo, &go))
|
||||
|
||||
@@ -61,4 +61,4 @@ int xdl_do_patience_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
xdfenv_t *env);
|
||||
|
||||
#endif /* #if !defined(XDIFFI_H) */
|
||||
#endif // #if !defined(XDIFFI_H)
|
||||
|
||||
@@ -54,9 +54,9 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
|
||||
xdchange_t *xch, *xchp, *lxch;
|
||||
long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen;
|
||||
long max_ignorable = xecfg->ctxlen;
|
||||
unsigned long ignored = 0; /* number of ignored blank lines */
|
||||
unsigned long ignored = 0; // number of ignored blank lines
|
||||
|
||||
/* remove ignorable changes that are too far before other changes */
|
||||
// remove ignorable changes that are too far before other changes
|
||||
for (xchp = *xscr; xchp && xchp->ignore; xchp = xchp->next) {
|
||||
xch = xchp->next;
|
||||
|
||||
@@ -99,9 +99,9 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
|
||||
static long def_ff(const char *rec, long len, char *buf, long sz, void *priv UNUSED)
|
||||
{
|
||||
if (len > 0 &&
|
||||
(isalpha((unsigned char)*rec) || /* identifier? */
|
||||
*rec == '_' || /* also identifier? */
|
||||
*rec == '$')) { /* identifiers from VMS and other esoterico */
|
||||
(isalpha((unsigned char)*rec) || // identifier?
|
||||
*rec == '_' || // also identifier?
|
||||
*rec == '$')) { // identifiers from VMS and other esoterico
|
||||
if (len > sz)
|
||||
len = sz;
|
||||
while (0 < len && isspace((unsigned char)rec[len - 1]))
|
||||
@@ -197,7 +197,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
||||
if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
|
||||
long fs1, i1 = xch->i1;
|
||||
|
||||
/* Appended chunk? */
|
||||
// Appended chunk?
|
||||
if (i1 >= xe->xdf1.nrec) {
|
||||
long i2 = xch->i2;
|
||||
|
||||
|
||||
@@ -33,4 +33,4 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
||||
|
||||
|
||||
|
||||
#endif /* #if !defined(XEMIT_H) */
|
||||
#endif // #if !defined(XEMIT_H)
|
||||
|
||||
@@ -55,8 +55,8 @@ struct histindex {
|
||||
struct record {
|
||||
unsigned int ptr, cnt;
|
||||
struct record *next;
|
||||
} **records, /* an occurrence */
|
||||
**line_map; /* map of line to record chain */
|
||||
} **records, // an occurrence
|
||||
**line_map; // map of line to record chain
|
||||
chastore_t rcha;
|
||||
unsigned int *next_ptrs;
|
||||
unsigned int table_bits,
|
||||
@@ -128,7 +128,7 @@ static int scanA(struct histindex *index, int line1, int count1)
|
||||
*/
|
||||
NEXT_PTR(index, ptr) = rec->ptr;
|
||||
rec->ptr = ptr;
|
||||
/* cap rec->cnt at MAX_CNT */
|
||||
// cap rec->cnt at MAX_CNT
|
||||
rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1);
|
||||
LINE_MAP(index, ptr) = rec;
|
||||
goto continue_scan;
|
||||
@@ -154,7 +154,7 @@ static int scanA(struct histindex *index, int line1, int count1)
|
||||
LINE_MAP(index, ptr) = rec;
|
||||
|
||||
continue_scan:
|
||||
; /* no op */
|
||||
; // no op
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -266,7 +266,7 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
|
||||
|
||||
index.records = NULL;
|
||||
index.line_map = NULL;
|
||||
/* in case of early xdl_cha_free() */
|
||||
// in case of early xdl_cha_free()
|
||||
index.rcha.head = NULL;
|
||||
|
||||
index.table_bits = xdl_hashbits(count1);
|
||||
@@ -288,7 +288,7 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
|
||||
goto cleanup;
|
||||
memset(index.next_ptrs, 0, sz);
|
||||
|
||||
/* lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx() */
|
||||
// lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx()
|
||||
if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* defines HAVE_ATTRIBUTE_UNUSED */
|
||||
// defines HAVE_ATTRIBUTE_UNUSED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../auto/config.h"
|
||||
#endif
|
||||
|
||||
/* Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
|
||||
* can be used to check for mistakes. */
|
||||
// Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
|
||||
// can be used to check for mistakes.
|
||||
#ifdef HAVE_ATTRIBUTE_UNUSED
|
||||
# define UNUSED __attribute__((unused))
|
||||
#else
|
||||
@@ -58,4 +58,4 @@
|
||||
#include "xemit.h"
|
||||
|
||||
|
||||
#endif /* #if !defined(XINCLUDE_H) */
|
||||
#endif // #if !defined(XINCLUDE_H)
|
||||
|
||||
@@ -51,4 +51,4 @@ do { \
|
||||
} while (0)
|
||||
|
||||
|
||||
#endif /* #if !defined(XMACROS_H) */
|
||||
#endif // #if !defined(XMACROS_H)
|
||||
|
||||
@@ -69,7 +69,7 @@ struct hashmap {
|
||||
*/
|
||||
unsigned anchor : 1;
|
||||
} *entries, *first, *last;
|
||||
/* were common records found? */
|
||||
// were common records found?
|
||||
unsigned long has_matches;
|
||||
mmfile_t *file1, *file2;
|
||||
xdfenv_t *env;
|
||||
@@ -86,7 +86,7 @@ static int is_anchor(xpparam_t const *xpp, const char *line)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The argument "pass" is 1 for the first file, 2 for the second. */
|
||||
// The argument "pass" is 1 for the first file, 2 for the second.
|
||||
static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map,
|
||||
int pass)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ static int fill_hashmap(mmfile_t *file1, mmfile_t *file2,
|
||||
result->xpp = xpp;
|
||||
result->env = env;
|
||||
|
||||
/* We know exactly how large we want the hash map */
|
||||
// We know exactly how large we want the hash map
|
||||
result->alloc = count1 * 2;
|
||||
result->entries = (struct entry *)
|
||||
xdl_malloc(result->alloc * sizeof(struct entry));
|
||||
@@ -163,11 +163,11 @@ static int fill_hashmap(mmfile_t *file1, mmfile_t *file2,
|
||||
return -1;
|
||||
memset(result->entries, 0, result->alloc * sizeof(struct entry));
|
||||
|
||||
/* First, fill with entries from the first file */
|
||||
// First, fill with entries from the first file
|
||||
while (count1--)
|
||||
insert_record(xpp, line1++, result, 1);
|
||||
|
||||
/* Then search for matches in the second file */
|
||||
// Then search for matches in the second file
|
||||
while (count2--)
|
||||
insert_record(xpp, line2++, result, 2);
|
||||
|
||||
@@ -185,13 +185,13 @@ static int binary_search(struct entry **sequence, int longest,
|
||||
|
||||
while (left + 1 < right) {
|
||||
int middle = left + (right - left) / 2;
|
||||
/* by construction, no two entries can be equal */
|
||||
// by construction, no two entries can be equal
|
||||
if (sequence[middle]->line2 > entry->line2)
|
||||
right = middle;
|
||||
else
|
||||
left = middle;
|
||||
}
|
||||
/* return the index in "sequence", _not_ the sequence length */
|
||||
// return the index in "sequence", _not_ the sequence length
|
||||
return left;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
|
||||
*/
|
||||
int anchor_i = -1;
|
||||
|
||||
/* Added to silence Coverity. */
|
||||
// Added to silence Coverity.
|
||||
if (sequence == NULL)
|
||||
return map->first;
|
||||
|
||||
@@ -237,13 +237,13 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
|
||||
}
|
||||
}
|
||||
|
||||
/* No common unique lines were found */
|
||||
// No common unique lines were found
|
||||
if (!longest) {
|
||||
xdl_free(sequence);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Iterate starting at the last element, adjusting the "next" members */
|
||||
// Iterate starting at the last element, adjusting the "next" members
|
||||
entry = sequence[longest - 1];
|
||||
entry->next = NULL;
|
||||
while (entry->previous) {
|
||||
@@ -273,7 +273,7 @@ static int walk_common_sequence(struct hashmap *map, struct entry *first,
|
||||
int next1, next2;
|
||||
|
||||
for (;;) {
|
||||
/* Try to grow the line ranges of common lines */
|
||||
// Try to grow the line ranges of common lines
|
||||
if (first) {
|
||||
next1 = first->line1;
|
||||
next2 = first->line2;
|
||||
@@ -292,7 +292,7 @@ static int walk_common_sequence(struct hashmap *map, struct entry *first,
|
||||
line2++;
|
||||
}
|
||||
|
||||
/* Recurse */
|
||||
// Recurse
|
||||
if (next1 > line1 || next2 > line2) {
|
||||
struct hashmap submap;
|
||||
|
||||
@@ -343,7 +343,7 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
|
||||
struct entry *first;
|
||||
int result = 0;
|
||||
|
||||
/* trivial case: one side is empty */
|
||||
// trivial case: one side is empty
|
||||
if (!count1) {
|
||||
while(count2--)
|
||||
env->xdf2.rchg[line2++ - 1] = 1;
|
||||
@@ -359,7 +359,7 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
|
||||
line1, count1, line2, count2))
|
||||
return -1;
|
||||
|
||||
/* are there any matching lines at all? */
|
||||
// are there any matching lines at all?
|
||||
if (!map.has_matches) {
|
||||
while(count1--)
|
||||
env->xdf1.rchg[line1++ - 1] = 1;
|
||||
@@ -387,7 +387,7 @@ int xdl_do_patience_diff(mmfile_t *file1, mmfile_t *file2,
|
||||
if (xdl_prepare_env(file1, file2, xpp, env) < 0)
|
||||
return -1;
|
||||
|
||||
/* environment is cleaned up in xdl_diff() */
|
||||
// environment is cleaned up in xdl_diff()
|
||||
return patience_diff(file1, file2, xpp, env,
|
||||
1, env->xdf1.nrec, 1, env->xdf2.nrec);
|
||||
}
|
||||
|
||||
@@ -31,4 +31,4 @@ void xdl_free_env(xdfenv_t *xe);
|
||||
|
||||
|
||||
|
||||
#endif /* #if !defined(XPREPARE_H) */
|
||||
#endif // #if !defined(XPREPARE_H)
|
||||
|
||||
@@ -64,4 +64,4 @@ typedef struct s_xdfenv {
|
||||
|
||||
|
||||
|
||||
#endif /* #if !defined(XTYPES_H) */
|
||||
#endif // #if !defined(XTYPES_H)
|
||||
|
||||
@@ -168,7 +168,7 @@ static int ends_with_optional_cr(const char *l, long s, long i)
|
||||
s--;
|
||||
if (s == i)
|
||||
return 1;
|
||||
/* do not ignore CR at the end of an incomplete line */
|
||||
// do not ignore CR at the end of an incomplete line
|
||||
if (complete && s == i + 1 && l[i] == '\r')
|
||||
return 1;
|
||||
return 0;
|
||||
@@ -208,7 +208,7 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
|
||||
} else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
|
||||
while (i1 < s1 && i2 < s2) {
|
||||
if (XDL_ISSPACE(l1[i1]) && XDL_ISSPACE(l2[i2])) {
|
||||
/* Skip matching spaces and try again */
|
||||
// Skip matching spaces and try again
|
||||
while (i1 < s1 && XDL_ISSPACE(l1[i1]))
|
||||
i1++;
|
||||
while (i2 < s2 && XDL_ISSPACE(l2[i2]))
|
||||
@@ -224,7 +224,7 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
|
||||
i2++;
|
||||
}
|
||||
} else if (flags & XDF_IGNORE_CR_AT_EOL) {
|
||||
/* Find the first difference and see how the line ends */
|
||||
// Find the first difference and see how the line ends
|
||||
while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) {
|
||||
i1++;
|
||||
i2++;
|
||||
@@ -261,7 +261,7 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
|
||||
|
||||
for (; ptr < top && *ptr != '\n'; ptr++) {
|
||||
if (cr_at_eol_only) {
|
||||
/* do not ignore CR at the end of an incomplete line */
|
||||
// do not ignore CR at the end of an incomplete line
|
||||
if (*ptr == '\r' &&
|
||||
(ptr + 1 < top && ptr[1] == '\n'))
|
||||
continue;
|
||||
@@ -274,7 +274,7 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
|
||||
ptr++;
|
||||
at_eol = (top <= ptr + 1 || ptr[1] == '\n');
|
||||
if (flags & XDF_IGNORE_WHITESPACE)
|
||||
; /* already handled */
|
||||
; // already handled
|
||||
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
|
||||
&& !at_eol) {
|
||||
ha += (ha << 5);
|
||||
|
||||
@@ -44,4 +44,4 @@ int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp,
|
||||
|
||||
|
||||
|
||||
#endif /* #if !defined(XUTILS_H) */
|
||||
#endif // #if !defined(XUTILS_H)
|
||||
|
||||
Reference in New Issue
Block a user