~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to src/nvim/ex_cmds2.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
  char_u      *sn_name;
58
58
  bool file_id_valid;
59
59
  FileID file_id;
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
77
77
} scriptitem_T;
78
78
 
79
79
static garray_T script_items = {0, 0, sizeof(scriptitem_T), 4, NULL};
81
81
 
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
87
87
} sn_prl_T;
88
88
 
89
89
/*
93
93
 * sourcing can be done recursively.
94
94
 */
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
102
102
#endif
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
108
108
};
109
109
 
110
110
#  define PRL_ITEM(si, idx)     (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
272
272
 
273
273
      xfree(cmdline);
274
274
    }
275
 
    lines_left = Rows - 1;
 
275
    lines_left = (int)(Rows - 1);
276
276
  }
277
277
  xfree(cmdline);
278
278
 
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.
393
393
 */
394
394
struct debuggy {
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
401
401
};
402
402
 
403
403
static garray_T dbg_breakp = {0, 0, sizeof(struct debuggy), 4, NULL};
563
563
  }
564
564
 
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)
 
566
    // ":breakdel {nr}"
 
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) {
570
570
        todel = i;
571
571
        break;
572
572
      }
 
573
    }
573
574
  } else if (*eap->arg == '*') {
574
575
    todel = 0;
575
576
    del_all = TRUE;
602
603
      --gap->ga_len;
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) {
607
608
        ++debug_tick;
608
 
      if (!del_all)
 
609
      }
 
610
      if (!del_all) {
609
611
        break;
 
612
      }
610
613
    }
611
614
 
612
615
    /* If all breakpoints were removed clear the array. */
810
813
 
811
814
/* Command line expansion for :profile. */
812
815
static enum {
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}
815
818
} pexpand_what;
816
819
 
817
820
static char *pexpand_cmds[] = {
892
895
  for (int id = 1; id <= script_items.ga_len; id++) {
893
896
    scriptitem_T *si = &SCRIPT_ITEM(id);
894
897
    if (si->sn_prof_on) {
895
 
      si->sn_prof_on      = 0;
 
898
      si->sn_prof_on      = false;
896
899
      si->sn_pr_force     = 0;
897
900
      si->sn_pr_child     = profile_zero();
898
901
      si->sn_pr_nest      = 0;
949
952
 
950
953
  ga_init(&si->sn_prl_ga, sizeof(sn_prl_T), 100);
951
954
  si->sn_prl_idx = -1;
952
 
  si->sn_prof_on = TRUE;
 
955
  si->sn_prof_on = true;
953
956
  si->sn_pr_nest = 0;
954
957
}
955
958
 
1255
1258
  int save;
1256
1259
  int i;
1257
1260
  int bufnum = 0;
1258
 
  int bufcount = 0;
 
1261
  size_t bufcount = 0;
1259
1262
  int         *bufnrs;
1260
1263
 
1261
1264
  FOR_ALL_BUFFERS(buf) {
1520
1523
          didone = TRUE;
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);
1540
 
    if (i == FAIL)
1541
 
      return FAIL;
1542
 
    if (exp_count == 0) {
 
1543
    if (i == FAIL || exp_count == 0) {
1543
1544
      EMSG(_(e_nomatch));
1544
1545
      return FAIL;
1545
1546
    }
1702
1703
{
1703
1704
  int i;
1704
1705
 
1705
 
  if (eap->addr_count > 0)
1706
 
    i = eap->line2 - 1;
1707
 
  else
 
1706
  if (eap->addr_count > 0) {
 
1707
    i = (int)eap->line2 - 1;
 
1708
  } else {
1708
1709
    i = curwin->w_arg_idx;
 
1710
  }
1709
1711
  do_argfile(eap, i);
1710
1712
}
1711
1713
 
1844
1846
void ex_argdelete(exarg_T *eap)
1845
1847
{
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)
 
1852
    }
 
1853
    linenr_T n = eap->line2 - eap->line1 + 1;
 
1854
    if (*eap->arg != NUL || n <= 0) {
1852
1855
      EMSG(_(e_invarg));
1853
 
    else {
1854
 
      for (int i = eap->line1; i <= eap->line2; ++i)
 
1856
    } else {
 
1857
      for (linenr_T i = eap->line1; i <= eap->line2; ++i) {
1855
1858
        xfree(ARGLIST[i - 1].ae_fname);
 
1859
      }
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;
 
1867
      }
1863
1868
    }
1864
1869
  } else if (*eap->arg == NUL)
1865
1870
    EMSG(_(e_argreq));
1909
1914
        }
1910
1915
        break;
1911
1916
      case CMD_argdo:
1912
 
        i = eap->line1 - 1;
 
1917
        i = (int)eap->line1 - 1;
1913
1918
        break;
1914
1919
      default:
1915
1920
        break;
1942
1947
        ex_cc(eap);
1943
1948
 
1944
1949
        buf = curbuf;
1945
 
        i = eap->line1 - 1;
 
1950
        i = (int)eap->line1 - 1;
1946
1951
        if (eap->addr_count <= 0) {
1947
1952
          // Default to all quickfix/location list entries.
1948
 
          eap->line2 = qf_size;
 
1953
          assert(qf_size < MAXLNUM);
 
1954
          eap->line2 = (linenr_T)qf_size;
1949
1955
        }
1950
1956
      }
1951
1957
    } else {
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;
2575
2581
    }
2576
2582
    si = &SCRIPT_ITEM(current_SID);
2577
2583
    si->sn_name = fname_exp;
3386
3392
    // script
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);
3392
3398
  }
3393
3399
 
3403
3409
  // filename
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);
3409
3415
}
3410
3416
 
3411
3417
static void script_host_do_range(char *name, exarg_T *eap)
3412
3418
{
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);
3418
3424
}