Mercurial > vim
comparison src/ex_docmd.c @ 10741:3f70b142e8da v8.0.0260
patch 8.0.0260: build fails with tiny features
commit https://github.com/vim/vim/commit/dea2570740a79c9f2c6ce723689e563f19aff5cf
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 29 15:18:10 2017 +0100
patch 8.0.0260: build fails with tiny features
Problem: Build fails with tiny features.
Solution: Move get_tabpage_arg() inside #ifdef.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 Jan 2017 15:30:04 +0100 |
parents | 380e706814da |
children | 4961e7acdd8c |
comparison
equal
deleted
inserted
replaced
10740:d3f75123cbc5 | 10741:3f70b142e8da |
---|---|
5483 | 5483 |
5484 return OK; | 5484 return OK; |
5485 } | 5485 } |
5486 | 5486 |
5487 /* | 5487 /* |
5488 * Handle the argument for a tabpage related ex command. | |
5489 * Returns a tabpage number. | |
5490 * When an error is encountered then eap->errmsg is set. | |
5491 */ | |
5492 static int | |
5493 get_tabpage_arg(exarg_T *eap) | |
5494 { | |
5495 int tab_number; | |
5496 int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1; | |
5497 | |
5498 if (eap->arg && *eap->arg != NUL) | |
5499 { | |
5500 char_u *p = eap->arg; | |
5501 char_u *p_save; | |
5502 int relative = 0; /* argument +N/-N means: go to N places to the | |
5503 * right/left relative to the current position. */ | |
5504 | |
5505 if (*p == '-') | |
5506 { | |
5507 relative = -1; | |
5508 p++; | |
5509 } | |
5510 else if (*p == '+') | |
5511 { | |
5512 relative = 1; | |
5513 p++; | |
5514 } | |
5515 | |
5516 p_save = p; | |
5517 tab_number = getdigits(&p); | |
5518 | |
5519 if (relative == 0) | |
5520 { | |
5521 if (STRCMP(p, "$") == 0) | |
5522 tab_number = LAST_TAB_NR; | |
5523 else if (p == p_save || *p_save == '-' || *p != NUL | |
5524 || tab_number > LAST_TAB_NR) | |
5525 { | |
5526 /* No numbers as argument. */ | |
5527 eap->errmsg = e_invarg; | |
5528 goto theend; | |
5529 } | |
5530 } | |
5531 else | |
5532 { | |
5533 if (*p_save == NUL) | |
5534 tab_number = 1; | |
5535 else if (p == p_save || *p_save == '-' || *p != NUL | |
5536 || tab_number == 0) | |
5537 { | |
5538 /* No numbers as argument. */ | |
5539 eap->errmsg = e_invarg; | |
5540 goto theend; | |
5541 } | |
5542 tab_number = tab_number * relative + tabpage_index(curtab); | |
5543 if (!unaccept_arg0 && relative == -1) | |
5544 --tab_number; | |
5545 } | |
5546 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) | |
5547 eap->errmsg = e_invarg; | |
5548 } | |
5549 else if (eap->addr_count > 0) | |
5550 { | |
5551 if (unaccept_arg0 && eap->line2 == 0) | |
5552 eap->errmsg = e_invrange; | |
5553 else | |
5554 { | |
5555 tab_number = eap->line2; | |
5556 if (!unaccept_arg0 && **eap->cmdlinep == '-') | |
5557 { | |
5558 --tab_number; | |
5559 if (tab_number < unaccept_arg0) | |
5560 eap->errmsg = e_invarg; | |
5561 } | |
5562 } | |
5563 } | |
5564 else | |
5565 { | |
5566 switch (eap->cmdidx) | |
5567 { | |
5568 case CMD_tabnext: | |
5569 tab_number = tabpage_index(curtab) + 1; | |
5570 if (tab_number > LAST_TAB_NR) | |
5571 tab_number = 1; | |
5572 break; | |
5573 case CMD_tabmove: | |
5574 tab_number = LAST_TAB_NR; | |
5575 break; | |
5576 default: | |
5577 tab_number = tabpage_index(curtab); | |
5578 } | |
5579 } | |
5580 | |
5581 theend: | |
5582 return tab_number; | |
5583 } | |
5584 | |
5585 /* | |
5586 * ":abbreviate" and friends. | 5488 * ":abbreviate" and friends. |
5587 */ | 5489 */ |
5588 static void | 5490 static void |
5589 ex_abbreviate(exarg_T *eap) | 5491 ex_abbreviate(exarg_T *eap) |
5590 { | 5492 { |
7562 /* free buffer when not hiding it or when it's a scratch buffer */ | 7464 /* free buffer when not hiding it or when it's a scratch buffer */ |
7563 if (tp == NULL) | 7465 if (tp == NULL) |
7564 win_close(win, !need_hide && !P_HID(buf)); | 7466 win_close(win, !need_hide && !P_HID(buf)); |
7565 else | 7467 else |
7566 win_close_othertab(win, !need_hide && !P_HID(buf), tp); | 7468 win_close_othertab(win, !need_hide && !P_HID(buf), tp); |
7469 } | |
7470 | |
7471 /* | |
7472 * Handle the argument for a tabpage related ex command. | |
7473 * Returns a tabpage number. | |
7474 * When an error is encountered then eap->errmsg is set. | |
7475 */ | |
7476 static int | |
7477 get_tabpage_arg(exarg_T *eap) | |
7478 { | |
7479 int tab_number; | |
7480 int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1; | |
7481 | |
7482 if (eap->arg && *eap->arg != NUL) | |
7483 { | |
7484 char_u *p = eap->arg; | |
7485 char_u *p_save; | |
7486 int relative = 0; /* argument +N/-N means: go to N places to the | |
7487 * right/left relative to the current position. */ | |
7488 | |
7489 if (*p == '-') | |
7490 { | |
7491 relative = -1; | |
7492 p++; | |
7493 } | |
7494 else if (*p == '+') | |
7495 { | |
7496 relative = 1; | |
7497 p++; | |
7498 } | |
7499 | |
7500 p_save = p; | |
7501 tab_number = getdigits(&p); | |
7502 | |
7503 if (relative == 0) | |
7504 { | |
7505 if (STRCMP(p, "$") == 0) | |
7506 tab_number = LAST_TAB_NR; | |
7507 else if (p == p_save || *p_save == '-' || *p != NUL | |
7508 || tab_number > LAST_TAB_NR) | |
7509 { | |
7510 /* No numbers as argument. */ | |
7511 eap->errmsg = e_invarg; | |
7512 goto theend; | |
7513 } | |
7514 } | |
7515 else | |
7516 { | |
7517 if (*p_save == NUL) | |
7518 tab_number = 1; | |
7519 else if (p == p_save || *p_save == '-' || *p != NUL | |
7520 || tab_number == 0) | |
7521 { | |
7522 /* No numbers as argument. */ | |
7523 eap->errmsg = e_invarg; | |
7524 goto theend; | |
7525 } | |
7526 tab_number = tab_number * relative + tabpage_index(curtab); | |
7527 if (!unaccept_arg0 && relative == -1) | |
7528 --tab_number; | |
7529 } | |
7530 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) | |
7531 eap->errmsg = e_invarg; | |
7532 } | |
7533 else if (eap->addr_count > 0) | |
7534 { | |
7535 if (unaccept_arg0 && eap->line2 == 0) | |
7536 eap->errmsg = e_invrange; | |
7537 else | |
7538 { | |
7539 tab_number = eap->line2; | |
7540 if (!unaccept_arg0 && **eap->cmdlinep == '-') | |
7541 { | |
7542 --tab_number; | |
7543 if (tab_number < unaccept_arg0) | |
7544 eap->errmsg = e_invarg; | |
7545 } | |
7546 } | |
7547 } | |
7548 else | |
7549 { | |
7550 switch (eap->cmdidx) | |
7551 { | |
7552 case CMD_tabnext: | |
7553 tab_number = tabpage_index(curtab) + 1; | |
7554 if (tab_number > LAST_TAB_NR) | |
7555 tab_number = 1; | |
7556 break; | |
7557 case CMD_tabmove: | |
7558 tab_number = LAST_TAB_NR; | |
7559 break; | |
7560 default: | |
7561 tab_number = tabpage_index(curtab); | |
7562 } | |
7563 } | |
7564 | |
7565 theend: | |
7566 return tab_number; | |
7567 } | 7567 } |
7568 | 7568 |
7569 /* | 7569 /* |
7570 * ":tabclose": close current tab page, unless it is the last one. | 7570 * ":tabclose": close current tab page, unless it is the last one. |
7571 * ":tabclose N": close tab page N. | 7571 * ":tabclose N": close tab page N. |