Mercurial > vim
comparison src/syntax.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 | 5c47dacf397c |
children | 762ab69c2d13 |
comparison
equal
deleted
inserted
replaced
6374:d98edc1ee7be | 6375:27a36d1013a6 |
---|---|
990 static int | 990 static int |
991 syn_match_linecont(lnum) | 991 syn_match_linecont(lnum) |
992 linenr_T lnum; | 992 linenr_T lnum; |
993 { | 993 { |
994 regmmatch_T regmatch; | 994 regmmatch_T regmatch; |
995 int r; | |
995 | 996 |
996 if (syn_block->b_syn_linecont_prog != NULL) | 997 if (syn_block->b_syn_linecont_prog != NULL) |
997 { | 998 { |
998 regmatch.rmm_ic = syn_block->b_syn_linecont_ic; | 999 regmatch.rmm_ic = syn_block->b_syn_linecont_ic; |
999 regmatch.regprog = syn_block->b_syn_linecont_prog; | 1000 regmatch.regprog = syn_block->b_syn_linecont_prog; |
1000 return syn_regexec(®match, lnum, (colnr_T)0, | 1001 r = syn_regexec(®match, lnum, (colnr_T)0, |
1001 IF_SYN_TIME(&syn_block->b_syn_linecont_time)); | 1002 IF_SYN_TIME(&syn_block->b_syn_linecont_time)); |
1003 syn_block->b_syn_linecont_prog = regmatch.regprog; | |
1004 return r; | |
1002 } | 1005 } |
1003 return FALSE; | 1006 return FALSE; |
1004 } | 1007 } |
1005 | 1008 |
1006 /* | 1009 /* |
2073 ? !(spp->sp_flags & HL_CONTAINED) | 2076 ? !(spp->sp_flags & HL_CONTAINED) |
2074 : in_id_list(cur_si, | 2077 : in_id_list(cur_si, |
2075 cur_si->si_cont_list, &spp->sp_syn, | 2078 cur_si->si_cont_list, &spp->sp_syn, |
2076 spp->sp_flags & HL_CONTAINED)))) | 2079 spp->sp_flags & HL_CONTAINED)))) |
2077 { | 2080 { |
2081 int r; | |
2082 | |
2078 /* If we already tried matching in this line, and | 2083 /* If we already tried matching in this line, and |
2079 * there isn't a match before next_match_col, skip | 2084 * there isn't a match before next_match_col, skip |
2080 * this item. */ | 2085 * this item. */ |
2081 if (spp->sp_line_id == current_line_id | 2086 if (spp->sp_line_id == current_line_id |
2082 && spp->sp_startcol >= next_match_col) | 2087 && spp->sp_startcol >= next_match_col) |
2087 if (lc_col < 0) | 2092 if (lc_col < 0) |
2088 lc_col = 0; | 2093 lc_col = 0; |
2089 | 2094 |
2090 regmatch.rmm_ic = spp->sp_ic; | 2095 regmatch.rmm_ic = spp->sp_ic; |
2091 regmatch.regprog = spp->sp_prog; | 2096 regmatch.regprog = spp->sp_prog; |
2092 if (!syn_regexec(®match, | 2097 r = syn_regexec(®match, |
2093 current_lnum, | 2098 current_lnum, |
2094 (colnr_T)lc_col, | 2099 (colnr_T)lc_col, |
2095 IF_SYN_TIME(&spp->sp_time))) | 2100 IF_SYN_TIME(&spp->sp_time)); |
2101 spp->sp_prog = regmatch.regprog; | |
2102 if (!r) | |
2096 { | 2103 { |
2097 /* no match in this line, try another one */ | 2104 /* no match in this line, try another one */ |
2098 spp->sp_startcol = MAXCOL; | 2105 spp->sp_startcol = MAXCOL; |
2099 continue; | 2106 continue; |
2100 } | 2107 } |
2961 */ | 2968 */ |
2962 best_idx = -1; | 2969 best_idx = -1; |
2963 for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx) | 2970 for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx) |
2964 { | 2971 { |
2965 int lc_col = matchcol; | 2972 int lc_col = matchcol; |
2973 int r; | |
2966 | 2974 |
2967 spp = &(SYN_ITEMS(syn_block)[idx]); | 2975 spp = &(SYN_ITEMS(syn_block)[idx]); |
2968 if (spp->sp_type != SPTYPE_END) /* past last END pattern */ | 2976 if (spp->sp_type != SPTYPE_END) /* past last END pattern */ |
2969 break; | 2977 break; |
2970 lc_col -= spp->sp_offsets[SPO_LC_OFF]; | 2978 lc_col -= spp->sp_offsets[SPO_LC_OFF]; |
2971 if (lc_col < 0) | 2979 if (lc_col < 0) |
2972 lc_col = 0; | 2980 lc_col = 0; |
2973 | 2981 |
2974 regmatch.rmm_ic = spp->sp_ic; | 2982 regmatch.rmm_ic = spp->sp_ic; |
2975 regmatch.regprog = spp->sp_prog; | 2983 regmatch.regprog = spp->sp_prog; |
2976 if (syn_regexec(®match, startpos->lnum, lc_col, | 2984 r = syn_regexec(®match, startpos->lnum, lc_col, |
2977 IF_SYN_TIME(&spp->sp_time))) | 2985 IF_SYN_TIME(&spp->sp_time)); |
2986 spp->sp_prog = regmatch.regprog; | |
2987 if (r) | |
2978 { | 2988 { |
2979 if (best_idx == -1 || regmatch.startpos[0].col | 2989 if (best_idx == -1 || regmatch.startpos[0].col |
2980 < best_regmatch.startpos[0].col) | 2990 < best_regmatch.startpos[0].col) |
2981 { | 2991 { |
2982 best_idx = idx; | 2992 best_idx = idx; |
2998 * continue searching after the skip pattern. | 3008 * continue searching after the skip pattern. |
2999 */ | 3009 */ |
3000 if (spp_skip != NULL) | 3010 if (spp_skip != NULL) |
3001 { | 3011 { |
3002 int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF]; | 3012 int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF]; |
3013 int r; | |
3003 | 3014 |
3004 if (lc_col < 0) | 3015 if (lc_col < 0) |
3005 lc_col = 0; | 3016 lc_col = 0; |
3006 regmatch.rmm_ic = spp_skip->sp_ic; | 3017 regmatch.rmm_ic = spp_skip->sp_ic; |
3007 regmatch.regprog = spp_skip->sp_prog; | 3018 regmatch.regprog = spp_skip->sp_prog; |
3008 if (syn_regexec(®match, startpos->lnum, lc_col, | 3019 r = syn_regexec(®match, startpos->lnum, lc_col, |
3009 IF_SYN_TIME(&spp_skip->sp_time)) | 3020 IF_SYN_TIME(&spp_skip->sp_time)); |
3010 && regmatch.startpos[0].col | 3021 spp_skip->sp_prog = regmatch.regprog; |
3022 if (r && regmatch.startpos[0].col | |
3011 <= best_regmatch.startpos[0].col) | 3023 <= best_regmatch.startpos[0].col) |
3012 { | 3024 { |
3013 /* Add offset to skip pattern match */ | 3025 /* Add offset to skip pattern match */ |
3014 syn_add_end_off(&pos, ®match, spp_skip, SPO_ME_OFF, 1); | 3026 syn_add_end_off(&pos, ®match, spp_skip, SPO_ME_OFF, 1); |
3015 | 3027 |