comparison src/regexp_nfa.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 c3cc8b2aab6a
children f4ea50924c6d
comparison
equal deleted inserted replaced
11126:48599a3eae0b 11127:506f5d8b7d8b
1423 if (reg_prev_sub == NULL) 1423 if (reg_prev_sub == NULL)
1424 { 1424 {
1425 EMSG(_(e_nopresub)); 1425 EMSG(_(e_nopresub));
1426 return FAIL; 1426 return FAIL;
1427 } 1427 }
1428 for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) 1428 for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp))
1429 { 1429 {
1430 EMIT(PTR2CHAR(lp)); 1430 EMIT(PTR2CHAR(lp));
1431 if (lp != reg_prev_sub) 1431 if (lp != reg_prev_sub)
1432 EMIT(NFA_CONCAT); 1432 EMIT(NFA_CONCAT);
1433 } 1433 }
1670 EMIT(NFA_OR); 1670 EMIT(NFA_OR);
1671 } 1671 }
1672 else 1672 else
1673 EMIT(result); 1673 EMIT(result);
1674 regparse = endp; 1674 regparse = endp;
1675 mb_ptr_adv(regparse); 1675 MB_PTR_ADV(regparse);
1676 return OK; 1676 return OK;
1677 } 1677 }
1678 /* 1678 /*
1679 * Failed to recognize a character class. Use the simple 1679 * Failed to recognize a character class. Use the simple
1680 * version that turns [abc] into 'a' OR 'b' OR 'c' 1680 * version that turns [abc] into 'a' OR 'b' OR 'c'
1682 startc = endc = oldstartc = -1; 1682 startc = endc = oldstartc = -1;
1683 negated = FALSE; 1683 negated = FALSE;
1684 if (*regparse == '^') /* negated range */ 1684 if (*regparse == '^') /* negated range */
1685 { 1685 {
1686 negated = TRUE; 1686 negated = TRUE;
1687 mb_ptr_adv(regparse); 1687 MB_PTR_ADV(regparse);
1688 EMIT(NFA_START_NEG_COLL); 1688 EMIT(NFA_START_NEG_COLL);
1689 } 1689 }
1690 else 1690 else
1691 EMIT(NFA_START_COLL); 1691 EMIT(NFA_START_COLL);
1692 if (*regparse == '-') 1692 if (*regparse == '-')
1693 { 1693 {
1694 startc = '-'; 1694 startc = '-';
1695 EMIT(startc); 1695 EMIT(startc);
1696 EMIT(NFA_CONCAT); 1696 EMIT(NFA_CONCAT);
1697 mb_ptr_adv(regparse); 1697 MB_PTR_ADV(regparse);
1698 } 1698 }
1699 /* Emit the OR branches for each character in the [] */ 1699 /* Emit the OR branches for each character in the [] */
1700 emit_range = FALSE; 1700 emit_range = FALSE;
1701 while (regparse < endp) 1701 while (regparse < endp)
1702 { 1702 {
1795 * start character. */ 1795 * start character. */
1796 if (*regparse == '-' && oldstartc != -1) 1796 if (*regparse == '-' && oldstartc != -1)
1797 { 1797 {
1798 emit_range = TRUE; 1798 emit_range = TRUE;
1799 startc = oldstartc; 1799 startc = oldstartc;
1800 mb_ptr_adv(regparse); 1800 MB_PTR_ADV(regparse);
1801 continue; /* reading the end of the range */ 1801 continue; /* reading the end of the range */
1802 } 1802 }
1803 1803
1804 /* Now handle simple and escaped characters. 1804 /* Now handle simple and escaped characters.
1805 * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim 1805 * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
1815 && vim_strchr(REGEXP_ABBR, regparse[1]) 1815 && vim_strchr(REGEXP_ABBR, regparse[1])
1816 != NULL) 1816 != NULL)
1817 ) 1817 )
1818 ) 1818 )
1819 { 1819 {
1820 mb_ptr_adv(regparse); 1820 MB_PTR_ADV(regparse);
1821 1821
1822 if (*regparse == 'n') 1822 if (*regparse == 'n')
1823 startc = reg_string ? NL : NFA_NEWL; 1823 startc = reg_string ? NL : NFA_NEWL;
1824 else 1824 else
1825 if (*regparse == 'd' 1825 if (*regparse == 'd'
1830 ) 1830 )
1831 { 1831 {
1832 /* TODO(RE) This needs more testing */ 1832 /* TODO(RE) This needs more testing */
1833 startc = coll_get_char(); 1833 startc = coll_get_char();
1834 got_coll_char = TRUE; 1834 got_coll_char = TRUE;
1835 mb_ptr_back(old_regparse, regparse); 1835 MB_PTR_BACK(old_regparse, regparse);
1836 } 1836 }
1837 else 1837 else
1838 { 1838 {
1839 /* \r,\t,\e,\b */ 1839 /* \r,\t,\e,\b */
1840 startc = backslash_trans(*regparse); 1840 startc = backslash_trans(*regparse);
1930 EMIT(startc); 1930 EMIT(startc);
1931 EMIT(NFA_CONCAT); 1931 EMIT(NFA_CONCAT);
1932 } 1932 }
1933 } 1933 }
1934 1934
1935 mb_ptr_adv(regparse); 1935 MB_PTR_ADV(regparse);
1936 } /* while (p < endp) */ 1936 } /* while (p < endp) */
1937 1937
1938 mb_ptr_back(old_regparse, regparse); 1938 MB_PTR_BACK(old_regparse, regparse);
1939 if (*regparse == '-') /* if last, '-' is just a char */ 1939 if (*regparse == '-') /* if last, '-' is just a char */
1940 { 1940 {
1941 EMIT('-'); 1941 EMIT('-');
1942 EMIT(NFA_CONCAT); 1942 EMIT(NFA_CONCAT);
1943 } 1943 }
1944 1944
1945 /* skip the trailing ] */ 1945 /* skip the trailing ] */
1946 regparse = endp; 1946 regparse = endp;
1947 mb_ptr_adv(regparse); 1947 MB_PTR_ADV(regparse);
1948 1948
1949 /* Mark end of the collection. */ 1949 /* Mark end of the collection. */
1950 if (negated == TRUE) 1950 if (negated == TRUE)
1951 EMIT(NFA_END_NEG_COLL); 1951 EMIT(NFA_END_NEG_COLL);
1952 else 1952 else