comparison src/regexp.c @ 31778:579c846086eb v9.0.1221

patch 9.0.1221: code is indented more than necessary Commit: https://github.com/vim/vim/commit/f97a295ccaa9803367f3714cdefce4e2283c771d Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jan 18 18:17:48 2023 +0000 patch 9.0.1221: code is indented more than necessary Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11833)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Jan 2023 19:30:03 +0100
parents 7fb4e244b16e
children f3987fde6dea
comparison
equal deleted inserted replaced
31777:84bb462086cf 31778:579c846086eb
708 static int 708 static int
709 peekchr(void) 709 peekchr(void)
710 { 710 {
711 static int after_slash = FALSE; 711 static int after_slash = FALSE;
712 712
713 if (curchr == -1) 713 if (curchr != -1)
714 { 714 return curchr;
715 switch (curchr = regparse[0]) 715
716 { 716 switch (curchr = regparse[0])
717 {
717 case '.': 718 case '.':
718 case '[': 719 case '[':
719 case '~': 720 case '~':
720 // magic when 'magic' is on 721 // magic when 'magic' is on
721 if (reg_magic >= MAGIC_ON) 722 if (reg_magic >= MAGIC_ON)
741 case '-': // future ext. 742 case '-': // future ext.
742 case ':': // future ext. 743 case ':': // future ext.
743 case ';': // future ext. 744 case ';': // future ext.
744 case '`': // future ext. 745 case '`': // future ext.
745 case '/': // Can't be used in / command 746 case '/': // Can't be used in / command
746 // magic only after "\v" 747 // magic only after "\v"
747 if (reg_magic == MAGIC_ALL) 748 if (reg_magic == MAGIC_ALL)
748 curchr = Magic(curchr); 749 curchr = Magic(curchr);
749 break; 750 break;
750 case '*': 751 case '*':
751 // * is not magic as the very first character, eg "?*ptr", when 752 // * is not magic as the very first character, eg "?*ptr", when
786 char_u *p = regparse + 1; 787 char_u *p = regparse + 1;
787 int is_magic_all = (reg_magic == MAGIC_ALL); 788 int is_magic_all = (reg_magic == MAGIC_ALL);
788 789
789 // ignore \c \C \m \M \v \V and \Z after '$' 790 // ignore \c \C \m \M \v \V and \Z after '$'
790 while (p[0] == '\\' && (p[1] == 'c' || p[1] == 'C' 791 while (p[0] == '\\' && (p[1] == 'c' || p[1] == 'C'
791 || p[1] == 'm' || p[1] == 'M' 792 || p[1] == 'm' || p[1] == 'M'
792 || p[1] == 'v' || p[1] == 'V' || p[1] == 'Z')) 793 || p[1] == 'v' || p[1] == 'V' || p[1] == 'Z'))
793 { 794 {
794 if (p[1] == 'v') 795 if (p[1] == 'v')
795 is_magic_all = TRUE; 796 is_magic_all = TRUE;
796 else if (p[1] == 'm' || p[1] == 'M' || p[1] == 'V') 797 else if (p[1] == 'm' || p[1] == 'M' || p[1] == 'V')
797 is_magic_all = FALSE; 798 is_magic_all = FALSE;
800 if (p[0] == NUL 801 if (p[0] == NUL
801 || (p[0] == '\\' 802 || (p[0] == '\\'
802 && (p[1] == '|' || p[1] == '&' || p[1] == ')' 803 && (p[1] == '|' || p[1] == '&' || p[1] == ')'
803 || p[1] == 'n')) 804 || p[1] == 'n'))
804 || (is_magic_all 805 || (is_magic_all
805 && (p[0] == '|' || p[0] == '&' || p[0] == ')')) 806 && (p[0] == '|' || p[0] == '&' || p[0] == ')'))
806 || reg_magic == MAGIC_ALL) 807 || reg_magic == MAGIC_ALL)
807 curchr = Magic('$'); 808 curchr = Magic('$');
808 } 809 }
809 break; 810 break;
810 case '\\': 811 case '\\':
856 } 857 }
857 858
858 default: 859 default:
859 if (has_mbyte) 860 if (has_mbyte)
860 curchr = (*mb_ptr2char)(regparse); 861 curchr = (*mb_ptr2char)(regparse);
861 }
862 } 862 }
863 863
864 return curchr; 864 return curchr;
865 } 865 }
866 866
1382 * used (to increase speed). 1382 * used (to increase speed).
1383 */ 1383 */
1384 static void 1384 static void
1385 cleanup_subexpr(void) 1385 cleanup_subexpr(void)
1386 { 1386 {
1387 if (rex.need_clear_subexpr) 1387 if (!rex.need_clear_subexpr)
1388 { 1388 return;
1389 if (REG_MULTI) 1389
1390 { 1390 if (REG_MULTI)
1391 // Use 0xff to set lnum to -1 1391 {
1392 vim_memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); 1392 // Use 0xff to set lnum to -1
1393 vim_memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); 1393 vim_memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP);
1394 } 1394 vim_memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP);
1395 else 1395 }
1396 { 1396 else
1397 vim_memset(rex.reg_startp, 0, sizeof(char_u *) * NSUBEXP); 1397 {
1398 vim_memset(rex.reg_endp, 0, sizeof(char_u *) * NSUBEXP); 1398 vim_memset(rex.reg_startp, 0, sizeof(char_u *) * NSUBEXP);
1399 } 1399 vim_memset(rex.reg_endp, 0, sizeof(char_u *) * NSUBEXP);
1400 rex.need_clear_subexpr = FALSE; 1400 }
1401 } 1401 rex.need_clear_subexpr = FALSE;
1402 } 1402 }
1403 1403
1404 #ifdef FEAT_SYN_HL 1404 #ifdef FEAT_SYN_HL
1405 static void 1405 static void
1406 cleanup_zsubexpr(void) 1406 cleanup_zsubexpr(void)
1407 { 1407 {
1408 if (rex.need_clear_zsubexpr) 1408 if (!rex.need_clear_zsubexpr)
1409 { 1409 return;
1410 if (REG_MULTI) 1410
1411 { 1411 if (REG_MULTI)
1412 // Use 0xff to set lnum to -1 1412 {
1413 vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP); 1413 // Use 0xff to set lnum to -1
1414 vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP); 1414 vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
1415 } 1415 vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
1416 else 1416 }
1417 { 1417 else
1418 vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP); 1418 {
1419 vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP); 1419 vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP);
1420 } 1420 vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP);
1421 rex.need_clear_zsubexpr = FALSE; 1421 }
1422 } 1422 rex.need_clear_zsubexpr = FALSE;
1423 } 1423 }
1424 #endif 1424 #endif
1425 1425
1426 /* 1426 /*
1427 * Advance rex.lnum, rex.line and rex.input to the next line. 1427 * Advance rex.lnum, rex.line and rex.input to the next line.