Mercurial > vim
comparison src/ex_docmd.c @ 41:f529edb9bab3 v7.0025
updated for version 7.0025
author | vimboss |
---|---|
date | Mon, 27 Dec 2004 21:59:20 +0000 |
parents | f1d2a58883b9 |
children | c75153d791d0 |
comparison
equal
deleted
inserted
replaced
40:f1d2a58883b9 | 41:f529edb9bab3 |
---|---|
110 static char_u *getargcmd __ARGS((char_u **)); | 110 static char_u *getargcmd __ARGS((char_u **)); |
111 static char_u *skip_cmd_arg __ARGS((char_u *p, int rembs)); | 111 static char_u *skip_cmd_arg __ARGS((char_u *p, int rembs)); |
112 static int getargopt __ARGS((exarg_T *eap)); | 112 static int getargopt __ARGS((exarg_T *eap)); |
113 #ifndef FEAT_QUICKFIX | 113 #ifndef FEAT_QUICKFIX |
114 # define ex_make ex_ni | 114 # define ex_make ex_ni |
115 # define ex_cbuffer ex_ni | |
115 # define ex_cc ex_ni | 116 # define ex_cc ex_ni |
116 # define ex_cnext ex_ni | 117 # define ex_cnext ex_ni |
117 # define ex_cfile ex_ni | 118 # define ex_cfile ex_ni |
118 # define qf_list ex_ni | 119 # define qf_list ex_ni |
119 # define qf_age ex_ni | 120 # define qf_age ex_ni |
120 # define ex_helpgrep ex_ni | 121 # define ex_helpgrep ex_ni |
122 # define ex_vimgrep ex_ni | |
121 #endif | 123 #endif |
122 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_WINDOWS) | 124 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_WINDOWS) |
123 # define ex_cclose ex_ni | 125 # define ex_cclose ex_ni |
124 # define ex_copen ex_ni | 126 # define ex_copen ex_ni |
125 # define ex_cwindow ex_ni | 127 # define ex_cwindow ex_ni |
1467 if (ga_grow(gap, 1) == FAIL) | 1469 if (ga_grow(gap, 1) == FAIL) |
1468 return FAIL; | 1470 return FAIL; |
1469 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); | 1471 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); |
1470 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum; | 1472 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum; |
1471 ++gap->ga_len; | 1473 ++gap->ga_len; |
1472 --gap->ga_room; | |
1473 return OK; | 1474 return OK; |
1474 } | 1475 } |
1475 | 1476 |
1476 /* | 1477 /* |
1477 * Free the lines stored for a ":while" loop. | 1478 * Free the lines stored for a ":while" loop. |
1482 { | 1483 { |
1483 while (gap->ga_len > 0) | 1484 while (gap->ga_len > 0) |
1484 { | 1485 { |
1485 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | 1486 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); |
1486 --gap->ga_len; | 1487 --gap->ga_len; |
1487 ++gap->ga_room; | |
1488 } | 1488 } |
1489 } | 1489 } |
1490 #endif | 1490 #endif |
1491 | 1491 |
1492 /* | 1492 /* |
2106 } | 2106 } |
2107 #endif | 2107 #endif |
2108 | 2108 |
2109 #ifdef FEAT_QUICKFIX | 2109 #ifdef FEAT_QUICKFIX |
2110 /* | 2110 /* |
2111 * For the :make and :grep commands we insert the 'makeprg'/'grepprg' | 2111 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
2112 * option here, so things like % get expanded. | 2112 * option here, so things like % get expanded. |
2113 * Don't do it when ":vimgrep" is used for ":grep". | |
2113 */ | 2114 */ |
2114 if (ea.cmdidx == CMD_make || ea.cmdidx == CMD_grep | 2115 if ((ea.cmdidx == CMD_make |
2115 || ea.cmdidx == CMD_grepadd) | 2116 || ea.cmdidx == CMD_grep || ea.cmdidx == CMD_grepadd) |
2117 && !grep_internal(&ea)) | |
2116 { | 2118 { |
2117 char_u *new_cmdline; | 2119 char_u *new_cmdline; |
2118 char_u *program; | 2120 char_u *program; |
2119 char_u *pos; | 2121 char_u *pos; |
2120 char_u *ptr; | 2122 char_u *ptr; |
4198 separate_nextcmd(eap) | 4200 separate_nextcmd(eap) |
4199 exarg_T *eap; | 4201 exarg_T *eap; |
4200 { | 4202 { |
4201 char_u *p; | 4203 char_u *p; |
4202 | 4204 |
4203 for (p = eap->arg; *p; ++p) | 4205 p = eap->arg; |
4206 #ifdef FEAT_QUICKFIX | |
4207 if (eap->cmdidx == CMD_vimgrep | |
4208 || eap->cmdidx == CMD_vimgrepadd | |
4209 || grep_internal(eap)) | |
4210 { | |
4211 /* Skip over the pattern. */ | |
4212 p = skip_regexp(p + 1, *p, TRUE, NULL); | |
4213 if (*p == *eap->arg) | |
4214 ++p; | |
4215 } | |
4216 #endif | |
4217 | |
4218 for ( ; *p; mb_ptr_adv(p)) | |
4204 { | 4219 { |
4205 if (*p == Ctrl_V) | 4220 if (*p == Ctrl_V) |
4206 { | 4221 { |
4207 if (eap->argt & (USECTRLV | XFILE)) | 4222 if (eap->argt & (USECTRLV | XFILE)) |
4208 ++p; /* skip CTRL-V and next char */ | 4223 ++p; /* skip CTRL-V and next char */ |
4216 /* Skip over `=expr` when wildcards are expanded. */ | 4231 /* Skip over `=expr` when wildcards are expanded. */ |
4217 else if (p[0] == '`' && p[1] == '=') | 4232 else if (p[0] == '`' && p[1] == '=') |
4218 { | 4233 { |
4219 p += 2; | 4234 p += 2; |
4220 (void)skip_expr(&p); | 4235 (void)skip_expr(&p); |
4221 if (*p == '`') | |
4222 ++p; | |
4223 } | 4236 } |
4224 #endif | 4237 #endif |
4225 | 4238 |
4226 /* Check for '"': start of comment or '|': next command */ | 4239 /* Check for '"': start of comment or '|': next command */ |
4227 /* :@" and :*" do not start a comment! | 4240 /* :@" and :*" do not start a comment! |
4248 eap->nextcmd = check_nextcmd(p); | 4261 eap->nextcmd = check_nextcmd(p); |
4249 *p = NUL; | 4262 *p = NUL; |
4250 break; | 4263 break; |
4251 } | 4264 } |
4252 } | 4265 } |
4253 #ifdef FEAT_MBYTE | 4266 } |
4254 else if (has_mbyte) | 4267 |
4255 p += (*mb_ptr2len_check)(p) - 1; /* skip bytes of multi-byte char */ | |
4256 #endif | |
4257 } | |
4258 if (!(eap->argt & NOTRLCOM)) /* remove trailing spaces */ | 4268 if (!(eap->argt & NOTRLCOM)) /* remove trailing spaces */ |
4259 del_trailing_spaces(eap->arg); | 4269 del_trailing_spaces(eap->arg); |
4260 } | 4270 } |
4261 | 4271 |
4262 /* | 4272 /* |
4778 | 4788 |
4779 cmd = USER_CMD_GA(gap, i); | 4789 cmd = USER_CMD_GA(gap, i); |
4780 mch_memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T)); | 4790 mch_memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T)); |
4781 | 4791 |
4782 ++gap->ga_len; | 4792 ++gap->ga_len; |
4783 --gap->ga_room; | |
4784 | 4793 |
4785 cmd->uc_name = p; | 4794 cmd->uc_name = p; |
4786 } | 4795 } |
4787 | 4796 |
4788 cmd->uc_rep = rep_buf; | 4797 cmd->uc_rep = rep_buf; |
5290 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | 5299 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) |
5291 vim_free(cmd->uc_compl_arg); | 5300 vim_free(cmd->uc_compl_arg); |
5292 # endif | 5301 # endif |
5293 | 5302 |
5294 --gap->ga_len; | 5303 --gap->ga_len; |
5295 ++gap->ga_room; | |
5296 | 5304 |
5297 if (i < gap->ga_len) | 5305 if (i < gap->ga_len) |
5298 mch_memmove(cmd, cmd + 1, (gap->ga_len - i) * sizeof(ucmd_T)); | 5306 mch_memmove(cmd, cmd + 1, (gap->ga_len - i) * sizeof(ucmd_T)); |
5299 } | 5307 } |
5300 | 5308 |
6169 } | 6177 } |
6170 | 6178 |
6171 /* | 6179 /* |
6172 * Set up the new argument list. | 6180 * Set up the new argument list. |
6173 */ | 6181 */ |
6174 alist_set(ALIST(curwin), filec, filev, FALSE); | 6182 alist_set(ALIST(curwin), filec, filev, FALSE, NULL, 0); |
6175 | 6183 |
6176 /* | 6184 /* |
6177 * Move to the first file. | 6185 * Move to the first file. |
6178 */ | 6186 */ |
6179 /* Fake up a minimal "next" command for do_argfile() */ | 6187 /* Fake up a minimal "next" command for do_argfile() */ |
6255 #endif | 6263 #endif |
6256 | 6264 |
6257 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) || defined(PROTO) | 6265 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) || defined(PROTO) |
6258 /* | 6266 /* |
6259 * Expand the file names in the global argument list. | 6267 * Expand the file names in the global argument list. |
6268 * If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer | |
6269 * numbers to be re-used. | |
6260 */ | 6270 */ |
6261 void | 6271 void |
6262 alist_expand() | 6272 alist_expand(fnum_list, fnum_len) |
6273 int *fnum_list; | |
6274 int fnum_len; | |
6263 { | 6275 { |
6264 char_u **old_arg_files; | 6276 char_u **old_arg_files; |
6277 int old_arg_count; | |
6265 char_u **new_arg_files; | 6278 char_u **new_arg_files; |
6266 int new_arg_file_count; | 6279 int new_arg_file_count; |
6267 char_u *save_p_su = p_su; | 6280 char_u *save_p_su = p_su; |
6268 int i; | 6281 int i; |
6269 | 6282 |
6273 p_su = empty_option; | 6286 p_su = empty_option; |
6274 old_arg_files = (char_u **)alloc((unsigned)(sizeof(char_u *) * GARGCOUNT)); | 6287 old_arg_files = (char_u **)alloc((unsigned)(sizeof(char_u *) * GARGCOUNT)); |
6275 if (old_arg_files != NULL) | 6288 if (old_arg_files != NULL) |
6276 { | 6289 { |
6277 for (i = 0; i < GARGCOUNT; ++i) | 6290 for (i = 0; i < GARGCOUNT; ++i) |
6278 old_arg_files[i] = GARGLIST[i].ae_fname; | 6291 old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname); |
6279 if (expand_wildcards(GARGCOUNT, old_arg_files, | 6292 old_arg_count = GARGCOUNT; |
6293 if (expand_wildcards(old_arg_count, old_arg_files, | |
6280 &new_arg_file_count, &new_arg_files, | 6294 &new_arg_file_count, &new_arg_files, |
6281 EW_FILE|EW_NOTFOUND|EW_ADDSLASH) == OK | 6295 EW_FILE|EW_NOTFOUND|EW_ADDSLASH) == OK |
6282 && new_arg_file_count > 0) | 6296 && new_arg_file_count > 0) |
6283 { | 6297 { |
6284 alist_set(&global_alist, new_arg_file_count, new_arg_files, TRUE); | 6298 alist_set(&global_alist, new_arg_file_count, new_arg_files, |
6285 vim_free(old_arg_files); | 6299 TRUE, fnum_list, fnum_len); |
6300 FreeWild(old_arg_count, old_arg_files); | |
6286 } | 6301 } |
6287 } | 6302 } |
6288 p_su = save_p_su; | 6303 p_su = save_p_su; |
6289 } | 6304 } |
6290 #endif | 6305 #endif |
6292 /* | 6307 /* |
6293 * Set the argument list for the current window. | 6308 * Set the argument list for the current window. |
6294 * Takes over the allocated files[] and the allocated fnames in it. | 6309 * Takes over the allocated files[] and the allocated fnames in it. |
6295 */ | 6310 */ |
6296 void | 6311 void |
6297 alist_set(al, count, files, use_curbuf) | 6312 alist_set(al, count, files, use_curbuf, fnum_list, fnum_len) |
6298 alist_T *al; | 6313 alist_T *al; |
6299 int count; | 6314 int count; |
6300 char_u **files; | 6315 char_u **files; |
6301 int use_curbuf; | 6316 int use_curbuf; |
6317 int *fnum_list; | |
6318 int fnum_len; | |
6302 { | 6319 { |
6303 int i; | 6320 int i; |
6304 | 6321 |
6305 alist_clear(al); | 6322 alist_clear(al); |
6306 if (ga_grow(&al->al_ga, count) == OK) | 6323 if (ga_grow(&al->al_ga, count) == OK) |
6313 * interrupting here. */ | 6330 * interrupting here. */ |
6314 while (i < count) | 6331 while (i < count) |
6315 vim_free(files[i++]); | 6332 vim_free(files[i++]); |
6316 break; | 6333 break; |
6317 } | 6334 } |
6335 | |
6336 /* May set buffer name of a buffer previously used for the | |
6337 * argument list, so that it's re-used by alist_add. */ | |
6338 if (fnum_list != NULL && i < fnum_len) | |
6339 buf_set_name(fnum_list[i], files[i]); | |
6340 | |
6318 alist_add(al, files[i], use_curbuf ? 2 : 1); | 6341 alist_add(al, files[i], use_curbuf ? 2 : 1); |
6319 ui_breakcheck(); | 6342 ui_breakcheck(); |
6320 } | 6343 } |
6321 vim_free(files); | 6344 vim_free(files); |
6322 } | 6345 } |
6346 AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname; | 6369 AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname; |
6347 if (set_fnum > 0) | 6370 if (set_fnum > 0) |
6348 AARGLIST(al)[al->al_ga.ga_len].ae_fnum = | 6371 AARGLIST(al)[al->al_ga.ga_len].ae_fnum = |
6349 buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); | 6372 buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); |
6350 ++al->al_ga.ga_len; | 6373 ++al->al_ga.ga_len; |
6351 --al->al_ga.ga_room; | |
6352 } | 6374 } |
6353 | 6375 |
6354 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) | 6376 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) |
6355 /* | 6377 /* |
6356 * Adjust slashes in file names. Called after 'shellslash' was set. | 6378 * Adjust slashes in file names. Called after 'shellslash' was set. |