comparison src/regexp_bt.c @ 23150:90b16a0022e5 v8.2.2121

patch 8.2.2121: internal error when using ze before zs in a pattern Commit: https://github.com/vim/vim/commit/a7a691cc142439e266f4ceb1f208bb952b57aa71 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 9 16:36:04 2020 +0100 patch 8.2.2121: internal error when using \ze before \zs in a pattern Problem: Internal error when using \ze before \zs in a pattern. Solution: Check the end is never before the start. (closes https://github.com/vim/vim/issues/7442)
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Dec 2020 16:45:04 +0100
parents 740b16b3c80b
children 22d0c25869d8
comparison
equal deleted inserted replaced
23149:e427a5961456 23150:90b16a0022e5
4803 if (regstack.ga_maxlen > REGSTACK_INITIAL) 4803 if (regstack.ga_maxlen > REGSTACK_INITIAL)
4804 ga_clear(&regstack); 4804 ga_clear(&regstack);
4805 if (backpos.ga_maxlen > BACKPOS_INITIAL) 4805 if (backpos.ga_maxlen > BACKPOS_INITIAL)
4806 ga_clear(&backpos); 4806 ga_clear(&backpos);
4807 4807
4808 // Make sure the end is never before the start. Can happen when \zs and
4809 // \ze are used.
4810 if (REG_MULTI)
4811 {
4812 lpos_T *start = &rex.reg_mmatch->startpos[0];
4813 lpos_T *end = &rex.reg_mmatch->endpos[0];
4814
4815 if (end->lnum < start->lnum
4816 || (end->lnum == start->lnum && end->col < start->col))
4817 rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
4818 }
4819 else
4820 {
4821 if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
4822 rex.reg_match->endp[0] = rex.reg_match->startp[0];
4823 }
4824
4808 return retval; 4825 return retval;
4809 } 4826 }
4810 4827
4811 /* 4828 /*
4812 * Match a regexp against a string. 4829 * Match a regexp against a string.