diff --git a/edit/syntax.c b/edit/syntax.c index 3e9325969..6b2192be5 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -237,7 +237,7 @@ static int compare_word_to_left (WEdit * edit, long i, char *text, char *whole_l #define debug_printf(x,y) #endif -static unsigned long apply_rules_going_right (WEdit * edit, long i, unsigned long rule) +static inline unsigned long apply_rules_going_right (WEdit * edit, long i, unsigned long rule) { struct context_rule *r; int context, keyword, c1, c2; @@ -249,6 +249,8 @@ static unsigned long apply_rules_going_right (WEdit * edit, long i, unsigned lon border = rule & (RULE_ON_LEFT_BORDER | RULE_ON_RIGHT_BORDER); c1 = edit_get_byte (edit, i - 1); c2 = edit_get_byte (edit, i); + if (!c2 || !c1) + return rule; debug_printf ("%c->", c1); debug_printf ("%c ", c2); @@ -390,7 +392,7 @@ static inline int resolve_left_delim (WEdit * edit, long i, struct context_rule return 0; } -static unsigned long apply_rules_going_left (WEdit * edit, long i, unsigned long rule) +static inline unsigned long apply_rules_going_left (WEdit * edit, long i, unsigned long rule) { struct context_rule *r; int context, keyword, c2, c1; @@ -402,6 +404,8 @@ static unsigned long apply_rules_going_left (WEdit * edit, long i, unsigned long border = rule & (RULE_ON_RIGHT_BORDER | RULE_ON_LEFT_BORDER); c1 = edit_get_byte (edit, i); c2 = edit_get_byte (edit, i + 1); + if (!c2 || !c1) + return rule; debug_printf ("%c->", c2); debug_printf ("%c ", c1); @@ -1327,6 +1331,10 @@ static int edit_read_syntax_file (WEdit * edit, char **names, char *syntax_file, #else (*syntax_change_callback) (edit->widget); #endif +/* if there are no rules then turn off syntax highlighting for speed */ + if (!edit->rules[1]) + if (!edit->rules[0]->keyword[1]) + edit_free_syntax_rules (edit); } break; } diff --git a/src/ChangeLog b/src/ChangeLog index 8c65f870b..cd0f8a982 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +Fri May 1 11:24:21 1998 Paul Sheer + + * syntax.c: syntax highlighting segfaults when editing a binary + file - now fixed. + 1998-04-30 Miguel de Icaza * main.c (parse_an_arg): GNOME edition keeps track of various