comparison src/regexp_nfa.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 8caba5736a9a
comparison
equal deleted inserted replaced
23149:e427a5961456 23150:90b16a0022e5
7223 #ifdef DEBUG 7223 #ifdef DEBUG
7224 nfa_regengine.expr = NULL; 7224 nfa_regengine.expr = NULL;
7225 #endif 7225 #endif
7226 7226
7227 theend: 7227 theend:
7228 // Make sure the end is never before the start. Can happen when \zs and
7229 // \ze are used.
7230 if (REG_MULTI)
7231 {
7232 lpos_T *start = &rex.reg_mmatch->startpos[0];
7233 lpos_T *end = &rex.reg_mmatch->endpos[0];
7234
7235 if (end->lnum < start->lnum
7236 || (end->lnum == start->lnum && end->col < start->col))
7237 rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
7238 }
7239 else
7240 {
7241 if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
7242 rex.reg_match->endp[0] = rex.reg_match->startp[0];
7243 }
7244
7228 return retval; 7245 return retval;
7229 } 7246 }
7230 7247
7231 /* 7248 /*
7232 * Compile a regular expression into internal code for the NFA matcher. 7249 * Compile a regular expression into internal code for the NFA matcher.