Mercurial > vim
comparison src/regexp.c @ 6375:27a36d1013a6 v7.4.519
updated for version 7.4.519
Problem: Crash when using syntax highlighting.
Solution: When regprog is freed and replaced, store the result.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 19 Nov 2014 16:38:07 +0100 |
parents | adfbffe1e642 |
children | 230b52b9d35e |
comparison
equal
deleted
inserted
replaced
6374:d98edc1ee7be | 6375:27a36d1013a6 |
---|---|
8161 static int vim_regexec_both __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int nl)); | 8161 static int vim_regexec_both __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int nl)); |
8162 | 8162 |
8163 /* | 8163 /* |
8164 * Match a regexp against a string. | 8164 * Match a regexp against a string. |
8165 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). | 8165 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). |
8166 * Note: "rmp->regprog" may be freed and changed. | |
8166 * Uses curbuf for line count and 'iskeyword'. | 8167 * Uses curbuf for line count and 'iskeyword'. |
8167 * When "nl" is TRUE consider a "\n" in "line" to be a line break. | 8168 * When "nl" is TRUE consider a "\n" in "line" to be a line break. |
8168 * | 8169 * |
8169 * Return TRUE if there is a match, FALSE if not. | 8170 * Return TRUE if there is a match, FALSE if not. |
8170 */ | 8171 */ |
8201 p_re = save_p_re; | 8202 p_re = save_p_re; |
8202 } | 8203 } |
8203 return result; | 8204 return result; |
8204 } | 8205 } |
8205 | 8206 |
8207 /* | |
8208 * Note: "*prog" may be freed and changed. | |
8209 */ | |
8210 int | |
8211 vim_regexec_prog(prog, ignore_case, line, col) | |
8212 regprog_T **prog; | |
8213 int ignore_case; | |
8214 char_u *line; | |
8215 colnr_T col; | |
8216 { | |
8217 int r; | |
8218 regmatch_T regmatch; | |
8219 | |
8220 regmatch.regprog = *prog; | |
8221 regmatch.rm_ic = ignore_case; | |
8222 r = vim_regexec_both(®match, line, col, FALSE); | |
8223 *prog = regmatch.regprog; | |
8224 return r; | |
8225 } | |
8226 | |
8227 /* | |
8228 * Note: "rmp->regprog" may be freed and changed. | |
8229 */ | |
8206 int | 8230 int |
8207 vim_regexec(rmp, line, col) | 8231 vim_regexec(rmp, line, col) |
8208 regmatch_T *rmp; | 8232 regmatch_T *rmp; |
8209 char_u *line; | 8233 char_u *line; |
8210 colnr_T col; | 8234 colnr_T col; |
8214 | 8238 |
8215 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \ | 8239 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \ |
8216 || defined(FIND_REPLACE_DIALOG) || defined(PROTO) | 8240 || defined(FIND_REPLACE_DIALOG) || defined(PROTO) |
8217 /* | 8241 /* |
8218 * Like vim_regexec(), but consider a "\n" in "line" to be a line break. | 8242 * Like vim_regexec(), but consider a "\n" in "line" to be a line break. |
8243 * Note: "rmp->regprog" may be freed and changed. | |
8219 */ | 8244 */ |
8220 int | 8245 int |
8221 vim_regexec_nl(rmp, line, col) | 8246 vim_regexec_nl(rmp, line, col) |
8222 regmatch_T *rmp; | 8247 regmatch_T *rmp; |
8223 char_u *line; | 8248 char_u *line; |
8228 #endif | 8253 #endif |
8229 | 8254 |
8230 /* | 8255 /* |
8231 * Match a regexp against multiple lines. | 8256 * Match a regexp against multiple lines. |
8232 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). | 8257 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). |
8258 * Note: "rmp->regprog" may be freed and changed. | |
8233 * Uses curbuf for line count and 'iskeyword'. | 8259 * Uses curbuf for line count and 'iskeyword'. |
8234 * | 8260 * |
8235 * Return zero if there is no match. Return number of lines contained in the | 8261 * Return zero if there is no match. Return number of lines contained in the |
8236 * match otherwise. | 8262 * match otherwise. |
8237 */ | 8263 */ |