Mercurial > vim
comparison src/regexp_nfa.c @ 15603:639b8318472c v8.1.0809
patch 8.1.0809: too many #ifdefs
commit https://github.com/vim/vim/commit/a12a161b8ce09d024ed71c2134149fa323f8ee8e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 16:39:02 2019 +0100
patch 8.1.0809: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 3.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 16:45:06 +0100 |
parents | 98c35d312987 |
children | 2e2f07561f4b |
comparison
equal
deleted
inserted
replaced
15602:2ef2028868e2 | 15603:639b8318472c |
---|---|
485 { | 485 { |
486 p = start->out->out; /* skip first char, it goes into regstart */ | 486 p = start->out->out; /* skip first char, it goes into regstart */ |
487 s = ret; | 487 s = ret; |
488 while (p->c > 0) | 488 while (p->c > 0) |
489 { | 489 { |
490 #ifdef FEAT_MBYTE | |
491 if (has_mbyte) | 490 if (has_mbyte) |
492 s += (*mb_char2bytes)(p->c, s); | 491 s += (*mb_char2bytes)(p->c, s); |
493 else | 492 else |
494 #endif | |
495 *s++ = p->c; | 493 *s++ = p->c; |
496 p = p->out; | 494 p = p->out; |
497 } | 495 } |
498 *s = NUL; | 496 *s = NUL; |
499 } | 497 } |
685 */ | 683 */ |
686 static int | 684 static int |
687 nfa_emit_equi_class(int c) | 685 nfa_emit_equi_class(int c) |
688 { | 686 { |
689 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); | 687 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); |
690 #ifdef FEAT_MBYTE | 688 #define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); |
691 # define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); | 689 |
692 #else | |
693 # define EMITMBC(c) | |
694 #endif | |
695 | |
696 #ifdef FEAT_MBYTE | |
697 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0 | 690 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0 |
698 || STRCMP(p_enc, "iso-8859-15") == 0) | 691 || STRCMP(p_enc, "iso-8859-15") == 0) |
699 #endif | |
700 { | 692 { |
701 #ifdef EBCDIC | 693 #ifdef EBCDIC |
702 # define A_circumflex 0x62 | 694 # define A_circumflex 0x62 |
703 # define A_diaeresis 0x63 | 695 # define A_diaeresis 0x63 |
704 # define A_grave 0x64 | 696 # define A_grave 0x64 |
1201 int equiclass; | 1193 int equiclass; |
1202 int collclass; | 1194 int collclass; |
1203 int got_coll_char; | 1195 int got_coll_char; |
1204 char_u *p; | 1196 char_u *p; |
1205 char_u *endp; | 1197 char_u *endp; |
1206 #ifdef FEAT_MBYTE | |
1207 char_u *old_regparse = regparse; | 1198 char_u *old_regparse = regparse; |
1208 #endif | |
1209 int extra = 0; | 1199 int extra = 0; |
1210 int emit_range; | 1200 int emit_range; |
1211 int negated; | 1201 int negated; |
1212 int result; | 1202 int result; |
1213 int startc = -1; | 1203 int startc = -1; |
1308 return FAIL; | 1298 return FAIL; |
1309 } | 1299 } |
1310 siemsg("INTERNAL: Unknown character class char: %d", c); | 1300 siemsg("INTERNAL: Unknown character class char: %d", c); |
1311 return FAIL; | 1301 return FAIL; |
1312 } | 1302 } |
1313 #ifdef FEAT_MBYTE | 1303 |
1314 /* When '.' is followed by a composing char ignore the dot, so that | 1304 /* When '.' is followed by a composing char ignore the dot, so that |
1315 * the composing char is matched here. */ | 1305 * the composing char is matched here. */ |
1316 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr())) | 1306 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr())) |
1317 { | 1307 { |
1318 old_regparse = regparse; | 1308 old_regparse = regparse; |
1319 c = getchr(); | 1309 c = getchr(); |
1320 goto nfa_do_multibyte; | 1310 goto nfa_do_multibyte; |
1321 } | 1311 } |
1322 #endif | |
1323 EMIT(nfa_classcodes[p - classchars]); | 1312 EMIT(nfa_classcodes[p - classchars]); |
1324 if (extra == NFA_ADD_NL) | 1313 if (extra == NFA_ADD_NL) |
1325 { | 1314 { |
1326 EMIT(NFA_NEWL); | 1315 EMIT(NFA_NEWL); |
1327 EMIT(NFA_OR); | 1316 EMIT(NFA_OR); |
1825 --post_ptr; /* remove NFA_CONCAT */ | 1814 --post_ptr; /* remove NFA_CONCAT */ |
1826 EMIT(endc); | 1815 EMIT(endc); |
1827 EMIT(NFA_RANGE); | 1816 EMIT(NFA_RANGE); |
1828 EMIT(NFA_CONCAT); | 1817 EMIT(NFA_CONCAT); |
1829 } | 1818 } |
1830 else | 1819 else if (has_mbyte && ((*mb_char2len)(startc) > 1 |
1831 #ifdef FEAT_MBYTE | |
1832 if (has_mbyte && ((*mb_char2len)(startc) > 1 | |
1833 || (*mb_char2len)(endc) > 1)) | 1820 || (*mb_char2len)(endc) > 1)) |
1834 { | 1821 { |
1835 /* Emit the characters in the range. | 1822 /* Emit the characters in the range. |
1836 * "startc" was already emitted, so skip it. | 1823 * "startc" was already emitted, so skip it. |
1837 * */ | 1824 * */ |
1840 EMIT(c); | 1827 EMIT(c); |
1841 EMIT(NFA_CONCAT); | 1828 EMIT(NFA_CONCAT); |
1842 } | 1829 } |
1843 } | 1830 } |
1844 else | 1831 else |
1845 #endif | |
1846 { | 1832 { |
1847 #ifdef EBCDIC | 1833 #ifdef EBCDIC |
1848 int alpha_only = FALSE; | 1834 int alpha_only = FALSE; |
1849 | 1835 |
1850 /* for alphabetical range skip the gaps | 1836 /* for alphabetical range skip the gaps |
1927 EMSG_RET_FAIL(_(e_missingbracket)); | 1913 EMSG_RET_FAIL(_(e_missingbracket)); |
1928 /* FALLTHROUGH */ | 1914 /* FALLTHROUGH */ |
1929 | 1915 |
1930 default: | 1916 default: |
1931 { | 1917 { |
1932 #ifdef FEAT_MBYTE | |
1933 int plen; | 1918 int plen; |
1934 | 1919 |
1935 nfa_do_multibyte: | 1920 nfa_do_multibyte: |
1936 /* plen is length of current char with composing chars */ | 1921 /* plen is length of current char with composing chars */ |
1937 if (enc_utf8 && ((*mb_char2len)(c) | 1922 if (enc_utf8 && ((*mb_char2len)(c) |
1959 } | 1944 } |
1960 EMIT(NFA_COMPOSING); | 1945 EMIT(NFA_COMPOSING); |
1961 regparse = old_regparse + plen; | 1946 regparse = old_regparse + plen; |
1962 } | 1947 } |
1963 else | 1948 else |
1964 #endif | |
1965 { | 1949 { |
1966 c = no_Magic(c); | 1950 c = no_Magic(c); |
1967 EMIT(c); | 1951 EMIT(c); |
1968 } | 1952 } |
1969 return OK; | 1953 return OK; |
2209 case Magic(')'): | 2193 case Magic(')'): |
2210 cont = FALSE; | 2194 cont = FALSE; |
2211 break; | 2195 break; |
2212 | 2196 |
2213 case Magic('Z'): | 2197 case Magic('Z'): |
2214 #ifdef FEAT_MBYTE | |
2215 regflags |= RF_ICOMBINE; | 2198 regflags |= RF_ICOMBINE; |
2216 #endif | |
2217 skipchr_keepstart(); | 2199 skipchr_keepstart(); |
2218 break; | 2200 break; |
2219 case Magic('c'): | 2201 case Magic('c'): |
2220 regflags |= RF_ICASE; | 2202 regflags |= RF_ICASE; |
2221 skipchr_keepstart(); | 2203 skipchr_keepstart(); |
2994 | 2976 |
2995 case NFA_ANY: | 2977 case NFA_ANY: |
2996 case NFA_START_COLL: | 2978 case NFA_START_COLL: |
2997 case NFA_START_NEG_COLL: | 2979 case NFA_START_NEG_COLL: |
2998 /* matches some character, including composing chars */ | 2980 /* matches some character, including composing chars */ |
2999 #ifdef FEAT_MBYTE | |
3000 if (enc_utf8) | 2981 if (enc_utf8) |
3001 len += MB_MAXBYTES; | 2982 len += MB_MAXBYTES; |
3002 else if (has_mbyte) | 2983 else if (has_mbyte) |
3003 len += 2; | 2984 len += 2; |
3004 else | 2985 else |
3005 #endif | |
3006 ++len; | 2986 ++len; |
3007 if (state->c != NFA_ANY) | 2987 if (state->c != NFA_ANY) |
3008 { | 2988 { |
3009 /* skip over the characters */ | 2989 /* skip over the characters */ |
3010 state = state->out1->out; | 2990 state = state->out1->out; |
3046 case NFA_NLOWER_IC: | 3026 case NFA_NLOWER_IC: |
3047 case NFA_UPPER_IC: | 3027 case NFA_UPPER_IC: |
3048 case NFA_NUPPER_IC: | 3028 case NFA_NUPPER_IC: |
3049 case NFA_ANY_COMPOSING: | 3029 case NFA_ANY_COMPOSING: |
3050 /* possibly non-ascii */ | 3030 /* possibly non-ascii */ |
3051 #ifdef FEAT_MBYTE | |
3052 if (has_mbyte) | 3031 if (has_mbyte) |
3053 len += 3; | 3032 len += 3; |
3054 else | 3033 else |
3055 #endif | |
3056 ++len; | 3034 ++len; |
3057 break; | 3035 break; |
3058 | 3036 |
3059 case NFA_START_INVISIBLE: | 3037 case NFA_START_INVISIBLE: |
3060 case NFA_START_INVISIBLE_NEG: | 3038 case NFA_START_INVISIBLE_NEG: |
3499 } | 3477 } |
3500 } | 3478 } |
3501 break; | 3479 break; |
3502 } | 3480 } |
3503 | 3481 |
3504 #ifdef FEAT_MBYTE | |
3505 case NFA_COMPOSING: /* char with composing char */ | 3482 case NFA_COMPOSING: /* char with composing char */ |
3506 #if 0 | 3483 #if 0 |
3507 /* TODO */ | 3484 /* TODO */ |
3508 if (regflags & RF_ICOMBINE) | 3485 if (regflags & RF_ICOMBINE) |
3509 { | 3486 { |
3510 /* use the base character only */ | 3487 /* use the base character only */ |
3511 } | 3488 } |
3512 #endif | 3489 #endif |
3513 /* FALLTHROUGH */ | 3490 /* FALLTHROUGH */ |
3514 #endif | |
3515 | 3491 |
3516 case NFA_MOPEN: /* \( \) Submatch */ | 3492 case NFA_MOPEN: /* \( \) Submatch */ |
3517 case NFA_MOPEN1: | 3493 case NFA_MOPEN1: |
3518 case NFA_MOPEN2: | 3494 case NFA_MOPEN2: |
3519 case NFA_MOPEN3: | 3495 case NFA_MOPEN3: |
3556 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break; | 3532 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break; |
3557 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break; | 3533 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break; |
3558 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break; | 3534 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break; |
3559 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break; | 3535 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break; |
3560 #endif | 3536 #endif |
3561 #ifdef FEAT_MBYTE | |
3562 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break; | 3537 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break; |
3563 #endif | |
3564 default: | 3538 default: |
3565 /* NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9 */ | 3539 /* NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9 */ |
3566 mclose = *p + NSUBEXP; | 3540 mclose = *p + NSUBEXP; |
3567 break; | 3541 break; |
3568 } | 3542 } |
3594 s1 = alloc_state(mclose, NULL, NULL); /* `)' */ | 3568 s1 = alloc_state(mclose, NULL, NULL); /* `)' */ |
3595 if (s1 == NULL) | 3569 if (s1 == NULL) |
3596 goto theend; | 3570 goto theend; |
3597 patch(e.out, s1); | 3571 patch(e.out, s1); |
3598 | 3572 |
3599 #ifdef FEAT_MBYTE | |
3600 if (mopen == NFA_COMPOSING) | 3573 if (mopen == NFA_COMPOSING) |
3601 /* COMPOSING->out1 = END_COMPOSING */ | 3574 /* COMPOSING->out1 = END_COMPOSING */ |
3602 patch(list1(&s->out1), s1); | 3575 patch(list1(&s->out1), s1); |
3603 #endif | |
3604 | 3576 |
3605 PUSH(frag(s, list1(&s1->out))); | 3577 PUSH(frag(s, list1(&s1->out))); |
3606 break; | 3578 break; |
3607 | 3579 |
3608 case NFA_BACKREF1: | 3580 case NFA_BACKREF1: |
5117 rex.input = rex.line + STRLEN(rex.line); | 5089 rex.input = rex.line + STRLEN(rex.line); |
5118 } | 5090 } |
5119 if ((int)(rex.input - rex.line) >= state->val) | 5091 if ((int)(rex.input - rex.line) >= state->val) |
5120 { | 5092 { |
5121 rex.input -= state->val; | 5093 rex.input -= state->val; |
5122 #ifdef FEAT_MBYTE | |
5123 if (has_mbyte) | 5094 if (has_mbyte) |
5124 rex.input -= mb_head_off(rex.line, rex.input); | 5095 rex.input -= mb_head_off(rex.line, rex.input); |
5125 #endif | |
5126 } | 5096 } |
5127 else | 5097 else |
5128 rex.input = rex.line; | 5098 rex.input = rex.line; |
5129 } | 5099 } |
5130 } | 5100 } |
5379 skip_to_start(int c, colnr_T *colp) | 5349 skip_to_start(int c, colnr_T *colp) |
5380 { | 5350 { |
5381 char_u *s; | 5351 char_u *s; |
5382 | 5352 |
5383 /* Used often, do some work to avoid call overhead. */ | 5353 /* Used often, do some work to avoid call overhead. */ |
5384 if (!rex.reg_ic | 5354 if (!rex.reg_ic && !has_mbyte) |
5385 #ifdef FEAT_MBYTE | |
5386 && !has_mbyte | |
5387 #endif | |
5388 ) | |
5389 s = vim_strbyte(rex.line + *colp, c); | 5355 s = vim_strbyte(rex.line + *colp, c); |
5390 else | 5356 else |
5391 s = cstrchr(rex.line + *colp, c); | 5357 s = cstrchr(rex.line + *colp, c); |
5392 if (s == NULL) | 5358 if (s == NULL) |
5393 return FAIL; | 5359 return FAIL; |
5422 break; | 5388 break; |
5423 } | 5389 } |
5424 len2 += MB_CHAR2LEN(c2); | 5390 len2 += MB_CHAR2LEN(c2); |
5425 } | 5391 } |
5426 if (match | 5392 if (match |
5427 #ifdef FEAT_MBYTE | |
5428 /* check that no composing char follows */ | 5393 /* check that no composing char follows */ |
5429 && !(enc_utf8 | 5394 && !(enc_utf8 |
5430 && utf_iscomposing(PTR2CHAR(rex.line + col + len2))) | 5395 && utf_iscomposing(PTR2CHAR(rex.line + col + len2)))) |
5431 #endif | |
5432 ) | |
5433 { | 5396 { |
5434 cleanup_subexpr(); | 5397 cleanup_subexpr(); |
5435 if (REG_MULTI) | 5398 if (REG_MULTI) |
5436 { | 5399 { |
5437 rex.reg_startpos[0].lnum = rex.lnum; | 5400 rex.reg_startpos[0].lnum = rex.lnum; |
5594 for (;;) | 5557 for (;;) |
5595 { | 5558 { |
5596 int curc; | 5559 int curc; |
5597 int clen; | 5560 int clen; |
5598 | 5561 |
5599 #ifdef FEAT_MBYTE | |
5600 if (has_mbyte) | 5562 if (has_mbyte) |
5601 { | 5563 { |
5602 curc = (*mb_ptr2char)(rex.input); | 5564 curc = (*mb_ptr2char)(rex.input); |
5603 clen = (*mb_ptr2len)(rex.input); | 5565 clen = (*mb_ptr2len)(rex.input); |
5604 } | 5566 } |
5605 else | 5567 else |
5606 #endif | |
5607 { | 5568 { |
5608 curc = *rex.input; | 5569 curc = *rex.input; |
5609 clen = 1; | 5570 clen = 1; |
5610 } | 5571 } |
5611 if (curc == NUL) | 5572 if (curc == NUL) |
5706 add_count = 0; | 5667 add_count = 0; |
5707 switch (t->state->c) | 5668 switch (t->state->c) |
5708 { | 5669 { |
5709 case NFA_MATCH: | 5670 case NFA_MATCH: |
5710 { | 5671 { |
5711 #ifdef FEAT_MBYTE | |
5712 /* If the match ends before a composing characters and | 5672 /* If the match ends before a composing characters and |
5713 * rex.reg_icombine is not set, that is not really a match. */ | 5673 * rex.reg_icombine is not set, that is not really a match. */ |
5714 if (enc_utf8 && !rex.reg_icombine && utf_iscomposing(curc)) | 5674 if (enc_utf8 && !rex.reg_icombine && utf_iscomposing(curc)) |
5715 break; | 5675 break; |
5716 #endif | 5676 |
5717 nfa_match = TRUE; | 5677 nfa_match = TRUE; |
5718 copy_sub(&submatch->norm, &t->subs.norm); | 5678 copy_sub(&submatch->norm, &t->subs.norm); |
5719 #ifdef FEAT_SYN_HL | 5679 #ifdef FEAT_SYN_HL |
5720 if (rex.nfa_has_zsubexpr) | 5680 if (rex.nfa_has_zsubexpr) |
5721 copy_sub(&submatch->synt, &t->subs.synt); | 5681 copy_sub(&submatch->synt, &t->subs.synt); |
6022 case NFA_BOW: | 5982 case NFA_BOW: |
6023 result = TRUE; | 5983 result = TRUE; |
6024 | 5984 |
6025 if (curc == NUL) | 5985 if (curc == NUL) |
6026 result = FALSE; | 5986 result = FALSE; |
6027 #ifdef FEAT_MBYTE | |
6028 else if (has_mbyte) | 5987 else if (has_mbyte) |
6029 { | 5988 { |
6030 int this_class; | 5989 int this_class; |
6031 | 5990 |
6032 /* Get class of current and previous char (if it exists). */ | 5991 /* Get class of current and previous char (if it exists). */ |
6034 if (this_class <= 1) | 5993 if (this_class <= 1) |
6035 result = FALSE; | 5994 result = FALSE; |
6036 else if (reg_prev_class() == this_class) | 5995 else if (reg_prev_class() == this_class) |
6037 result = FALSE; | 5996 result = FALSE; |
6038 } | 5997 } |
6039 #endif | |
6040 else if (!vim_iswordc_buf(curc, rex.reg_buf) | 5998 else if (!vim_iswordc_buf(curc, rex.reg_buf) |
6041 || (rex.input > rex.line | 5999 || (rex.input > rex.line |
6042 && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) | 6000 && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) |
6043 result = FALSE; | 6001 result = FALSE; |
6044 if (result) | 6002 if (result) |
6050 | 6008 |
6051 case NFA_EOW: | 6009 case NFA_EOW: |
6052 result = TRUE; | 6010 result = TRUE; |
6053 if (rex.input == rex.line) | 6011 if (rex.input == rex.line) |
6054 result = FALSE; | 6012 result = FALSE; |
6055 #ifdef FEAT_MBYTE | |
6056 else if (has_mbyte) | 6013 else if (has_mbyte) |
6057 { | 6014 { |
6058 int this_class, prev_class; | 6015 int this_class, prev_class; |
6059 | 6016 |
6060 /* Get class of current and previous char (if it exists). */ | 6017 /* Get class of current and previous char (if it exists). */ |
6062 prev_class = reg_prev_class(); | 6019 prev_class = reg_prev_class(); |
6063 if (this_class == prev_class | 6020 if (this_class == prev_class |
6064 || prev_class == 0 || prev_class == 1) | 6021 || prev_class == 0 || prev_class == 1) |
6065 result = FALSE; | 6022 result = FALSE; |
6066 } | 6023 } |
6067 #endif | |
6068 else if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf) | 6024 else if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf) |
6069 || (rex.input[0] != NUL | 6025 || (rex.input[0] != NUL |
6070 && vim_iswordc_buf(curc, rex.reg_buf))) | 6026 && vim_iswordc_buf(curc, rex.reg_buf))) |
6071 result = FALSE; | 6027 result = FALSE; |
6072 if (result) | 6028 if (result) |
6091 add_here = TRUE; | 6047 add_here = TRUE; |
6092 add_state = t->state->out; | 6048 add_state = t->state->out; |
6093 } | 6049 } |
6094 break; | 6050 break; |
6095 | 6051 |
6096 #ifdef FEAT_MBYTE | |
6097 case NFA_COMPOSING: | 6052 case NFA_COMPOSING: |
6098 { | 6053 { |
6099 int mc = curc; | 6054 int mc = curc; |
6100 int len = 0; | 6055 int len = 0; |
6101 nfa_state_T *end; | 6056 nfa_state_T *end; |
6167 | 6122 |
6168 end = t->state->out1; /* NFA_END_COMPOSING */ | 6123 end = t->state->out1; /* NFA_END_COMPOSING */ |
6169 ADD_STATE_IF_MATCH(end); | 6124 ADD_STATE_IF_MATCH(end); |
6170 break; | 6125 break; |
6171 } | 6126 } |
6172 #endif | |
6173 | 6127 |
6174 case NFA_NEWL: | 6128 case NFA_NEWL: |
6175 if (curc == NUL && !rex.reg_line_lbr && REG_MULTI | 6129 if (curc == NUL && !rex.reg_line_lbr && REG_MULTI |
6176 && rex.lnum <= rex.reg_maxline) | 6130 && rex.lnum <= rex.reg_maxline) |
6177 { | 6131 { |
6272 break; | 6226 break; |
6273 | 6227 |
6274 case NFA_ANY_COMPOSING: | 6228 case NFA_ANY_COMPOSING: |
6275 /* On a composing character skip over it. Otherwise do | 6229 /* On a composing character skip over it. Otherwise do |
6276 * nothing. Always matches. */ | 6230 * nothing. Always matches. */ |
6277 #ifdef FEAT_MBYTE | |
6278 if (enc_utf8 && utf_iscomposing(curc)) | 6231 if (enc_utf8 && utf_iscomposing(curc)) |
6279 { | 6232 { |
6280 add_off = clen; | 6233 add_off = clen; |
6281 } | 6234 } |
6282 else | 6235 else |
6283 #endif | |
6284 { | 6236 { |
6285 add_here = TRUE; | 6237 add_here = TRUE; |
6286 add_off = 0; | 6238 add_off = 0; |
6287 } | 6239 } |
6288 add_state = t->state->out; | 6240 add_state = t->state->out; |
6560 win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; | 6512 win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; |
6561 | 6513 |
6562 /* Bail out quickly when there can't be a match, avoid the | 6514 /* Bail out quickly when there can't be a match, avoid the |
6563 * overhead of win_linetabsize() on long lines. */ | 6515 * overhead of win_linetabsize() on long lines. */ |
6564 if (op != 1 && col > t->state->val | 6516 if (op != 1 && col > t->state->val |
6565 #ifdef FEAT_MBYTE | 6517 * (has_mbyte ? MB_MAXBYTES : 1)) |
6566 * (has_mbyte ? MB_MAXBYTES : 1) | |
6567 #endif | |
6568 ) | |
6569 break; | 6518 break; |
6570 result = FALSE; | 6519 result = FALSE; |
6571 if (op == 1 && col - 1 > t->state->val && col > 100) | 6520 if (op == 1 && col - 1 > t->state->val && col > 100) |
6572 { | 6521 { |
6573 int ts = wp->w_buffer->b_p_ts; | 6522 int ts = wp->w_buffer->b_p_ts; |
6674 #endif | 6623 #endif |
6675 result = (c == curc); | 6624 result = (c == curc); |
6676 | 6625 |
6677 if (!result && rex.reg_ic) | 6626 if (!result && rex.reg_ic) |
6678 result = MB_TOLOWER(c) == MB_TOLOWER(curc); | 6627 result = MB_TOLOWER(c) == MB_TOLOWER(curc); |
6679 #ifdef FEAT_MBYTE | |
6680 /* If rex.reg_icombine is not set only skip over the character | 6628 /* If rex.reg_icombine is not set only skip over the character |
6681 * itself. When it is set skip over composing characters. */ | 6629 * itself. When it is set skip over composing characters. */ |
6682 if (result && enc_utf8 && !rex.reg_icombine) | 6630 if (result && enc_utf8 && !rex.reg_icombine) |
6683 clen = utf_ptr2len(rex.input); | 6631 clen = utf_ptr2len(rex.input); |
6684 #endif | |
6685 ADD_STATE_IF_MATCH(t->state); | 6632 ADD_STATE_IF_MATCH(t->state); |
6686 break; | 6633 break; |
6687 } | 6634 } |
6688 | 6635 |
6689 } /* switch (t->state->c) */ | 6636 } /* switch (t->state->c) */ |
7102 if (prog->regflags & RF_ICASE) | 7049 if (prog->regflags & RF_ICASE) |
7103 rex.reg_ic = TRUE; | 7050 rex.reg_ic = TRUE; |
7104 else if (prog->regflags & RF_NOICASE) | 7051 else if (prog->regflags & RF_NOICASE) |
7105 rex.reg_ic = FALSE; | 7052 rex.reg_ic = FALSE; |
7106 | 7053 |
7107 #ifdef FEAT_MBYTE | |
7108 /* If pattern contains "\Z" overrule value of rex.reg_icombine */ | 7054 /* If pattern contains "\Z" overrule value of rex.reg_icombine */ |
7109 if (prog->regflags & RF_ICOMBINE) | 7055 if (prog->regflags & RF_ICOMBINE) |
7110 rex.reg_icombine = TRUE; | 7056 rex.reg_icombine = TRUE; |
7111 #endif | |
7112 | 7057 |
7113 rex.line = line; | 7058 rex.line = line; |
7114 rex.lnum = 0; /* relative to line */ | 7059 rex.lnum = 0; /* relative to line */ |
7115 | 7060 |
7116 rex.nfa_has_zend = prog->has_zend; | 7061 rex.nfa_has_zend = prog->has_zend; |
7147 if (skip_to_start(prog->regstart, &col) == FAIL) | 7092 if (skip_to_start(prog->regstart, &col) == FAIL) |
7148 return 0L; | 7093 return 0L; |
7149 | 7094 |
7150 /* If match_text is set it contains the full text that must match. | 7095 /* If match_text is set it contains the full text that must match. |
7151 * Nothing else to try. Doesn't handle combining chars well. */ | 7096 * Nothing else to try. Doesn't handle combining chars well. */ |
7152 if (prog->match_text != NULL | 7097 if (prog->match_text != NULL && !rex.reg_icombine) |
7153 #ifdef FEAT_MBYTE | |
7154 && !rex.reg_icombine | |
7155 #endif | |
7156 ) | |
7157 return find_match_text(col, prog->regstart, prog->match_text); | 7098 return find_match_text(col, prog->regstart, prog->match_text); |
7158 } | 7099 } |
7159 | 7100 |
7160 /* If the start column is past the maximum column: no need to try. */ | 7101 /* If the start column is past the maximum column: no need to try. */ |
7161 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) | 7102 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) |
7332 rex.reg_maxline = 0; | 7273 rex.reg_maxline = 0; |
7333 rex.reg_line_lbr = line_lbr; | 7274 rex.reg_line_lbr = line_lbr; |
7334 rex.reg_buf = curbuf; | 7275 rex.reg_buf = curbuf; |
7335 rex.reg_win = NULL; | 7276 rex.reg_win = NULL; |
7336 rex.reg_ic = rmp->rm_ic; | 7277 rex.reg_ic = rmp->rm_ic; |
7337 #ifdef FEAT_MBYTE | |
7338 rex.reg_icombine = FALSE; | 7278 rex.reg_icombine = FALSE; |
7339 #endif | |
7340 rex.reg_maxcol = 0; | 7279 rex.reg_maxcol = 0; |
7341 return nfa_regexec_both(line, col, NULL, NULL); | 7280 return nfa_regexec_both(line, col, NULL, NULL); |
7342 } | 7281 } |
7343 | 7282 |
7344 | 7283 |
7383 rex.reg_win = win; | 7322 rex.reg_win = win; |
7384 rex.reg_firstlnum = lnum; | 7323 rex.reg_firstlnum = lnum; |
7385 rex.reg_maxline = rex.reg_buf->b_ml.ml_line_count - lnum; | 7324 rex.reg_maxline = rex.reg_buf->b_ml.ml_line_count - lnum; |
7386 rex.reg_line_lbr = FALSE; | 7325 rex.reg_line_lbr = FALSE; |
7387 rex.reg_ic = rmp->rmm_ic; | 7326 rex.reg_ic = rmp->rmm_ic; |
7388 #ifdef FEAT_MBYTE | |
7389 rex.reg_icombine = FALSE; | 7327 rex.reg_icombine = FALSE; |
7390 #endif | |
7391 rex.reg_maxcol = rmp->rmm_maxcol; | 7328 rex.reg_maxcol = rmp->rmm_maxcol; |
7392 | 7329 |
7393 return nfa_regexec_both(NULL, col, tm, timed_out); | 7330 return nfa_regexec_both(NULL, col, tm, timed_out); |
7394 } | 7331 } |
7395 | 7332 |