mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
refactor(uncrustify): enable formatting for regexp and indent files (#18549)
The formatting for these files were originally disabled as to signal that "we don't own these files", meaning we intentionally want to minimize the amount of work put in these files as the return will be very little. This unfortunately conflicts with other refactoring efforts that happen to touch these files, and it's easier to simply enable formatting.
This commit is contained in:
1046
src/nvim/indent_c.c
1046
src/nvim/indent_c.c
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,6 @@
|
|||||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
||||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
|
|
||||||
// uncrustify:off
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handling of regular expressions: vim_regcomp(), vim_regexec(), vim_regsub()
|
* Handling of regular expressions: vim_regcomp(), vim_regexec(), vim_regsub()
|
||||||
*/
|
*/
|
||||||
@@ -18,21 +16,21 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "nvim/vim.h"
|
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/regexp.h"
|
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/eval.h"
|
#include "nvim/eval.h"
|
||||||
#include "nvim/eval/userfunc.h"
|
#include "nvim/eval/userfunc.h"
|
||||||
#include "nvim/ex_cmds2.h"
|
#include "nvim/ex_cmds2.h"
|
||||||
|
#include "nvim/garray.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
#include "nvim/message.h"
|
#include "nvim/message.h"
|
||||||
#include "nvim/os/input.h"
|
#include "nvim/os/input.h"
|
||||||
#include "nvim/plines.h"
|
#include "nvim/plines.h"
|
||||||
#include "nvim/garray.h"
|
#include "nvim/regexp.h"
|
||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
#ifdef REGEXP_DEBUG
|
#ifdef REGEXP_DEBUG
|
||||||
// show/save debugging data when BT engine is used
|
// show/save debugging data when BT engine is used
|
||||||
@@ -62,15 +60,17 @@ typedef void (*(*fptr_T)(int *, int))(void);
|
|||||||
|
|
||||||
static int no_Magic(int x)
|
static int no_Magic(int x)
|
||||||
{
|
{
|
||||||
if (is_Magic(x))
|
if (is_Magic(x)) {
|
||||||
return un_Magic(x);
|
return un_Magic(x);
|
||||||
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int toggle_Magic(int x)
|
static int toggle_Magic(int x)
|
||||||
{
|
{
|
||||||
if (is_Magic(x))
|
if (is_Magic(x)) {
|
||||||
return un_Magic(x);
|
return un_Magic(x);
|
||||||
|
}
|
||||||
return Magic(x);
|
return Magic(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,13 +88,12 @@ static int toggle_Magic(int x)
|
|||||||
#define IEMSG_RET_NULL(m) return (iemsg(m), rc_did_emsg = true, (void *)NULL)
|
#define IEMSG_RET_NULL(m) return (iemsg(m), rc_did_emsg = true, (void *)NULL)
|
||||||
#define EMSG_RET_FAIL(m) return (emsg(m), rc_did_emsg = true, FAIL)
|
#define EMSG_RET_FAIL(m) return (emsg(m), rc_did_emsg = true, FAIL)
|
||||||
#define EMSG2_RET_NULL(m, c) \
|
#define EMSG2_RET_NULL(m, c) \
|
||||||
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
|
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
|
||||||
#define EMSG3_RET_NULL(m, c, a) \
|
#define EMSG3_RET_NULL(m, c, a) \
|
||||||
return (semsg((const char *)(m), (c) ? "" : "\\", (a)), rc_did_emsg = true, (void *)NULL)
|
return (semsg((const char *)(m), (c) ? "" : "\\", (a)), rc_did_emsg = true, (void *)NULL)
|
||||||
#define EMSG2_RET_FAIL(m, c) \
|
#define EMSG2_RET_FAIL(m, c) \
|
||||||
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
|
return (semsg((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
|
||||||
#define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \
|
#define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL)
|
||||||
"E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL)
|
|
||||||
|
|
||||||
#define MAX_LIMIT (32767L << 16L)
|
#define MAX_LIMIT (32767L << 16L)
|
||||||
|
|
||||||
@@ -128,30 +127,32 @@ static char_u e_regexp_number_after_dot_pos_search[]
|
|||||||
/// Return MULTI_MULT if c is a multi "multi" operator.
|
/// Return MULTI_MULT if c is a multi "multi" operator.
|
||||||
static int re_multi_type(int c)
|
static int re_multi_type(int c)
|
||||||
{
|
{
|
||||||
if (c == Magic('@') || c == Magic('=') || c == Magic('?'))
|
if (c == Magic('@') || c == Magic('=') || c == Magic('?')) {
|
||||||
return MULTI_ONE;
|
return MULTI_ONE;
|
||||||
if (c == Magic('*') || c == Magic('+') || c == Magic('{'))
|
}
|
||||||
|
if (c == Magic('*') || c == Magic('+') || c == Magic('{')) {
|
||||||
return MULTI_MULT;
|
return MULTI_MULT;
|
||||||
|
}
|
||||||
return NOT_MULTI;
|
return NOT_MULTI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char_u *reg_prev_sub = NULL;
|
static char_u *reg_prev_sub = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* REGEXP_INRANGE contains all characters which are always special in a []
|
* REGEXP_INRANGE contains all characters which are always special in a []
|
||||||
* range after '\'.
|
* range after '\'.
|
||||||
* REGEXP_ABBR contains all characters which act as abbreviations after '\'.
|
* REGEXP_ABBR contains all characters which act as abbreviations after '\'.
|
||||||
* These are:
|
* These are:
|
||||||
* \n - New line (NL).
|
* \n - New line (NL).
|
||||||
* \r - Carriage Return (CR).
|
* \r - Carriage Return (CR).
|
||||||
* \t - Tab (TAB).
|
* \t - Tab (TAB).
|
||||||
* \e - Escape (ESC).
|
* \e - Escape (ESC).
|
||||||
* \b - Backspace (Ctrl_H).
|
* \b - Backspace (Ctrl_H).
|
||||||
* \d - Character code in decimal, eg \d123
|
* \d - Character code in decimal, eg \d123
|
||||||
* \o - Character code in octal, eg \o80
|
* \o - Character code in octal, eg \o80
|
||||||
* \x - Character code in hex, eg \x4a
|
* \x - Character code in hex, eg \x4a
|
||||||
* \u - Multibyte character code, eg \u20ac
|
* \u - Multibyte character code, eg \u20ac
|
||||||
* \U - Long multibyte character code, eg \U12345678
|
* \U - Long multibyte character code, eg \U12345678
|
||||||
*/
|
*/
|
||||||
static char_u REGEXP_INRANGE[] = "]^-n\\";
|
static char_u REGEXP_INRANGE[] = "]^-n\\";
|
||||||
static char_u REGEXP_ABBR[] = "nrtebdoxuU";
|
static char_u REGEXP_ABBR[] = "nrtebdoxuU";
|
||||||
@@ -163,10 +164,14 @@ static char_u REGEXP_ABBR[] = "nrtebdoxuU";
|
|||||||
static int backslash_trans(int c)
|
static int backslash_trans(int c)
|
||||||
{
|
{
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'r': return CAR;
|
case 'r':
|
||||||
case 't': return TAB;
|
return CAR;
|
||||||
case 'e': return ESC;
|
case 't':
|
||||||
case 'b': return BS;
|
return TAB;
|
||||||
|
case 'e':
|
||||||
|
return ESC;
|
||||||
|
case 'b':
|
||||||
|
return BS;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -223,11 +228,12 @@ static int get_char_class(char_u **pp)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((*pp)[1] == ':') {
|
if ((*pp)[1] == ':') {
|
||||||
for (i = 0; i < (int)ARRAY_SIZE(class_names); ++i)
|
for (i = 0; i < (int)ARRAY_SIZE(class_names); i++) {
|
||||||
if (STRNCMP(*pp + 2, class_names[i], STRLEN(class_names[i])) == 0) {
|
if (STRNCMP(*pp + 2, class_names[i], STRLEN(class_names[i])) == 0) {
|
||||||
*pp += STRLEN(class_names[i]) + 2;
|
*pp += STRLEN(class_names[i]) + 2;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CLASS_NONE;
|
return CLASS_NONE;
|
||||||
}
|
}
|
||||||
@@ -253,41 +259,43 @@ static void init_class_tab(void)
|
|||||||
int i;
|
int i;
|
||||||
static int done = false;
|
static int done = false;
|
||||||
|
|
||||||
if (done)
|
if (done) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0; i < 256; i++) {
|
||||||
if (i >= '0' && i <= '7')
|
if (i >= '0' && i <= '7') {
|
||||||
class_tab[i] = RI_DIGIT + RI_HEX + RI_OCTAL + RI_WORD;
|
class_tab[i] = RI_DIGIT + RI_HEX + RI_OCTAL + RI_WORD;
|
||||||
else if (i >= '8' && i <= '9')
|
} else if (i >= '8' && i <= '9') {
|
||||||
class_tab[i] = RI_DIGIT + RI_HEX + RI_WORD;
|
class_tab[i] = RI_DIGIT + RI_HEX + RI_WORD;
|
||||||
else if (i >= 'a' && i <= 'f')
|
} else if (i >= 'a' && i <= 'f') {
|
||||||
class_tab[i] = RI_HEX + RI_WORD + RI_HEAD + RI_ALPHA + RI_LOWER;
|
class_tab[i] = RI_HEX + RI_WORD + RI_HEAD + RI_ALPHA + RI_LOWER;
|
||||||
else if (i >= 'g' && i <= 'z')
|
} else if (i >= 'g' && i <= 'z') {
|
||||||
class_tab[i] = RI_WORD + RI_HEAD + RI_ALPHA + RI_LOWER;
|
class_tab[i] = RI_WORD + RI_HEAD + RI_ALPHA + RI_LOWER;
|
||||||
else if (i >= 'A' && i <= 'F')
|
} else if (i >= 'A' && i <= 'F') {
|
||||||
class_tab[i] = RI_HEX + RI_WORD + RI_HEAD + RI_ALPHA + RI_UPPER;
|
class_tab[i] = RI_HEX + RI_WORD + RI_HEAD + RI_ALPHA + RI_UPPER;
|
||||||
else if (i >= 'G' && i <= 'Z')
|
} else if (i >= 'G' && i <= 'Z') {
|
||||||
class_tab[i] = RI_WORD + RI_HEAD + RI_ALPHA + RI_UPPER;
|
class_tab[i] = RI_WORD + RI_HEAD + RI_ALPHA + RI_UPPER;
|
||||||
else if (i == '_')
|
} else if (i == '_') {
|
||||||
class_tab[i] = RI_WORD + RI_HEAD;
|
class_tab[i] = RI_WORD + RI_HEAD;
|
||||||
else
|
} else {
|
||||||
class_tab[i] = 0;
|
class_tab[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class_tab[' '] |= RI_WHITE;
|
class_tab[' '] |= RI_WHITE;
|
||||||
class_tab['\t'] |= RI_WHITE;
|
class_tab['\t'] |= RI_WHITE;
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define ri_digit(c) ((c) < 0x100 && (class_tab[c] & RI_DIGIT))
|
#define ri_digit(c) ((c) < 0x100 && (class_tab[c] & RI_DIGIT))
|
||||||
# define ri_hex(c) ((c) < 0x100 && (class_tab[c] & RI_HEX))
|
#define ri_hex(c) ((c) < 0x100 && (class_tab[c] & RI_HEX))
|
||||||
# define ri_octal(c) ((c) < 0x100 && (class_tab[c] & RI_OCTAL))
|
#define ri_octal(c) ((c) < 0x100 && (class_tab[c] & RI_OCTAL))
|
||||||
# define ri_word(c) ((c) < 0x100 && (class_tab[c] & RI_WORD))
|
#define ri_word(c) ((c) < 0x100 && (class_tab[c] & RI_WORD))
|
||||||
# define ri_head(c) ((c) < 0x100 && (class_tab[c] & RI_HEAD))
|
#define ri_head(c) ((c) < 0x100 && (class_tab[c] & RI_HEAD))
|
||||||
# define ri_alpha(c) ((c) < 0x100 && (class_tab[c] & RI_ALPHA))
|
#define ri_alpha(c) ((c) < 0x100 && (class_tab[c] & RI_ALPHA))
|
||||||
# define ri_lower(c) ((c) < 0x100 && (class_tab[c] & RI_LOWER))
|
#define ri_lower(c) ((c) < 0x100 && (class_tab[c] & RI_LOWER))
|
||||||
# define ri_upper(c) ((c) < 0x100 && (class_tab[c] & RI_UPPER))
|
#define ri_upper(c) ((c) < 0x100 && (class_tab[c] & RI_UPPER))
|
||||||
# define ri_white(c) ((c) < 0x100 && (class_tab[c] & RI_WHITE))
|
#define ri_white(c) ((c) < 0x100 && (class_tab[c] & RI_WHITE))
|
||||||
|
|
||||||
// flags for regflags
|
// flags for regflags
|
||||||
#define RF_ICASE 1 // ignore case
|
#define RF_ICASE 1 // ignore case
|
||||||
@@ -320,6 +328,8 @@ static int reg_strict; // "[abc" is illegal
|
|||||||
* META contains all characters that may be magic, except '^' and '$'.
|
* META contains all characters that may be magic, except '^' and '$'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// uncrustify:off
|
||||||
|
|
||||||
// META[] is used often enough to justify turning it into a table.
|
// META[] is used often enough to justify turning it into a table.
|
||||||
static char_u META_flags[] = {
|
static char_u META_flags[] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@@ -338,6 +348,8 @@ static char_u META_flags[] = {
|
|||||||
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1
|
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// uncrustify:on
|
||||||
|
|
||||||
static int curchr; // currently parsed character
|
static int curchr; // currently parsed character
|
||||||
// Previous character. Note: prevchr is sometimes -1 when we are not at the
|
// Previous character. Note: prevchr is sometimes -1 when we are not at the
|
||||||
// start, eg in /[ ^I]^ the pattern was never found even if it existed,
|
// start, eg in /[ ^I]^ the pattern was never found even if it existed,
|
||||||
@@ -389,7 +401,7 @@ static int get_equi_class(char_u **pp)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int l = 1;
|
int l = 1;
|
||||||
char_u *p = *pp;
|
char_u *p = *pp;
|
||||||
|
|
||||||
if (p[1] == '=' && p[2] != NUL) {
|
if (p[1] == '=' && p[2] != NUL) {
|
||||||
l = utfc_ptr2len((char *)p + 2);
|
l = utfc_ptr2len((char *)p + 2);
|
||||||
@@ -413,7 +425,7 @@ static int get_coll_element(char_u **pp)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int l = 1;
|
int l = 1;
|
||||||
char_u *p = *pp;
|
char_u *p = *pp;
|
||||||
|
|
||||||
if (p[0] != NUL && p[1] == '.' && p[2] != NUL) {
|
if (p[0] != NUL && p[1] == '.' && p[2] != NUL) {
|
||||||
l = utfc_ptr2len((char *)p + 2);
|
l = utfc_ptr2len((char *)p + 2);
|
||||||
@@ -451,7 +463,7 @@ static char_u *skip_anyof(char_u *p)
|
|||||||
while (*p != NUL && *p != ']') {
|
while (*p != NUL && *p != ']') {
|
||||||
if ((l = utfc_ptr2len((char *)p)) > 1) {
|
if ((l = utfc_ptr2len((char *)p)) > 1) {
|
||||||
p += l;
|
p += l;
|
||||||
} else if (*p == '-') {
|
} else if (*p == '-') {
|
||||||
p++;
|
p++;
|
||||||
if (*p != ']' && *p != NUL) {
|
if (*p != ']' && *p != NUL) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
@@ -488,12 +500,13 @@ static char_u *skip_anyof(char_u *p)
|
|||||||
char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
|
char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
|
||||||
{
|
{
|
||||||
int mymagic;
|
int mymagic;
|
||||||
char_u *p = startp;
|
char_u *p = startp;
|
||||||
|
|
||||||
if (magic)
|
if (magic) {
|
||||||
mymagic = MAGIC_ON;
|
mymagic = MAGIC_ON;
|
||||||
else
|
} else {
|
||||||
mymagic = MAGIC_OFF;
|
mymagic = MAGIC_OFF;
|
||||||
|
}
|
||||||
get_cpo_flags();
|
get_cpo_flags();
|
||||||
|
|
||||||
for (; p[0] != NUL; MB_PTR_ADV(p)) {
|
for (; p[0] != NUL; MB_PTR_ADV(p)) {
|
||||||
@@ -503,9 +516,10 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
|
|||||||
if ((p[0] == '[' && mymagic >= MAGIC_ON)
|
if ((p[0] == '[' && mymagic >= MAGIC_ON)
|
||||||
|| (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) {
|
|| (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) {
|
||||||
p = skip_anyof(p + 1);
|
p = skip_anyof(p + 1);
|
||||||
if (p[0] == NUL)
|
if (p[0] == NUL) {
|
||||||
break;
|
break;
|
||||||
} else if (p[0] == '\\' && p[1] != NUL) {
|
}
|
||||||
|
} else if (p[0] == '\\' && p[1] != NUL) {
|
||||||
if (dirc == '?' && newp != NULL && p[1] == '?') {
|
if (dirc == '?' && newp != NULL && p[1] == '?') {
|
||||||
// change "\?" to "?", make a copy first.
|
// change "\?" to "?", make a copy first.
|
||||||
if (*newp == NULL) {
|
if (*newp == NULL) {
|
||||||
@@ -686,8 +700,7 @@ static int peekchr(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\': {
|
||||||
{
|
|
||||||
int c = regparse[1];
|
int c = regparse[1];
|
||||||
|
|
||||||
if (c == NUL) {
|
if (c == NUL) {
|
||||||
@@ -712,13 +725,11 @@ static int peekchr(void)
|
|||||||
* Handle abbreviations, like "\t" for TAB -- webb
|
* Handle abbreviations, like "\t" for TAB -- webb
|
||||||
*/
|
*/
|
||||||
curchr = backslash_trans(c);
|
curchr = backslash_trans(c);
|
||||||
} else if (reg_magic == MAGIC_NONE && (c == '$' || c == '^'))
|
} else if (reg_magic == MAGIC_NONE && (c == '$' || c == '^')) {
|
||||||
curchr = toggle_Magic(c);
|
curchr = toggle_Magic(c);
|
||||||
else {
|
} else {
|
||||||
/*
|
// Next character can never be (made) magic?
|
||||||
* Next character can never be (made) magic?
|
// Then backslashing it won't do anything.
|
||||||
* Then backslashing it won't do anything.
|
|
||||||
*/
|
|
||||||
curchr = utf_ptr2char((char *)regparse + 1);
|
curchr = utf_ptr2char((char *)regparse + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -804,7 +815,7 @@ static void ungetchr(void)
|
|||||||
* Return -1 if there is no valid hex number.
|
* Return -1 if there is no valid hex number.
|
||||||
* The position is updated:
|
* The position is updated:
|
||||||
* blahblah\%x20asdf
|
* blahblah\%x20asdf
|
||||||
* before-^ ^-after
|
* before-^ ^-after
|
||||||
* The parameter controls the maximum number of input characters. This will be
|
* The parameter controls the maximum number of input characters. This will be
|
||||||
* 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence.
|
* 2 when reading a \%x20 sequence and 4 when reading a \%u20AC sequence.
|
||||||
*/
|
*/
|
||||||
@@ -816,15 +827,17 @@ static int64_t gethexchrs(int maxinputlen)
|
|||||||
|
|
||||||
for (i = 0; i < maxinputlen; ++i) {
|
for (i = 0; i < maxinputlen; ++i) {
|
||||||
c = regparse[0];
|
c = regparse[0];
|
||||||
if (!ascii_isxdigit(c))
|
if (!ascii_isxdigit(c)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
nr <<= 4;
|
nr <<= 4;
|
||||||
nr |= hex2nr(c);
|
nr |= hex2nr(c);
|
||||||
++regparse;
|
++regparse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,16 +853,18 @@ static int64_t getdecchrs(void)
|
|||||||
|
|
||||||
for (i = 0;; ++i) {
|
for (i = 0;; ++i) {
|
||||||
c = regparse[0];
|
c = regparse[0];
|
||||||
if (c < '0' || c > '9')
|
if (c < '0' || c > '9') {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
nr *= 10;
|
nr *= 10;
|
||||||
nr += c - '0';
|
nr += c - '0';
|
||||||
regparse++;
|
regparse++;
|
||||||
curchr = -1; // no longer valid
|
curchr = -1; // no longer valid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,7 +874,7 @@ static int64_t getdecchrs(void)
|
|||||||
* numbers > 377 correctly (for example, 400 is treated as 40) and doesn't
|
* numbers > 377 correctly (for example, 400 is treated as 40) and doesn't
|
||||||
* treat 8 or 9 as recognised characters. Position is updated:
|
* treat 8 or 9 as recognised characters. Position is updated:
|
||||||
* blahblah\%o210asdf
|
* blahblah\%o210asdf
|
||||||
* before-^ ^-after
|
* before-^ ^-after
|
||||||
*/
|
*/
|
||||||
static int64_t getoctchrs(void)
|
static int64_t getoctchrs(void)
|
||||||
{
|
{
|
||||||
@@ -869,15 +884,17 @@ static int64_t getoctchrs(void)
|
|||||||
|
|
||||||
for (i = 0; i < 3 && nr < 040; i++) { // -V536
|
for (i = 0; i < 3 && nr < 040; i++) { // -V536
|
||||||
c = regparse[0];
|
c = regparse[0];
|
||||||
if (c < '0' || c > '7')
|
if (c < '0' || c > '7') {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
nr <<= 3;
|
nr <<= 3;
|
||||||
nr |= hex2nr(c);
|
nr |= hex2nr(c);
|
||||||
++regparse;
|
++regparse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -891,7 +908,7 @@ static int64_t getoctchrs(void)
|
|||||||
static int read_limits(long *minval, long *maxval)
|
static int read_limits(long *minval, long *maxval)
|
||||||
{
|
{
|
||||||
int reverse = false;
|
int reverse = false;
|
||||||
char_u *first_char;
|
char_u *first_char;
|
||||||
long tmp;
|
long tmp;
|
||||||
|
|
||||||
if (*regparse == '-') {
|
if (*regparse == '-') {
|
||||||
@@ -943,7 +960,7 @@ static int read_limits(long *minval, long *maxval)
|
|||||||
// Sometimes need to save a copy of a line. Since alloc()/free() is very
|
// Sometimes need to save a copy of a line. Since alloc()/free() is very
|
||||||
// slow, we keep one allocated piece of memory and only re-allocate it when
|
// slow, we keep one allocated piece of memory and only re-allocate it when
|
||||||
// it's too small. It's freed in bt_regexec_both() when finished.
|
// it's too small. It's freed in bt_regexec_both() when finished.
|
||||||
static char_u *reg_tofree = NULL;
|
static char_u *reg_tofree = NULL;
|
||||||
static unsigned reg_tofreelen;
|
static unsigned reg_tofreelen;
|
||||||
|
|
||||||
// Structure used to store the execution state of the regex engine.
|
// Structure used to store the execution state of the regex engine.
|
||||||
@@ -1039,8 +1056,8 @@ static char_u *reg_getline(linenr_T lnum)
|
|||||||
return ml_get_buf(rex.reg_buf, rex.reg_firstlnum + lnum, false);
|
return ml_get_buf(rex.reg_buf, rex.reg_firstlnum + lnum, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char_u *reg_startzp[NSUBEXP]; // Workspace to mark beginning
|
static char_u *reg_startzp[NSUBEXP]; // Workspace to mark beginning
|
||||||
static char_u *reg_endzp[NSUBEXP]; // and end of \z(...\) matches
|
static char_u *reg_endzp[NSUBEXP]; // and end of \z(...\) matches
|
||||||
static lpos_T reg_startzpos[NSUBEXP]; // idem, beginning pos
|
static lpos_T reg_startzpos[NSUBEXP]; // idem, beginning pos
|
||||||
static lpos_T reg_endzpos[NSUBEXP]; // idem, end pos
|
static lpos_T reg_endzpos[NSUBEXP]; // idem, end pos
|
||||||
|
|
||||||
@@ -1063,8 +1080,9 @@ static reg_extmatch_T *make_extmatch(void)
|
|||||||
*/
|
*/
|
||||||
reg_extmatch_T *ref_extmatch(reg_extmatch_T *em)
|
reg_extmatch_T *ref_extmatch(reg_extmatch_T *em)
|
||||||
{
|
{
|
||||||
if (em != NULL)
|
if (em != NULL) {
|
||||||
em->refcnt++;
|
em->refcnt++;
|
||||||
|
}
|
||||||
return em;
|
return em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1077,8 +1095,9 @@ void unref_extmatch(reg_extmatch_T *em)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (em != NULL && --em->refcnt <= 0) {
|
if (em != NULL && --em->refcnt <= 0) {
|
||||||
for (i = 0; i < NSUBEXP; ++i)
|
for (i = 0; i < NSUBEXP; i++) {
|
||||||
xfree(em->matches[i]);
|
xfree(em->matches[i]);
|
||||||
|
}
|
||||||
xfree(em);
|
xfree(em);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1087,9 +1106,8 @@ void unref_extmatch(reg_extmatch_T *em)
|
|||||||
static int reg_prev_class(void)
|
static int reg_prev_class(void)
|
||||||
{
|
{
|
||||||
if (rex.input > rex.line) {
|
if (rex.input > rex.line) {
|
||||||
return mb_get_class_tab(
|
return mb_get_class_tab(rex.input - 1 - utf_head_off(rex.line, rex.input - 1),
|
||||||
rex.input - 1 - utf_head_off(rex.line, rex.input - 1),
|
rex.reg_buf->b_chartab);
|
||||||
rex.reg_buf->b_chartab);
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1147,10 +1165,12 @@ static bool reg_match_visual(void)
|
|||||||
} else if (mode == Ctrl_V) {
|
} else if (mode == Ctrl_V) {
|
||||||
getvvcol(wp, &top, &start, NULL, &end);
|
getvvcol(wp, &top, &start, NULL, &end);
|
||||||
getvvcol(wp, &bot, &start2, NULL, &end2);
|
getvvcol(wp, &bot, &start2, NULL, &end2);
|
||||||
if (start2 < start)
|
if (start2 < start) {
|
||||||
start = start2;
|
start = start2;
|
||||||
if (end2 > end)
|
}
|
||||||
|
if (end2 > end) {
|
||||||
end = end2;
|
end = end2;
|
||||||
|
}
|
||||||
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) {
|
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) {
|
||||||
end = MAXCOL;
|
end = MAXCOL;
|
||||||
}
|
}
|
||||||
@@ -1175,7 +1195,7 @@ static bool reg_match_visual(void)
|
|||||||
*/
|
*/
|
||||||
static int prog_magic_wrong(void)
|
static int prog_magic_wrong(void)
|
||||||
{
|
{
|
||||||
regprog_T *prog;
|
regprog_T *prog;
|
||||||
|
|
||||||
prog = REG_MULTI ? rex.reg_mmatch->regprog : rex.reg_match->regprog;
|
prog = REG_MULTI ? rex.reg_mmatch->regprog : rex.reg_match->regprog;
|
||||||
if (prog->engine == &nfa_regengine) {
|
if (prog->engine == &nfa_regengine) {
|
||||||
@@ -1241,21 +1261,18 @@ static void reg_nextline(void)
|
|||||||
* If "bytelen" is not NULL, it is set to the byte length of the match in the
|
* If "bytelen" is not NULL, it is set to the byte length of the match in the
|
||||||
* last line.
|
* last line.
|
||||||
*/
|
*/
|
||||||
static int match_with_backref(
|
static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T end_lnum,
|
||||||
linenr_T start_lnum,
|
colnr_T end_col, int *bytelen)
|
||||||
colnr_T start_col,
|
|
||||||
linenr_T end_lnum,
|
|
||||||
colnr_T end_col,
|
|
||||||
int *bytelen)
|
|
||||||
{
|
{
|
||||||
linenr_T clnum = start_lnum;
|
linenr_T clnum = start_lnum;
|
||||||
colnr_T ccol = start_col;
|
colnr_T ccol = start_col;
|
||||||
int len;
|
int len;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
if (bytelen != NULL)
|
if (bytelen != NULL) {
|
||||||
*bytelen = 0;
|
*bytelen = 0;
|
||||||
for (;; ) {
|
}
|
||||||
|
for (;;) {
|
||||||
// Since getting one line may invalidate the other, need to make copy.
|
// Since getting one line may invalidate the other, need to make copy.
|
||||||
// Slow!
|
// Slow!
|
||||||
if (rex.line != reg_tofree) {
|
if (rex.line != reg_tofree) {
|
||||||
@@ -1275,10 +1292,11 @@ static int match_with_backref(
|
|||||||
p = reg_getline(clnum);
|
p = reg_getline(clnum);
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
if (clnum == end_lnum)
|
if (clnum == end_lnum) {
|
||||||
len = end_col - ccol;
|
len = end_col - ccol;
|
||||||
else
|
} else {
|
||||||
len = (int)STRLEN(p + ccol);
|
len = (int)STRLEN(p + ccol);
|
||||||
|
}
|
||||||
|
|
||||||
if (cstrncmp(p + ccol, rex.input, &len) != 0) {
|
if (cstrncmp(p + ccol, rex.input, &len) != 0) {
|
||||||
return RA_NOMATCH; // doesn't match
|
return RA_NOMATCH; // doesn't match
|
||||||
@@ -1295,12 +1313,14 @@ static int match_with_backref(
|
|||||||
|
|
||||||
// Advance to next line.
|
// Advance to next line.
|
||||||
reg_nextline();
|
reg_nextline();
|
||||||
if (bytelen != NULL)
|
if (bytelen != NULL) {
|
||||||
*bytelen = 0;
|
*bytelen = 0;
|
||||||
++clnum;
|
}
|
||||||
|
clnum++;
|
||||||
ccol = 0;
|
ccol = 0;
|
||||||
if (got_int)
|
if (got_int) {
|
||||||
return RA_FAIL;
|
return RA_FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// found a match! Note that rex.line may now point to a copy of the line,
|
// found a match! Note that rex.line may now point to a copy of the line,
|
||||||
@@ -1324,7 +1344,7 @@ typedef struct {
|
|||||||
} decomp_T;
|
} decomp_T;
|
||||||
|
|
||||||
// 0xfb20 - 0xfb4f
|
// 0xfb20 - 0xfb4f
|
||||||
static decomp_T decomp_table[0xfb4f-0xfb20+1] =
|
static decomp_T decomp_table[0xfb4f - 0xfb20 + 1] =
|
||||||
{
|
{
|
||||||
{ 0x5e2, 0, 0 }, // 0xfb20 alt ayin
|
{ 0x5e2, 0, 0 }, // 0xfb20 alt ayin
|
||||||
{ 0x5d0, 0, 0 }, // 0xfb21 alt alef
|
{ 0x5d0, 0, 0 }, // 0xfb21 alt alef
|
||||||
@@ -1407,7 +1427,7 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
|
|||||||
|
|
||||||
// if it failed and it's utf8 and we want to combineignore:
|
// if it failed and it's utf8 and we want to combineignore:
|
||||||
if (result != 0 && rex.reg_icombine) {
|
if (result != 0 && rex.reg_icombine) {
|
||||||
char_u *str1, *str2;
|
char_u *str1, *str2;
|
||||||
int c1, c2, c11, c12;
|
int c1, c2, c11, c12;
|
||||||
int junk;
|
int junk;
|
||||||
|
|
||||||
@@ -1435,8 +1455,9 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = c2 - c1;
|
result = c2 - c1;
|
||||||
if (result == 0)
|
if (result == 0) {
|
||||||
*n = (int)(str2 - s2);
|
*n = (int)(str2 - s2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -1533,9 +1554,9 @@ static fptr_T do_Lower(int *d, int c)
|
|||||||
*/
|
*/
|
||||||
char_u *regtilde(char_u *source, int magic, bool preview)
|
char_u *regtilde(char_u *source, int magic, bool preview)
|
||||||
{
|
{
|
||||||
char_u *newsub = source;
|
char_u *newsub = source;
|
||||||
char_u *tmpsub;
|
char_u *tmpsub;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int len;
|
int len;
|
||||||
int prevlen;
|
int prevlen;
|
||||||
|
|
||||||
@@ -1605,8 +1626,7 @@ static regsubmatch_T rsm; // can only be used when can_f_submatch is true
|
|||||||
|
|
||||||
/// Put the submatches in "argv[argskip]" which is a list passed into
|
/// Put the submatches in "argv[argskip]" which is a list passed into
|
||||||
/// call_func() by vim_regsub_both().
|
/// call_func() by vim_regsub_both().
|
||||||
static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv,
|
static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv, int argskip, int argcount)
|
||||||
int argskip, int argcount)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
typval_T *listarg = argv + argskip;
|
typval_T *listarg = argv + argskip;
|
||||||
@@ -1658,8 +1678,8 @@ static void clear_submatch_list(staticList10_T *sl)
|
|||||||
/// references invalid!
|
/// references invalid!
|
||||||
///
|
///
|
||||||
/// Returns the size of the replacement, including terminating NUL.
|
/// Returns the size of the replacement, including terminating NUL.
|
||||||
int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest,
|
int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest, int copy, int magic,
|
||||||
int copy, int magic, int backslash)
|
int backslash)
|
||||||
{
|
{
|
||||||
regexec_T rex_save;
|
regexec_T rex_save;
|
||||||
bool rex_in_use_save = rex_in_use;
|
bool rex_in_use_save = rex_in_use;
|
||||||
@@ -1685,8 +1705,8 @@ int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *dest,
|
int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *dest, int copy,
|
||||||
int copy, int magic, int backslash)
|
int magic, int backslash)
|
||||||
{
|
{
|
||||||
regexec_T rex_save;
|
regexec_T rex_save;
|
||||||
bool rex_in_use_save = rex_in_use;
|
bool rex_in_use_save = rex_in_use;
|
||||||
@@ -1713,12 +1733,12 @@ int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *de
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int copy, int magic,
|
||||||
int copy, int magic, int backslash)
|
int backslash)
|
||||||
{
|
{
|
||||||
char_u *src;
|
char_u *src;
|
||||||
char_u *dst;
|
char_u *dst;
|
||||||
char_u *s;
|
char_u *s;
|
||||||
int c;
|
int c;
|
||||||
int cc;
|
int cc;
|
||||||
int no = -1;
|
int no = -1;
|
||||||
@@ -1737,8 +1757,9 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
emsg(_(e_null));
|
emsg(_(e_null));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (prog_magic_wrong())
|
if (prog_magic_wrong()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
src = source;
|
src = source;
|
||||||
dst = dest;
|
dst = dest;
|
||||||
|
|
||||||
@@ -1851,11 +1872,11 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
rsm = rsm_save;
|
rsm = rsm_save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
while ((c = *src++) != NUL) {
|
while ((c = *src++) != NUL) {
|
||||||
if (c == '&' && magic)
|
if (c == '&' && magic) {
|
||||||
no = 0;
|
no = 0;
|
||||||
else if (c == '\\' && *src != NUL) {
|
} else if (c == '\\' && *src != NUL) {
|
||||||
if (*src == '&' && !magic) {
|
if (*src == '&' && !magic) {
|
||||||
++src;
|
++src;
|
||||||
no = 0;
|
no = 0;
|
||||||
@@ -1863,16 +1884,21 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
no = *src++ - '0';
|
no = *src++ - '0';
|
||||||
} else if (vim_strchr((char_u *)"uUlLeE", *src)) {
|
} else if (vim_strchr((char_u *)"uUlLeE", *src)) {
|
||||||
switch (*src++) {
|
switch (*src++) {
|
||||||
case 'u': func_one = (fptr_T)do_upper;
|
case 'u':
|
||||||
|
func_one = (fptr_T)do_upper;
|
||||||
continue;
|
continue;
|
||||||
case 'U': func_all = (fptr_T)do_Upper;
|
case 'U':
|
||||||
|
func_all = (fptr_T)do_Upper;
|
||||||
continue;
|
continue;
|
||||||
case 'l': func_one = (fptr_T)do_lower;
|
case 'l':
|
||||||
|
func_one = (fptr_T)do_lower;
|
||||||
continue;
|
continue;
|
||||||
case 'L': func_all = (fptr_T)do_Lower;
|
case 'L':
|
||||||
|
func_all = (fptr_T)do_Lower;
|
||||||
continue;
|
continue;
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E': func_one = func_all = (fptr_T)NULL;
|
case 'E':
|
||||||
|
func_one = func_all = (fptr_T)NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1894,12 +1920,16 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
if (c == '\\' && *src != NUL) {
|
if (c == '\\' && *src != NUL) {
|
||||||
// Check for abbreviations -- webb
|
// Check for abbreviations -- webb
|
||||||
switch (*src) {
|
switch (*src) {
|
||||||
case 'r': c = CAR; ++src; break;
|
case 'r':
|
||||||
case 'n': c = NL; ++src; break;
|
c = CAR; ++src; break;
|
||||||
case 't': c = TAB; ++src; break;
|
case 'n':
|
||||||
|
c = NL; ++src; break;
|
||||||
|
case 't':
|
||||||
|
c = TAB; ++src; break;
|
||||||
// Oh no! \e already has meaning in subst pat :-(
|
// Oh no! \e already has meaning in subst pat :-(
|
||||||
// case 'e': c = ESC; ++src; break;
|
// case 'e': c = ESC; ++src; break;
|
||||||
case 'b': c = Ctrl_H; ++src; break;
|
case 'b':
|
||||||
|
c = Ctrl_H; ++src; break;
|
||||||
|
|
||||||
// If "backslash" is true the backslash will be removed
|
// If "backslash" is true the backslash will be removed
|
||||||
// later. Used to insert a literal CR.
|
// later. Used to insert a literal CR.
|
||||||
@@ -1967,7 +1997,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
for (;; ) {
|
for (;;) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
if (REG_MULTI) {
|
if (REG_MULTI) {
|
||||||
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
||||||
@@ -2042,8 +2072,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
no = -1;
|
no = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (copy)
|
}
|
||||||
|
if (copy) {
|
||||||
*dst = NUL;
|
*dst = NUL;
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return (int)((dst - dest) + 1 - num_escaped);
|
return (int)((dst - dest) + 1 - num_escaped);
|
||||||
@@ -2078,13 +2110,14 @@ static char_u *reg_getline_submatch(linenr_T lnum)
|
|||||||
*/
|
*/
|
||||||
char_u *reg_submatch(int no)
|
char_u *reg_submatch(int no)
|
||||||
{
|
{
|
||||||
char_u *retval = NULL;
|
char_u *retval = NULL;
|
||||||
char_u *s;
|
char_u *s;
|
||||||
int round;
|
int round;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
|
|
||||||
if (!can_f_submatch || no < 0)
|
if (!can_f_submatch || no < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (rsm.sm_match == NULL) {
|
if (rsm.sm_match == NULL) {
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
@@ -2123,12 +2156,14 @@ char_u *reg_submatch(int no)
|
|||||||
lnum++;
|
lnum++;
|
||||||
while (lnum < rsm.sm_mmatch->endpos[no].lnum) {
|
while (lnum < rsm.sm_mmatch->endpos[no].lnum) {
|
||||||
s = reg_getline_submatch(lnum++);
|
s = reg_getline_submatch(lnum++);
|
||||||
if (round == 2)
|
if (round == 2) {
|
||||||
STRCPY(retval + len, s);
|
STRCPY(retval + len, s);
|
||||||
|
}
|
||||||
len += STRLEN(s);
|
len += STRLEN(s);
|
||||||
if (round == 2)
|
if (round == 2) {
|
||||||
retval[len] = '\n';
|
retval[len] = '\n';
|
||||||
++len;
|
}
|
||||||
|
len++;
|
||||||
}
|
}
|
||||||
if (round == 2) {
|
if (round == 2) {
|
||||||
STRNCPY(retval + len, reg_getline_submatch(lnum),
|
STRNCPY(retval + len, reg_getline_submatch(lnum),
|
||||||
@@ -2252,9 +2287,9 @@ static char_u regname[][30] = {
|
|||||||
*/
|
*/
|
||||||
regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
||||||
{
|
{
|
||||||
regprog_T *prog = NULL;
|
regprog_T *prog = NULL;
|
||||||
char_u *expr = expr_arg;
|
char_u *expr = expr_arg;
|
||||||
int save_called_emsg;
|
int save_called_emsg;
|
||||||
|
|
||||||
regexp_engine = p_re;
|
regexp_engine = p_re;
|
||||||
|
|
||||||
@@ -2273,8 +2308,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
regname[newengine]);
|
regname[newengine]);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
emsg(_(
|
emsg(_("E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used "));
|
||||||
"E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used "));
|
|
||||||
regexp_engine = AUTOMATIC_ENGINE;
|
regexp_engine = AUTOMATIC_ENGINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2292,7 +2326,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
called_emsg = false;
|
called_emsg = false;
|
||||||
if (regexp_engine != BACKTRACKING_ENGINE) {
|
if (regexp_engine != BACKTRACKING_ENGINE) {
|
||||||
prog = nfa_regengine.regcomp(expr,
|
prog = nfa_regengine.regcomp(expr,
|
||||||
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
|
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
|
||||||
} else {
|
} else {
|
||||||
prog = bt_regengine.regcomp(expr, re_flags);
|
prog = bt_regengine.regcomp(expr, re_flags);
|
||||||
}
|
}
|
||||||
@@ -2339,8 +2373,9 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
*/
|
*/
|
||||||
void vim_regfree(regprog_T *prog)
|
void vim_regfree(regprog_T *prog)
|
||||||
{
|
{
|
||||||
if (prog != NULL)
|
if (prog != NULL) {
|
||||||
prog->engine->regfree(prog);
|
prog->engine->regfree(prog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2462,16 +2497,17 @@ bool vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col)
|
|||||||
/// Note: "rmp->regprog" may be freed and changed, even set to NULL.
|
/// Note: "rmp->regprog" may be freed and changed, even set to NULL.
|
||||||
/// Uses curbuf for line count and 'iskeyword'.
|
/// Uses curbuf for line count and 'iskeyword'.
|
||||||
///
|
///
|
||||||
/// Return zero if there is no match. Return number of lines contained in the
|
/// @param win window in which to search or NULL
|
||||||
/// match otherwise.
|
/// @param buf buffer in which to search
|
||||||
long vim_regexec_multi(
|
/// @param lnum nr of line to start looking for match
|
||||||
regmmatch_T *rmp,
|
/// @param col column to start looking for match
|
||||||
win_T *win, // window in which to search or NULL
|
/// @param tm timeout limit or NULL
|
||||||
buf_T *buf, // buffer in which to search
|
/// @param timed_out flag is set when timeout limit reached
|
||||||
linenr_T lnum, // nr of line to start looking for match
|
///
|
||||||
colnr_T col, // column to start looking for match
|
/// @return zero if there is no match. Return number of lines contained in the
|
||||||
proftime_T *tm, // timeout limit or NULL
|
/// match otherwise.
|
||||||
int *timed_out) // flag is set when timeout limit reached
|
long vim_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col,
|
||||||
|
proftime_T *tm, int *timed_out)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
regexec_T rex_save;
|
regexec_T rex_save;
|
||||||
|
2043
src/nvim/regexp_bt.c
2043
src/nvim/regexp_bt.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user