comparison src/ex_docmd.c @ 12419:d216d9e8ac57 v8.0.1089

patch 8.0.1089: cannot get range count in user command commit https://github.com/vim/vim/commit/c168bd4bd3a9b856fc410fc4515dcca1d10d7461 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 10 17:34:35 2017 +0200 patch 8.0.1089: cannot get range count in user command Problem: Cannot get range count in user command. Solution: Add <range> argument.
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Sep 2017 17:45:04 +0200
parents 294f510f6d35
children da55ea30842c
comparison
equal deleted inserted replaced
12418:d03c8480d226 12419:d216d9e8ac57
6329 /* Check for attributes */ 6329 /* Check for attributes */
6330 while (*p == '-') 6330 while (*p == '-')
6331 { 6331 {
6332 ++p; 6332 ++p;
6333 end = skiptowhite(p); 6333 end = skiptowhite(p);
6334 if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg, &addr_type_arg) 6334 if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl,
6335 &compl_arg, &addr_type_arg)
6335 == FAIL) 6336 == FAIL)
6336 return; 6337 return;
6337 p = skipwhite(end); 6338 p = skipwhite(end);
6338 } 6339 }
6339 6340
6370 EMSG(_("E841: Reserved name, cannot be used for user defined command")); 6371 EMSG(_("E841: Reserved name, cannot be used for user defined command"));
6371 return; 6372 return;
6372 } 6373 }
6373 else 6374 else
6374 uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg, 6375 uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
6375 addr_type_arg, eap->forceit); 6376 addr_type_arg, eap->forceit);
6376 } 6377 }
6377 6378
6378 /* 6379 /*
6379 * ":comclear" 6380 * ":comclear"
6380 * Clear all user commands, global and for current buffer. 6381 * Clear all user commands, global and for current buffer.
6590 { 6591 {
6591 size_t result = 0; 6592 size_t result = 0;
6592 char_u *p = code + 1; 6593 char_u *p = code + 1;
6593 size_t l = len - 2; 6594 size_t l = len - 2;
6594 int quote = 0; 6595 int quote = 0;
6595 enum { ct_ARGS, ct_BANG, ct_COUNT, ct_LINE1, ct_LINE2, ct_MODS, 6596 enum {
6596 ct_REGISTER, ct_LT, ct_NONE } type = ct_NONE; 6597 ct_ARGS,
6598 ct_BANG,
6599 ct_COUNT,
6600 ct_LINE1,
6601 ct_LINE2,
6602 ct_RANGE,
6603 ct_MODS,
6604 ct_REGISTER,
6605 ct_LT,
6606 ct_NONE
6607 } type = ct_NONE;
6597 6608
6598 if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-') 6609 if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-')
6599 { 6610 {
6600 quote = (*p == 'q' || *p == 'Q') ? 1 : 2; 6611 quote = (*p == 'q' || *p == 'Q') ? 1 : 2;
6601 p += 2; 6612 p += 2;
6613 type = ct_COUNT; 6624 type = ct_COUNT;
6614 else if (STRNICMP(p, "line1>", l) == 0) 6625 else if (STRNICMP(p, "line1>", l) == 0)
6615 type = ct_LINE1; 6626 type = ct_LINE1;
6616 else if (STRNICMP(p, "line2>", l) == 0) 6627 else if (STRNICMP(p, "line2>", l) == 0)
6617 type = ct_LINE2; 6628 type = ct_LINE2;
6629 else if (STRNICMP(p, "range>", l) == 0)
6630 type = ct_RANGE;
6618 else if (STRNICMP(p, "lt>", l) == 0) 6631 else if (STRNICMP(p, "lt>", l) == 0)
6619 type = ct_LT; 6632 type = ct_LT;
6620 else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0) 6633 else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0)
6621 type = ct_REGISTER; 6634 type = ct_REGISTER;
6622 else if (STRNICMP(p, "mods>", l) == 0) 6635 else if (STRNICMP(p, "mods>", l) == 0)
6714 } 6727 }
6715 break; 6728 break;
6716 6729
6717 case ct_LINE1: 6730 case ct_LINE1:
6718 case ct_LINE2: 6731 case ct_LINE2:
6732 case ct_RANGE:
6719 case ct_COUNT: 6733 case ct_COUNT:
6720 { 6734 {
6721 char num_buf[20]; 6735 char num_buf[20];
6722 long num = (type == ct_LINE1) ? eap->line1 : 6736 long num = (type == ct_LINE1) ? eap->line1 :
6723 (type == ct_LINE2) ? eap->line2 : 6737 (type == ct_LINE2) ? eap->line2 :
6738 (type == ct_RANGE) ? eap->addr_count :
6724 (eap->addr_count > 0) ? eap->line2 : cmd->uc_def; 6739 (eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
6725 size_t num_len; 6740 size_t num_len;
6726 6741
6727 sprintf(num_buf, "%ld", num); 6742 sprintf(num_buf, "%ld", num);
6728 num_len = STRLEN(num_buf); 6743 num_len = STRLEN(num_buf);