No OOM error conditions in quickfix.c and regex_nfa.c

quickfix.c

 - ll_new_list
 - ll_get_or_alloc_list

regex_nfa.c

 - realloc_post_list -> EMIT -> nfa_emit_equi_class
 - nfa_regcomp_start

Use xrealloc() in realloc_post_list() (regexp_nfa.c)

  Test plan: force a call to realloc_post_list() for every use of the EMIT macro;
  open nvim and test regexp search.
This commit is contained in:
Felipe Oliveira Carvalho 2014-04-21 19:43:01 -03:00 committed by Thiago de Arruda
parent e76d146029
commit 244ca83be5
2 changed files with 73 additions and 108 deletions

View File

@ -200,8 +200,6 @@ qf_init (
if (wp != NULL) { if (wp != NULL) {
qi = ll_get_or_alloc_list(wp); qi = ll_get_or_alloc_list(wp);
if (qi == NULL)
return FAIL;
} }
return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist, return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
@ -977,10 +975,7 @@ qf_add_entry (
*/ */
static qf_info_T *ll_new_list(void) static qf_info_T *ll_new_list(void)
{ {
qf_info_T *qi; qf_info_T *qi = xcalloc(1, sizeof(qf_info_T));
qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
memset(qi, 0, (size_t)(sizeof(qf_info_T)));
qi->qf_refcount++; qi->qf_refcount++;
return qi; return qi;
@ -1030,8 +1025,7 @@ void copy_loclist(win_T *from, win_T *to)
return; return;
/* allocate a new location list */ /* allocate a new location list */
if ((to->w_llist = ll_new_list()) == NULL) to->w_llist = ll_new_list();
return;
to->w_llist->qf_listcount = qi->qf_listcount; to->w_llist->qf_listcount = qi->qf_listcount;
@ -2797,8 +2791,6 @@ void ex_vimgrep(exarg_T *eap)
|| eap->cmdidx == CMD_lgrepadd || eap->cmdidx == CMD_lgrepadd
|| eap->cmdidx == CMD_lvimgrepadd) { || eap->cmdidx == CMD_lvimgrepadd) {
qi = ll_get_or_alloc_list(curwin); qi = ll_get_or_alloc_list(curwin);
if (qi == NULL)
return;
} }
if (eap->addr_count > 0) if (eap->addr_count > 0)
@ -3339,8 +3331,6 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title)
if (wp != NULL) { if (wp != NULL) {
qi = ll_get_or_alloc_list(wp); qi = ll_get_or_alloc_list(wp);
if (qi == NULL)
return FAIL;
} }
if (action == ' ' || qi->qf_curlist == qi->qf_listcount) if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
@ -3442,8 +3432,6 @@ void ex_cbuffer(exarg_T *eap)
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
|| eap->cmdidx == CMD_laddbuffer) { || eap->cmdidx == CMD_laddbuffer) {
qi = ll_get_or_alloc_list(curwin); qi = ll_get_or_alloc_list(curwin);
if (qi == NULL)
return;
} }
if (*eap->arg == NUL) if (*eap->arg == NUL)
@ -3495,8 +3483,6 @@ void ex_cexpr(exarg_T *eap)
if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
|| eap->cmdidx == CMD_laddexpr) { || eap->cmdidx == CMD_laddexpr) {
qi = ll_get_or_alloc_list(curwin); qi = ll_get_or_alloc_list(curwin);
if (qi == NULL)
return;
} }
/* Evaluate the expression. When the result is a string or a list we can /* Evaluate the expression. When the result is a string or a list we can
@ -3570,8 +3556,7 @@ void ex_helpgrep(exarg_T *eap)
if (qi == NULL) { if (qi == NULL) {
/* Allocate a new location list for help text matches */ /* Allocate a new location list for help text matches */
if ((qi = ll_new_list()) == NULL) qi = ll_new_list();
return;
new_qi = TRUE; new_qi = TRUE;
} }
} }

View File

@ -275,14 +275,14 @@ static int nfa_alt_listid;
/* 0 for first call to nfa_regmatch(), 1 for recursive call. */ /* 0 for first call to nfa_regmatch(), 1 for recursive call. */
static int nfa_ll_index = 0; static int nfa_ll_index = 0;
static int nfa_regcomp_start(char_u *expr, int re_flags); static void nfa_regcomp_start(char_u *expr, int re_flags);
static int nfa_get_reganch(nfa_state_T *start, int depth); static int nfa_get_reganch(nfa_state_T *start, int depth);
static int nfa_get_regstart(nfa_state_T *start, int depth); static int nfa_get_regstart(nfa_state_T *start, int depth);
static char_u *nfa_get_match_text(nfa_state_T *start); static char_u *nfa_get_match_text(nfa_state_T *start);
static int realloc_post_list(void); static void realloc_post_list(void);
static int nfa_recognize_char_class(char_u *start, char_u *end, static int nfa_recognize_char_class(char_u *start, char_u *end,
int extra_newl); int extra_newl);
static int nfa_emit_equi_class(int c); static void nfa_emit_equi_class(int c);
static int nfa_regatom(void); static int nfa_regatom(void);
static int nfa_regpiece(void); static int nfa_regpiece(void);
static int nfa_regconcat(void); static int nfa_regconcat(void);
@ -320,28 +320,28 @@ static int failure_chance(nfa_state_T *state, int depth);
/* helper functions used when doing re2post() ... regatom() parsing */ /* helper functions used when doing re2post() ... regatom() parsing */
#define EMIT(c) do { \ #define EMIT(c) do { \
if (post_ptr >= post_end && realloc_post_list() == FAIL) \ if (post_ptr >= post_end) { \
return FAIL; \ realloc_post_list(); \
*post_ptr++ = c; \ } \
*post_ptr++ = c; \
} while (0) } while (0)
/* /*
* Initialize internal variables before NFA compilation. * Initialize internal variables before NFA compilation.
* Return OK on success, FAIL otherwise.
*/ */
static int static void
nfa_regcomp_start ( nfa_regcomp_start (
char_u *expr, char_u *expr,
int re_flags /* see vim_regcomp() */ int re_flags /* see vim_regcomp() */
) )
{ {
size_t postfix_size; size_t postfix_size;
int nstate_max; size_t nstate_max;
nstate = 0; nstate = 0;
istate = 0; istate = 0;
/* A reasonable estimation for maximum size */ /* A reasonable estimation for maximum size */
nstate_max = (int)(STRLEN(expr) + 1) * 25; nstate_max = (STRLEN(expr) + 1) * 25;
/* Some items blow up in size, such as [A-z]. Add more space for that. /* Some items blow up in size, such as [A-z]. Add more space for that.
* When it is still not enough realloc_post_list() will be used. */ * When it is still not enough realloc_post_list() will be used. */
@ -350,9 +350,7 @@ nfa_regcomp_start (
/* Size for postfix representation of expr. */ /* Size for postfix representation of expr. */
postfix_size = sizeof(int) * nstate_max; postfix_size = sizeof(int) * nstate_max;
post_start = (int *)lalloc(postfix_size, TRUE); post_start = (int *)xmalloc(postfix_size);
if (post_start == NULL)
return FAIL;
post_ptr = post_start; post_ptr = post_start;
post_end = post_start + nstate_max; post_end = post_start + nstate_max;
nfa_has_zend = FALSE; nfa_has_zend = FALSE;
@ -360,8 +358,6 @@ nfa_regcomp_start (
/* shared with BT engine */ /* shared with BT engine */
regcomp_start(expr, re_flags); regcomp_start(expr, re_flags);
return OK;
} }
/* /*
@ -540,23 +536,13 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
* Allocate more space for post_start. Called when * Allocate more space for post_start. Called when
* running above the estimated number of states. * running above the estimated number of states.
*/ */
static int realloc_post_list(void) static void realloc_post_list(void)
{ {
int nstate_max = (int)(post_end - post_start); size_t new_max = (post_end - post_start) + 1000;
int new_max = nstate_max + 1000; int *new_start = xrealloc(post_start, new_max * sizeof(int));
int *new_start; post_ptr = new_start + (post_ptr - post_start);
int *old_start; post_end = new_start + new_max;
new_start = (int *)lalloc(new_max * sizeof(int), TRUE);
if (new_start == NULL)
return FAIL;
memmove(new_start, post_start, nstate_max * sizeof(int));
old_start = post_start;
post_start = new_start; post_start = new_start;
post_ptr = new_start + (post_ptr - old_start);
post_end = post_start + new_max;
vim_free(old_start);
return OK;
} }
/* /*
@ -691,7 +677,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl)
* *
* NOTE! When changing this function, also update reg_equi_class() * NOTE! When changing this function, also update reg_equi_class()
*/ */
static int nfa_emit_equi_class(int c) static void nfa_emit_equi_class(int c)
{ {
#define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT);
# define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); # define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT);
@ -708,23 +694,23 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104) EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104)
EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0) EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0)
EMITMBC(0x1ea2) EMITMBC(0x1ea2)
return OK; return;
case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06) case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06)
EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06) EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06)
return OK; return;
case 'C': case 0307: case 'C': case 0307:
CASEMBC(0x106) CASEMBC(0x108) CASEMBC(0x10a) CASEMBC(0x10c) CASEMBC(0x106) CASEMBC(0x108) CASEMBC(0x10a) CASEMBC(0x10c)
EMIT2('C'); EMIT2(0307); EMITMBC(0x106) EMITMBC(0x108) EMIT2('C'); EMIT2(0307); EMITMBC(0x106) EMITMBC(0x108)
EMITMBC(0x10a) EMITMBC(0x10c) EMITMBC(0x10a) EMITMBC(0x10c)
return OK; return;
case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a) case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a)
CASEMBC(0x1e0e) CASEMBC(0x1e10) CASEMBC(0x1e0e) CASEMBC(0x1e10)
EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a) EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a)
EMITMBC(0x1e0e) EMITMBC(0x1e10) EMITMBC(0x1e0e) EMITMBC(0x1e10)
return OK; return;
case 'E': case 0310: case 0311: case 0312: case 0313: case 'E': case 0310: case 0311: case 0312: case 0313:
CASEMBC(0x112) CASEMBC(0x114) CASEMBC(0x116) CASEMBC(0x118) CASEMBC(0x112) CASEMBC(0x114) CASEMBC(0x116) CASEMBC(0x118)
@ -734,11 +720,11 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116) EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116)
EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba) EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba)
EMITMBC(0x1ebc) EMITMBC(0x1ebc)
return OK; return;
case 'F': CASEMBC(0x1e1e) case 'F': CASEMBC(0x1e1e)
EMIT2('F'); EMITMBC(0x1e1e) EMIT2('F'); EMITMBC(0x1e1e)
return OK; return;
case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120) case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120)
CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) CASEMBC(0x1f4) CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) CASEMBC(0x1f4)
@ -746,13 +732,13 @@ static int nfa_emit_equi_class(int c)
EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120) EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120)
EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6) EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6)
EMITMBC(0x1f4) EMITMBC(0x1e20) EMITMBC(0x1f4) EMITMBC(0x1e20)
return OK; return;
case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22) case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22)
CASEMBC(0x1e26) CASEMBC(0x1e28) CASEMBC(0x1e26) CASEMBC(0x1e28)
EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22) EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22)
EMITMBC(0x1e26) EMITMBC(0x1e28) EMITMBC(0x1e26) EMITMBC(0x1e28)
return OK; return;
case 'I': case 0314: case 0315: case 0316: case 0317: case 'I': case 0314: case 0315: case 0316: case 0317:
CASEMBC(0x128) CASEMBC(0x12a) CASEMBC(0x12c) CASEMBC(0x12e) CASEMBC(0x128) CASEMBC(0x12a) CASEMBC(0x12c) CASEMBC(0x12e)
@ -761,34 +747,34 @@ static int nfa_emit_equi_class(int c)
EMIT2(0317); EMITMBC(0x128) EMITMBC(0x12a) EMIT2(0317); EMITMBC(0x128) EMITMBC(0x12a)
EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130) EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130)
EMITMBC(0x1cf) EMITMBC(0x1ec8) EMITMBC(0x1cf) EMITMBC(0x1ec8)
return OK; return;
case 'J': CASEMBC(0x134) case 'J': CASEMBC(0x134)
EMIT2('J'); EMITMBC(0x134) EMIT2('J'); EMITMBC(0x134)
return OK; return;
case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30) case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30)
CASEMBC(0x1e34) CASEMBC(0x1e34)
EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30) EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30)
EMITMBC(0x1e34) EMITMBC(0x1e34)
return OK; return;
case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d) case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d)
CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a) CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a)
EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d) EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d)
EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a) EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a)
return OK; return;
case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40) case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40)
EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40) EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40)
return OK; return;
case 'N': case 0321: case 'N': case 0321:
CASEMBC(0x143) CASEMBC(0x145) CASEMBC(0x147) CASEMBC(0x1e44) CASEMBC(0x143) CASEMBC(0x145) CASEMBC(0x147) CASEMBC(0x1e44)
CASEMBC(0x1e48) CASEMBC(0x1e48)
EMIT2('N'); EMIT2(0321); EMITMBC(0x143) EMITMBC(0x145) EMIT2('N'); EMIT2(0321); EMITMBC(0x143) EMITMBC(0x145)
EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48) EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48)
return OK; return;
case 'O': case 0322: case 0323: case 0324: case 0325: case 'O': case 0322: case 0323: case 0324: case 0325:
case 0326: case 0330: case 0326: case 0330:
@ -799,29 +785,29 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150) EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150)
EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea) EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea)
EMITMBC(0x1ec) EMITMBC(0x1ece) EMITMBC(0x1ec) EMITMBC(0x1ece)
return OK; return;
case 'P': case 0x1e54: case 0x1e56: case 'P': case 0x1e54: case 0x1e56:
EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56) EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56)
return OK; return;
case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158) case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158)
CASEMBC(0x1e58) CASEMBC(0x1e5e) CASEMBC(0x1e58) CASEMBC(0x1e5e)
EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158) EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158)
EMITMBC(0x1e58) EMITMBC(0x1e5e) EMITMBC(0x1e58) EMITMBC(0x1e5e)
return OK; return;
case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e) case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e)
CASEMBC(0x160) CASEMBC(0x1e60) CASEMBC(0x160) CASEMBC(0x1e60)
EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e) EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e)
EMITMBC(0x160) EMITMBC(0x1e60) EMITMBC(0x160) EMITMBC(0x1e60)
return OK; return;
case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166) case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166)
CASEMBC(0x1e6a) CASEMBC(0x1e6e) CASEMBC(0x1e6a) CASEMBC(0x1e6e)
EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166) EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166)
EMITMBC(0x1e6a) EMITMBC(0x1e6e) EMITMBC(0x1e6a) EMITMBC(0x1e6e)
return OK; return;
case 'U': case 0331: case 0332: case 0333: case 0334: case 'U': case 0331: case 0332: case 0333: case 0334:
CASEMBC(0x168) CASEMBC(0x16a) CASEMBC(0x16c) CASEMBC(0x16e) CASEMBC(0x168) CASEMBC(0x16a) CASEMBC(0x16c) CASEMBC(0x16e)
@ -832,21 +818,21 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170) EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170)
EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3) EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3)
EMITMBC(0x1ee6) EMITMBC(0x1ee6)
return OK; return;
case 'V': CASEMBC(0x1e7c) case 'V': CASEMBC(0x1e7c)
EMIT2('V'); EMITMBC(0x1e7c) EMIT2('V'); EMITMBC(0x1e7c)
return OK; return;
case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82) case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82)
CASEMBC(0x1e84) CASEMBC(0x1e86) CASEMBC(0x1e84) CASEMBC(0x1e86)
EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82) EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82)
EMITMBC(0x1e84) EMITMBC(0x1e86) EMITMBC(0x1e84) EMITMBC(0x1e86)
return OK; return;
case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c) case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c)
EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c) EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c)
return OK; return;
case 'Y': case 0335: case 'Y': case 0335:
CASEMBC(0x176) CASEMBC(0x178) CASEMBC(0x1e8e) CASEMBC(0x1ef2) CASEMBC(0x176) CASEMBC(0x178) CASEMBC(0x1e8e) CASEMBC(0x1ef2)
@ -854,13 +840,13 @@ static int nfa_emit_equi_class(int c)
EMIT2('Y'); EMIT2(0335); EMITMBC(0x176) EMITMBC(0x178) EMIT2('Y'); EMIT2(0335); EMITMBC(0x176) EMITMBC(0x178)
EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6) EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6)
EMITMBC(0x1ef8) EMITMBC(0x1ef8)
return OK; return;
case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d) case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d)
CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94) CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94)
EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d) EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d)
EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94) EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94)
return OK; return;
case 'a': case 0340: case 0341: case 0342: case 'a': case 0340: case 0341: case 0342:
case 0343: case 0344: case 0345: case 0343: case 0344: case 0345:
@ -871,23 +857,23 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105) EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105)
EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1) EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1)
EMITMBC(0x1ea3) EMITMBC(0x1ea3)
return OK; return;
case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07) case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07)
EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07) EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07)
return OK; return;
case 'c': case 0347: case 'c': case 0347:
CASEMBC(0x107) CASEMBC(0x109) CASEMBC(0x10b) CASEMBC(0x10d) CASEMBC(0x107) CASEMBC(0x109) CASEMBC(0x10b) CASEMBC(0x10d)
EMIT2('c'); EMIT2(0347); EMITMBC(0x107) EMITMBC(0x109) EMIT2('c'); EMIT2(0347); EMITMBC(0x107) EMITMBC(0x109)
EMITMBC(0x10b) EMITMBC(0x10d) EMITMBC(0x10b) EMITMBC(0x10d)
return OK; return;
case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1d0b) case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1d0b)
CASEMBC(0x1e11) CASEMBC(0x1e11)
EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111) EMITMBC(0x1e0b) EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111) EMITMBC(0x1e0b)
EMITMBC(0x01e0f) EMITMBC(0x1e11) EMITMBC(0x01e0f) EMITMBC(0x1e11)
return OK; return;
case 'e': case 0350: case 0351: case 0352: case 0353: case 'e': case 0350: case 0351: case 0352: case 0353:
CASEMBC(0x113) CASEMBC(0x115) CASEMBC(0x117) CASEMBC(0x119) CASEMBC(0x113) CASEMBC(0x115) CASEMBC(0x117) CASEMBC(0x119)
@ -896,11 +882,11 @@ static int nfa_emit_equi_class(int c)
EMIT2(0353); EMITMBC(0x113) EMITMBC(0x115) EMIT2(0353); EMITMBC(0x113) EMITMBC(0x115)
EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b) EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b)
EMITMBC(0x1ebb) EMITMBC(0x1ebd) EMITMBC(0x1ebb) EMITMBC(0x1ebd)
return OK; return;
case 'f': CASEMBC(0x1e1f) case 'f': CASEMBC(0x1e1f)
EMIT2('f'); EMITMBC(0x1e1f) EMIT2('f'); EMITMBC(0x1e1f)
return OK; return;
case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121) case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121)
CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) CASEMBC(0x1f5) CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) CASEMBC(0x1f5)
@ -908,13 +894,13 @@ static int nfa_emit_equi_class(int c)
EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121) EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121)
EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7) EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7)
EMITMBC(0x1f5) EMITMBC(0x1e21) EMITMBC(0x1f5) EMITMBC(0x1e21)
return OK; return;
case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23) case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23)
CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96) CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96)
EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23) EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23)
EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96) EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96)
return OK; return;
case 'i': case 0354: case 0355: case 0356: case 0357: case 'i': case 0354: case 0355: case 0356: case 0357:
CASEMBC(0x129) CASEMBC(0x12b) CASEMBC(0x12d) CASEMBC(0x12f) CASEMBC(0x129) CASEMBC(0x12b) CASEMBC(0x12d) CASEMBC(0x12f)
@ -923,27 +909,27 @@ static int nfa_emit_equi_class(int c)
EMIT2(0357); EMITMBC(0x129) EMITMBC(0x12b) EMIT2(0357); EMITMBC(0x129) EMITMBC(0x12b)
EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0) EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0)
EMITMBC(0x1ec9) EMITMBC(0x1ec9)
return OK; return;
case 'j': CASEMBC(0x135) CASEMBC(0x1f0) case 'j': CASEMBC(0x135) CASEMBC(0x1f0)
EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0) EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0)
return OK; return;
case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31) case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31)
CASEMBC(0x1e35) CASEMBC(0x1e35)
EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31) EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31)
EMITMBC(0x1e35) EMITMBC(0x1e35)
return OK; return;
case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e) case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e)
CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b) CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b)
EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e) EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e)
EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b) EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b)
return OK; return;
case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41) case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41)
EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41) EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41)
return OK; return;
case 'n': case 0361: case 'n': case 0361:
CASEMBC(0x144) CASEMBC(0x146) CASEMBC(0x148) CASEMBC(0x149) CASEMBC(0x144) CASEMBC(0x146) CASEMBC(0x148) CASEMBC(0x149)
@ -951,7 +937,7 @@ static int nfa_emit_equi_class(int c)
EMIT2('n'); EMIT2(0361); EMITMBC(0x144) EMITMBC(0x146) EMIT2('n'); EMIT2(0361); EMITMBC(0x144) EMITMBC(0x146)
EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45) EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45)
EMITMBC(0x1e49) EMITMBC(0x1e49)
return OK; return;
case 'o': case 0362: case 0363: case 0364: case 0365: case 'o': case 0362: case 0363: case 0364: case 0365:
case 0366: case 0370: case 0366: case 0370:
@ -962,29 +948,29 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151) EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151)
EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb) EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb)
EMITMBC(0x1ed) EMITMBC(0x1ecf) EMITMBC(0x1ed) EMITMBC(0x1ecf)
return OK; return;
case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57) case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57)
EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57) EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57)
return OK; return;
case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159) case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159)
CASEMBC(0x1e59) CASEMBC(0x1e5f) CASEMBC(0x1e59) CASEMBC(0x1e5f)
EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159) EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159)
EMITMBC(0x1e59) EMITMBC(0x1e5f) EMITMBC(0x1e59) EMITMBC(0x1e5f)
return OK; return;
case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f) case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f)
CASEMBC(0x161) CASEMBC(0x1e61) CASEMBC(0x161) CASEMBC(0x1e61)
EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f) EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f)
EMITMBC(0x161) EMITMBC(0x1e61) EMITMBC(0x161) EMITMBC(0x1e61)
return OK; return;
case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167) case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167)
CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97) CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97)
EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167) EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167)
EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97) EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97)
return OK; return;
case 'u': case 0371: case 0372: case 0373: case 0374: case 'u': case 0371: case 0372: case 0373: case 0374:
CASEMBC(0x169) CASEMBC(0x16b) CASEMBC(0x16d) CASEMBC(0x16f) CASEMBC(0x169) CASEMBC(0x16b) CASEMBC(0x16d) CASEMBC(0x16f)
@ -995,21 +981,21 @@ static int nfa_emit_equi_class(int c)
EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171) EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171)
EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4) EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4)
EMITMBC(0x1ee7) EMITMBC(0x1ee7)
return OK; return;
case 'v': CASEMBC(0x1e7d) case 'v': CASEMBC(0x1e7d)
EMIT2('v'); EMITMBC(0x1e7d) EMIT2('v'); EMITMBC(0x1e7d)
return OK; return;
case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83) case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83)
CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98) CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98)
EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83) EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83)
EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98) EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98)
return OK; return;
case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d) case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d)
EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d) EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d)
return OK; return;
case 'y': case 0375: case 0377: case 'y': case 0375: case 0377:
CASEMBC(0x177) CASEMBC(0x1e8f) CASEMBC(0x1e99) CASEMBC(0x177) CASEMBC(0x1e8f) CASEMBC(0x1e99)
@ -1017,20 +1003,19 @@ static int nfa_emit_equi_class(int c)
EMIT2('y'); EMIT2(0375); EMIT2(0377); EMITMBC(0x177) EMIT2('y'); EMIT2(0375); EMIT2(0377); EMITMBC(0x177)
EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3) EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3)
EMITMBC(0x1ef7) EMITMBC(0x1ef9) EMITMBC(0x1ef7) EMITMBC(0x1ef9)
return OK; return;
case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e) case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e)
CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95) CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95)
EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e) EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e)
EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95) EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95)
return OK; return;
/* default: character itself */ /* default: character itself */
} }
} }
EMIT2(c); EMIT2(c);
return OK;
#undef EMIT2 #undef EMIT2
#undef EMITMBC #undef EMITMBC
} }
@ -1530,12 +1515,8 @@ collection:
} }
/* Try equivalence class [=a=] and the like */ /* Try equivalence class [=a=] and the like */
if (equiclass != 0) { if (equiclass != 0) {
result = nfa_emit_equi_class(equiclass); nfa_emit_equi_class(equiclass);
if (result == FAIL) { result = OK;
/* should never happen */
EMSG_RET_FAIL(_(
"E868: Error building NFA with equivalence class!"));
}
continue; continue;
} }
/* Try collating class like [. .] */ /* Try collating class like [. .] */
@ -6263,8 +6244,7 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags)
init_class_tab(); init_class_tab();
if (nfa_regcomp_start(expr, re_flags) == FAIL) nfa_regcomp_start(expr, re_flags);
return NULL;
/* Build postfix form of the regexp. Needed to build the NFA /* Build postfix form of the regexp. Needed to build the NFA
* (and count its size). */ * (and count its size). */