Mercurial > vim
comparison src/ex_docmd.c @ 26327:227543e4181f v8.2.3694
patch 8.2.3694: cannot use quotes in the count of an Ex command
Commit: https://github.com/vim/vim/commit/af377e34b01ba00f9520d2b9de1f911e72db0114
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 29 12:12:43 2021 +0000
patch 8.2.3694: cannot use quotes in the count of an Ex command
Problem: Cannot use quotes in the count of an Ex command.
Solution: Add getdigits_quoted(). Give an error when misplacing a quote in
a range. (closes #9240)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 29 Nov 2021 13:15:02 +0100 |
parents | 8b594193dcb6 |
children | a2e6da79274d |
comparison
equal
deleted
inserted
replaced
26326:2a3b022339b0 | 26327:227543e4181f |
---|---|
2400 */ | 2400 */ |
2401 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg) | 2401 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg) |
2402 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL | 2402 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL |
2403 || VIM_ISWHITE(*p))) | 2403 || VIM_ISWHITE(*p))) |
2404 { | 2404 { |
2405 n = getdigits(&ea.arg); | 2405 n = getdigits_quoted(&ea.arg); |
2406 ea.arg = skipwhite(ea.arg); | 2406 ea.arg = skipwhite(ea.arg); |
2407 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) | 2407 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
2408 { | 2408 { |
2409 errormsg = _(e_zerocount); | 2409 errormsg = _(e_zerocount); |
2410 goto doend; | 2410 goto doend; |
3948 * Also skip white space and ":" characters after the range. | 3948 * Also skip white space and ":" characters after the range. |
3949 * Returns the "cmd" pointer advanced to beyond the range. | 3949 * Returns the "cmd" pointer advanced to beyond the range. |
3950 */ | 3950 */ |
3951 char_u * | 3951 char_u * |
3952 skip_range( | 3952 skip_range( |
3953 char_u *cmd, | 3953 char_u *cmd_start, |
3954 int skip_star, // skip "*" used for Visual range | 3954 int skip_star, // skip "*" used for Visual range |
3955 int *ctx) // pointer to xp_context or NULL | 3955 int *ctx) // pointer to xp_context or NULL |
3956 { | 3956 { |
3957 char_u *cmd = cmd_start; | |
3957 unsigned delim; | 3958 unsigned delim; |
3958 | 3959 |
3959 while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) | 3960 while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) |
3960 { | 3961 { |
3961 if (*cmd == '\\') | 3962 if (*cmd == '\\') |
3965 else | 3966 else |
3966 break; | 3967 break; |
3967 } | 3968 } |
3968 else if (*cmd == '\'') | 3969 else if (*cmd == '\'') |
3969 { | 3970 { |
3971 char_u *p = cmd; | |
3972 | |
3973 // a quote is only valid at the start or after a separator | |
3974 while (p > cmd_start) | |
3975 { | |
3976 --p; | |
3977 if (!VIM_ISWHITE(*p)) | |
3978 break; | |
3979 } | |
3980 if (cmd > cmd_start && !VIM_ISWHITE(*p) && *p != ',' && *p != ';') | |
3981 break; | |
3970 if (*++cmd == NUL && ctx != NULL) | 3982 if (*++cmd == NUL && ctx != NULL) |
3971 *ctx = EXPAND_NOTHING; | 3983 *ctx = EXPAND_NOTHING; |
3972 } | 3984 } |
3973 else if (*cmd == '/' || *cmd == '?') | 3985 else if (*cmd == '/' || *cmd == '?') |
3974 { | 3986 { |