To: vim-dev@vim.org Subject: Patch 6.2.339 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.339 Problem: Crash when using many different highlight groups and a User highlight group. (Juergen Kraemer) Solution: Do not use the sg_name_u pointer when it is NULL. Also simplify use of the highlight group table. Files: src/syntax.c *** ../vim-6.2.338/src/syntax.c Sun Feb 1 20:02:19 2004 --- src/syntax.c Wed Mar 10 15:53:39 2004 *************** *** 7738,7747 **** set_hl_attr(idx) int idx; /* index in array */ { ! attrentry_T at_en; /* The "Normal" group doesn't need an attribute number */ ! if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) return; #ifdef FEAT_GUI --- 7738,7748 ---- set_hl_attr(idx) int idx; /* index in array */ { ! attrentry_T at_en; ! struct hl_group *sgp = HL_TABLE() + idx; /* The "Normal" group doesn't need an attribute number */ ! if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0) return; #ifdef FEAT_GUI *************** *** 7749,7803 **** * For the GUI mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (HL_TABLE()[idx].sg_gui_fg == INVALCOLOR ! && HL_TABLE()[idx].sg_gui_bg == INVALCOLOR ! && HL_TABLE()[idx].sg_font == NOFONT # ifdef FEAT_XFONTSET ! && HL_TABLE()[idx].sg_fontset == NOFONTSET # endif ) { ! HL_TABLE()[idx].sg_gui_attr = HL_TABLE()[idx].sg_gui; } else { ! at_en.ae_attr = HL_TABLE()[idx].sg_gui; ! at_en.ae_u.gui.fg_color = HL_TABLE()[idx].sg_gui_fg; ! at_en.ae_u.gui.bg_color = HL_TABLE()[idx].sg_gui_bg; ! at_en.ae_u.gui.font = HL_TABLE()[idx].sg_font; # ifdef FEAT_XFONTSET ! at_en.ae_u.gui.fontset = HL_TABLE()[idx].sg_fontset; # endif ! HL_TABLE()[idx].sg_gui_attr = get_attr_entry(&gui_attr_table, &at_en); } #endif /* * For the term mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (HL_TABLE()[idx].sg_start == NULL && HL_TABLE()[idx].sg_stop == NULL) ! HL_TABLE()[idx].sg_term_attr = HL_TABLE()[idx].sg_term; else { ! at_en.ae_attr = HL_TABLE()[idx].sg_term; ! at_en.ae_u.term.start = HL_TABLE()[idx].sg_start; ! at_en.ae_u.term.stop = HL_TABLE()[idx].sg_stop; ! HL_TABLE()[idx].sg_term_attr = get_attr_entry(&term_attr_table, &at_en); } /* * For the color term mode: If there are other than "normal" * highlighting attributes, need to allocate an attr number. */ ! if (HL_TABLE()[idx].sg_cterm_fg == 0 && HL_TABLE()[idx].sg_cterm_bg == 0) ! HL_TABLE()[idx].sg_cterm_attr = HL_TABLE()[idx].sg_cterm; else { ! at_en.ae_attr = HL_TABLE()[idx].sg_cterm; ! at_en.ae_u.cterm.fg_color = HL_TABLE()[idx].sg_cterm_fg; ! at_en.ae_u.cterm.bg_color = HL_TABLE()[idx].sg_cterm_bg; ! HL_TABLE()[idx].sg_cterm_attr = ! get_attr_entry(&cterm_attr_table, &at_en); } } --- 7750,7803 ---- * For the GUI mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (sgp->sg_gui_fg == INVALCOLOR ! && sgp->sg_gui_bg == INVALCOLOR ! && sgp->sg_font == NOFONT # ifdef FEAT_XFONTSET ! && sgp->sg_fontset == NOFONTSET # endif ) { ! sgp->sg_gui_attr = sgp->sg_gui; } else { ! at_en.ae_attr = sgp->sg_gui; ! at_en.ae_u.gui.fg_color = sgp->sg_gui_fg; ! at_en.ae_u.gui.bg_color = sgp->sg_gui_bg; ! at_en.ae_u.gui.font = sgp->sg_font; # ifdef FEAT_XFONTSET ! at_en.ae_u.gui.fontset = sgp->sg_fontset; # endif ! sgp->sg_gui_attr = get_attr_entry(&gui_attr_table, &at_en); } #endif /* * For the term mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (sgp->sg_start == NULL && sgp->sg_stop == NULL) ! sgp->sg_term_attr = sgp->sg_term; else { ! at_en.ae_attr = sgp->sg_term; ! at_en.ae_u.term.start = sgp->sg_start; ! at_en.ae_u.term.stop = sgp->sg_stop; ! sgp->sg_term_attr = get_attr_entry(&term_attr_table, &at_en); } /* * For the color term mode: If there are other than "normal" * highlighting attributes, need to allocate an attr number. */ ! if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0) ! sgp->sg_cterm_attr = sgp->sg_cterm; else { ! at_en.ae_attr = sgp->sg_cterm; ! at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; ! at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; ! sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); } } *** ../vim-6.2.338/src/version.c Tue Mar 9 19:49:08 2004 --- src/version.c Wed Mar 10 16:21:38 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 339, /**/ -- Engineers are always delighted to share wisdom, even in areas in which they have no experience whatsoever. Their logic provides them with inherent insight into any field of expertise. This can be a problem when dealing with the illogical people who believe that knowledge can only be derived through experience. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///