58
58
bool file_id_valid;
60
int sn_prof_on; /* TRUE when script is/was profiled */
61
int sn_pr_force; /* forceit: profile functions in this script */
62
proftime_T sn_pr_child; /* time set when going into first child */
63
int sn_pr_nest; /* nesting for sn_pr_child */
64
/* profiling the script as a whole */
65
int sn_pr_count; /* nr of times sourced */
66
proftime_T sn_pr_total; /* time spent in script + children */
67
proftime_T sn_pr_self; /* time spent in script itself */
68
proftime_T sn_pr_start; /* time at script start */
69
proftime_T sn_pr_children; /* time in children after script start */
70
/* profiling the script per line */
71
garray_T sn_prl_ga; /* things stored for every line */
72
proftime_T sn_prl_start; /* start time for current line */
73
proftime_T sn_prl_children; /* time spent in children for this line */
74
proftime_T sn_prl_wait; /* wait start time for current line */
75
int sn_prl_idx; /* index of line being timed; -1 if none */
76
int sn_prl_execed; /* line being timed was executed */
60
bool sn_prof_on; ///< true when script is/was profiled
61
int sn_pr_force; ///< forceit: profile functions in this script
62
proftime_T sn_pr_child; ///< time set when going into first child
63
int sn_pr_nest; ///< nesting for sn_pr_child
64
// profiling the script as a whole
65
int sn_pr_count; ///< nr of times sourced
66
proftime_T sn_pr_total; ///< time spent in script + children
67
proftime_T sn_pr_self; ///< time spent in script itself
68
proftime_T sn_pr_start; ///< time at script start
69
proftime_T sn_pr_children; ///< time in children after script start
70
// profiling the script per line
71
garray_T sn_prl_ga; ///< things stored for every line
72
proftime_T sn_prl_start; ///< start time for current line
73
proftime_T sn_prl_children; ///< time spent in children for this line
74
proftime_T sn_prl_wait; ///< wait start time for current line
75
linenr_T sn_prl_idx; ///< index of line being timed; -1 if none
76
int sn_prl_execed; ///< line being timed was executed
79
79
static garray_T script_items = {0, 0, sizeof(scriptitem_T), 4, NULL};
82
82
/* Struct used in sn_prl_ga for every line of a script. */
83
83
typedef struct sn_prl_S {
84
int snp_count; /* nr of times line was executed */
85
proftime_T sn_prl_total; /* time spent in a line + children */
86
proftime_T sn_prl_self; /* time spent in a line itself */
84
int snp_count; ///< nr of times line was executed
85
proftime_T sn_prl_total; ///< time spent in a line + children
86
proftime_T sn_prl_self; ///< time spent in a line itself
93
93
* sourcing can be done recursively.
95
95
struct source_cookie {
96
FILE *fp; /* opened file for sourcing */
97
char_u *nextline; /* if not NULL: line that was read ahead */
98
int finished; /* ":finish" used */
96
FILE *fp; ///< opened file for sourcing
97
char_u *nextline; ///< if not NULL: line that was read ahead
98
int finished; ///< ":finish" used
99
99
#if defined(USE_CRNL)
100
int fileformat; /* EOL_UNKNOWN, EOL_UNIX or EOL_DOS */
101
int error; /* TRUE if LF found after CR-LF */
100
int fileformat; ///< EOL_UNKNOWN, EOL_UNIX or EOL_DOS
101
int error; ///< TRUE if LF found after CR-LF
103
linenr_T breakpoint; /* next line with breakpoint or zero */
104
char_u *fname; /* name of sourced file */
105
int dbg_tick; /* debug_tick when breakpoint was set */
106
int level; /* top nesting level of sourced file */
107
vimconv_T conv; /* type of conversion */
103
linenr_T breakpoint; ///< next line with breakpoint or zero
104
char_u *fname; ///< name of sourced file
105
int dbg_tick; ///< debug_tick when breakpoint was set
106
int level; ///< top nesting level of sourced file
107
vimconv_T conv; ///< type of conversion
110
110
# define PRL_ITEM(si, idx) (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
281
281
redraw_all_later(NOT_VALID);
282
282
need_wait_return = FALSE;
283
283
msg_scroll = save_msg_scroll;
284
lines_left = Rows - 1;
284
lines_left = (int)(Rows - 1);
285
285
State = save_State;
286
286
did_emsg = save_did_emsg;
287
287
cmd_silent = save_cmd_silent;
392
392
* This is a grow-array of structs.
395
int dbg_nr; /* breakpoint number */
396
int dbg_type; /* DBG_FUNC or DBG_FILE */
397
char_u *dbg_name; /* function or file name */
398
regprog_T *dbg_prog; /* regexp program */
399
linenr_T dbg_lnum; /* line number in function or file */
400
int dbg_forceit; /* ! used */
395
int dbg_nr; ///< breakpoint number
396
int dbg_type; ///< DBG_FUNC or DBG_FILE
397
char_u *dbg_name; ///< function or file name
398
regprog_T *dbg_prog; ///< regexp program
399
linenr_T dbg_lnum; ///< line number in function or file
400
int dbg_forceit; ///< ! used
403
403
static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL};
565
565
if (ascii_isdigit(*eap->arg)) {
566
/* ":breakdel {nr}" */
567
nr = atol((char *)eap->arg);
568
for (int i = 0; i < gap->ga_len; ++i)
567
nr = atoi((char *)eap->arg);
568
for (int i = 0; i < gap->ga_len; ++i) {
569
569
if (DEBUGGY(gap, i).dbg_nr == nr) {
573
574
} else if (*eap->arg == '*') {
603
604
if (todel < gap->ga_len)
604
605
memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1),
605
(gap->ga_len - todel) * sizeof(struct debuggy));
606
if (eap->cmdidx == CMD_breakdel)
606
(size_t)(gap->ga_len - todel) * sizeof(struct debuggy));
607
if (eap->cmdidx == CMD_breakdel) {
612
615
/* If all breakpoints were removed clear the array. */
811
814
/* Command line expansion for :profile. */
813
PEXP_SUBCMD, /* expand :profile sub-commands */
814
PEXP_FUNC /* expand :profile func {funcname} */
816
PEXP_SUBCMD, ///< expand :profile sub-commands
817
PEXP_FUNC ///< expand :profile func {funcname}
817
820
static char *pexpand_cmds[] = {
1521
1524
xfree(ARGLIST[match].ae_fname);
1522
1525
memmove(ARGLIST + match, ARGLIST + match + 1,
1523
(ARGCOUNT - match - 1) * sizeof(aentry_T));
1526
(size_t)(ARGCOUNT - match - 1) * sizeof(aentry_T));
1524
1527
--ALIST(curwin)->al_ga.ga_len;
1525
1528
if (curwin->w_arg_idx > match)
1526
1529
--curwin->w_arg_idx;
1537
1540
int i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data,
1538
1541
&exp_count, &exp_files, EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND);
1539
1542
ga_clear(&new_ga);
1542
if (exp_count == 0) {
1543
if (i == FAIL || exp_count == 0) {
1543
1544
EMSG(_(e_nomatch));
1844
1846
void ex_argdelete(exarg_T *eap)
1846
1848
if (eap->addr_count > 0) {
1847
/* ":1,4argdel": Delete all arguments in the range. */
1848
if (eap->line2 > ARGCOUNT)
1849
// ":1,4argdel": Delete all arguments in the range.
1850
if (eap->line2 > ARGCOUNT) {
1849
1851
eap->line2 = ARGCOUNT;
1850
int n = eap->line2 - eap->line1 + 1;
1851
if (*eap->arg != NUL || n <= 0)
1853
linenr_T n = eap->line2 - eap->line1 + 1;
1854
if (*eap->arg != NUL || n <= 0) {
1852
1855
EMSG(_(e_invarg));
1854
for (int i = eap->line1; i <= eap->line2; ++i)
1857
for (linenr_T i = eap->line1; i <= eap->line2; ++i) {
1855
1858
xfree(ARGLIST[i - 1].ae_fname);
1856
1860
memmove(ARGLIST + eap->line1 - 1, ARGLIST + eap->line2,
1857
(size_t)((ARGCOUNT - eap->line2) * sizeof(aentry_T)));
1858
ALIST(curwin)->al_ga.ga_len -= n;
1859
if (curwin->w_arg_idx >= eap->line2)
1860
curwin->w_arg_idx -= n;
1861
else if (curwin->w_arg_idx > eap->line1)
1862
curwin->w_arg_idx = eap->line1;
1861
(size_t)(ARGCOUNT - eap->line2) * sizeof(aentry_T));
1862
ALIST(curwin)->al_ga.ga_len -= (int)n;
1863
if (curwin->w_arg_idx >= eap->line2) {
1864
curwin->w_arg_idx -= (int)n;
1865
} else if (curwin->w_arg_idx > eap->line1) {
1866
curwin->w_arg_idx = (int)eap->line1;
1864
1869
} else if (*eap->arg == NUL)
1865
1870
EMSG(_(e_argreq));
2098
2104
after = ARGCOUNT;
2099
2105
if (after < ARGCOUNT)
2100
2106
memmove(&(ARGLIST[after + count]), &(ARGLIST[after]),
2101
(ARGCOUNT - after) * sizeof(aentry_T));
2107
(size_t)(ARGCOUNT - after) * sizeof(aentry_T));
2102
2108
for (int i = 0; i < count; ++i) {
2103
2109
ARGLIST[after + i].ae_fname = files[i];
2104
2110
ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED);
2571
2577
while (script_items.ga_len < current_SID) {
2572
2578
++script_items.ga_len;
2573
2579
SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
2574
SCRIPT_ITEM(script_items.ga_len).sn_prof_on = FALSE;
2580
SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false;
2576
2582
si = &SCRIPT_ITEM(current_SID);
2577
2583
si->sn_name = fname_exp;
3387
3393
list_append_string(args, script ? script : eap->arg, -1);
3388
3394
// current range
3389
list_append_number(args, eap->line1);
3390
list_append_number(args, eap->line2);
3395
list_append_number(args, (int)eap->line1);
3396
list_append_number(args, (int)eap->line2);
3391
3397
(void)eval_call_provider(name, "execute", args);
3404
3410
list_append_string(args, buffer, -1);
3405
3411
// current range
3406
list_append_number(args, eap->line1);
3407
list_append_number(args, eap->line2);
3412
list_append_number(args, (int)eap->line1);
3413
list_append_number(args, (int)eap->line2);
3408
3414
(void)eval_call_provider(name, "execute_file", args);
3411
3417
static void script_host_do_range(char *name, exarg_T *eap)
3413
3419
list_T *args = list_alloc();
3414
list_append_number(args, eap->line1);
3415
list_append_number(args, eap->line2);
3420
list_append_number(args, (int)eap->line1);
3421
list_append_number(args, (int)eap->line2);
3416
3422
list_append_string(args, eap->arg, -1);
3417
3423
(void)eval_call_provider(name, "do_range", args);