comparison src/regexp.c @ 11127:506f5d8b7d8b v8.0.0451

patch 8.0.0451: some macros are in lower case commit https://github.com/vim/vim/commit/91acfffc1e6c0d8c2abfb186a0e79a5bf19c3f3f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 12 19:22:36 2017 +0100 patch 8.0.0451: some macros are in lower case Problem: Some macros are in lower case. Solution: Make a few more macros upper case. Avoid lower case macros use an argument twice.
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Mar 2017 19:30:05 +0100
parents 778c10516955
children f4ea50924c6d
comparison
equal deleted inserted replaced
11126:48599a3eae0b 11127:506f5d8b7d8b
1203 #endif 1203 #endif
1204 if (*p == '-') 1204 if (*p == '-')
1205 { 1205 {
1206 ++p; 1206 ++p;
1207 if (*p != ']' && *p != NUL) 1207 if (*p != ']' && *p != NUL)
1208 mb_ptr_adv(p); 1208 MB_PTR_ADV(p);
1209 } 1209 }
1210 else if (*p == '\\' 1210 else if (*p == '\\'
1211 && !reg_cpo_bsl 1211 && !reg_cpo_bsl
1212 && (vim_strchr(REGEXP_INRANGE, p[1]) != NULL 1212 && (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
1213 || (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL))) 1213 || (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
1250 mymagic = MAGIC_ON; 1250 mymagic = MAGIC_ON;
1251 else 1251 else
1252 mymagic = MAGIC_OFF; 1252 mymagic = MAGIC_OFF;
1253 get_cpo_flags(); 1253 get_cpo_flags();
1254 1254
1255 for (; p[0] != NUL; mb_ptr_adv(p)) 1255 for (; p[0] != NUL; MB_PTR_ADV(p))
1256 { 1256 {
1257 if (p[0] == dirc) /* found end of regexp */ 1257 if (p[0] == dirc) /* found end of regexp */
1258 break; 1258 break;
1259 if ((p[0] == '[' && mymagic >= MAGIC_ON) 1259 if ((p[0] == '[' && mymagic >= MAGIC_ON)
1260 || (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) 1260 || (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF))
3862 else if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1)) 3862 else if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1))
3863 while ((s = vim_strchr(s, c)) != NULL) 3863 while ((s = vim_strchr(s, c)) != NULL)
3864 { 3864 {
3865 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) 3865 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
3866 break; /* Found it. */ 3866 break; /* Found it. */
3867 mb_ptr_adv(s); 3867 MB_PTR_ADV(s);
3868 } 3868 }
3869 #endif 3869 #endif
3870 else 3870 else
3871 while ((s = cstrchr(s, c)) != NULL) 3871 while ((s = cstrchr(s, c)) != NULL)
3872 { 3872 {
3873 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) 3873 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
3874 break; /* Found it. */ 3874 break; /* Found it. */
3875 mb_ptr_adv(s); 3875 MB_PTR_ADV(s);
3876 } 3876 }
3877 if (s == NULL) /* Not present. */ 3877 if (s == NULL) /* Not present. */
3878 goto theend; 3878 goto theend;
3879 } 3879 }
3880 3880
4202 return FALSE; 4202 return FALSE;
4203 } 4203 }
4204 return TRUE; 4204 return TRUE;
4205 } 4205 }
4206 4206
4207 #define ADVANCE_REGINPUT() mb_ptr_adv(reginput) 4207 #define ADVANCE_REGINPUT() MB_PTR_ADV(reginput)
4208 4208
4209 /* 4209 /*
4210 * The arguments from BRACE_LIMITS are stored here. They are actually local 4210 * The arguments from BRACE_LIMITS are stored here. They are actually local
4211 * to regmatch(), but they are here to reduce the amount of stack space used 4211 * to regmatch(), but they are here to reduce the amount of stack space used
4212 * (it can be called recursively many times). 4212 * (it can be called recursively many times).
4773 #ifdef FEAT_MBYTE 4773 #ifdef FEAT_MBYTE
4774 if (enc_utf8) 4774 if (enc_utf8)
4775 { 4775 {
4776 /* Skip composing characters. */ 4776 /* Skip composing characters. */
4777 while (utf_iscomposing(utf_ptr2char(reginput))) 4777 while (utf_iscomposing(utf_ptr2char(reginput)))
4778 mb_cptr_adv(reginput); 4778 MB_CPTR_ADV(reginput);
4779 } 4779 }
4780 #endif 4780 #endif
4781 break; 4781 break;
4782 4782
4783 case NOTHING: 4783 case NOTHING:
5555 { 5555 {
5556 if (rp->rs_un.regsave.rs_u.ptr == regline) 5556 if (rp->rs_un.regsave.rs_u.ptr == regline)
5557 no = FAIL; 5557 no = FAIL;
5558 else 5558 else
5559 { 5559 {
5560 mb_ptr_back(regline, rp->rs_un.regsave.rs_u.ptr); 5560 MB_PTR_BACK(regline, rp->rs_un.regsave.rs_u.ptr);
5561 if (limit > 0 && (long)(behind_pos.rs_u.ptr 5561 if (limit > 0 && (long)(behind_pos.rs_u.ptr
5562 - rp->rs_un.regsave.rs_u.ptr) > limit) 5562 - rp->rs_un.regsave.rs_u.ptr) > limit)
5563 no = FAIL; 5563 no = FAIL;
5564 } 5564 }
5565 } 5565 }
5642 break; 5642 break;
5643 reginput = regline + STRLEN(regline); 5643 reginput = regline + STRLEN(regline);
5644 fast_breakcheck(); 5644 fast_breakcheck();
5645 } 5645 }
5646 else 5646 else
5647 mb_ptr_back(regline, reginput); 5647 MB_PTR_BACK(regline, reginput);
5648 } 5648 }
5649 else 5649 else
5650 { 5650 {
5651 /* Range is backwards, use shortest match first. 5651 /* Range is backwards, use shortest match first.
5652 * Careful: maxval and minval are exchanged! 5652 * Careful: maxval and minval are exchanged!
5786 /* Matching anything means we continue until end-of-line (or 5786 /* Matching anything means we continue until end-of-line (or
5787 * end-of-file for ANY + ADD_NL), only limited by maxcount. */ 5787 * end-of-file for ANY + ADD_NL), only limited by maxcount. */
5788 while (*scan != NUL && count < maxcount) 5788 while (*scan != NUL && count < maxcount)
5789 { 5789 {
5790 ++count; 5790 ++count;
5791 mb_ptr_adv(scan); 5791 MB_PTR_ADV(scan);
5792 } 5792 }
5793 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline 5793 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
5794 || rex.reg_line_lbr || count == maxcount) 5794 || rex.reg_line_lbr || count == maxcount)
5795 break; 5795 break;
5796 ++count; /* count the line-break */ 5796 ++count; /* count the line-break */
5809 case SIDENT + ADD_NL: 5809 case SIDENT + ADD_NL:
5810 while (count < maxcount) 5810 while (count < maxcount)
5811 { 5811 {
5812 if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) 5812 if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))
5813 { 5813 {
5814 mb_ptr_adv(scan); 5814 MB_PTR_ADV(scan);
5815 } 5815 }
5816 else if (*scan == NUL) 5816 else if (*scan == NUL)
5817 { 5817 {
5818 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline 5818 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
5819 || rex.reg_line_lbr) 5819 || rex.reg_line_lbr)
5840 while (count < maxcount) 5840 while (count < maxcount)
5841 { 5841 {
5842 if (vim_iswordp_buf(scan, rex.reg_buf) 5842 if (vim_iswordp_buf(scan, rex.reg_buf)
5843 && (testval || !VIM_ISDIGIT(*scan))) 5843 && (testval || !VIM_ISDIGIT(*scan)))
5844 { 5844 {
5845 mb_ptr_adv(scan); 5845 MB_PTR_ADV(scan);
5846 } 5846 }
5847 else if (*scan == NUL) 5847 else if (*scan == NUL)
5848 { 5848 {
5849 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline 5849 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
5850 || rex.reg_line_lbr) 5850 || rex.reg_line_lbr)
5870 case SFNAME + ADD_NL: 5870 case SFNAME + ADD_NL:
5871 while (count < maxcount) 5871 while (count < maxcount)
5872 { 5872 {
5873 if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) 5873 if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))
5874 { 5874 {
5875 mb_ptr_adv(scan); 5875 MB_PTR_ADV(scan);
5876 } 5876 }
5877 else if (*scan == NUL) 5877 else if (*scan == NUL)
5878 { 5878 {
5879 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline 5879 if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
5880 || rex.reg_line_lbr) 5880 || rex.reg_line_lbr)
5911 break; 5911 break;
5912 } 5912 }
5913 else if (vim_isprintc(PTR2CHAR(scan)) == 1 5913 else if (vim_isprintc(PTR2CHAR(scan)) == 1
5914 && (testval || !VIM_ISDIGIT(*scan))) 5914 && (testval || !VIM_ISDIGIT(*scan)))
5915 { 5915 {
5916 mb_ptr_adv(scan); 5916 MB_PTR_ADV(scan);
5917 } 5917 }
5918 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) 5918 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
5919 ++scan; 5919 ++scan;
5920 else 5920 else
5921 break; 5921 break;
7544 7544
7545 if (eval_result != NULL) 7545 if (eval_result != NULL)
7546 { 7546 {
7547 int had_backslash = FALSE; 7547 int had_backslash = FALSE;
7548 7548
7549 for (s = eval_result; *s != NUL; mb_ptr_adv(s)) 7549 for (s = eval_result; *s != NUL; MB_PTR_ADV(s))
7550 { 7550 {
7551 /* Change NL to CR, so that it becomes a line break, 7551 /* Change NL to CR, so that it becomes a line break,
7552 * unless called from vim_regexec_nl(). 7552 * unless called from vim_regexec_nl().
7553 * Skip over a backslashed character. */ 7553 * Skip over a backslashed character. */
7554 if (*s == NL && !rsm.sm_line_lbr) 7554 if (*s == NL && !rsm.sm_line_lbr)