From f426c570a684e8c565514e91ab963bd9d8545c99 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 16 Oct 2003 20:31:06 +0000 Subject: [PATCH] * syntax.c (compare_word_to_right): More checks for braces and brackets. --- edit/ChangeLog | 5 +++++ edit/syntax.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/edit/ChangeLog b/edit/ChangeLog index bd703d0a9..a16e75ea6 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,3 +1,8 @@ +2003-10-16 Andrew V. Samoilov + + * syntax.c (compare_word_to_right): More checks for braces and + brackets. + 2003-10-16 Pavel Roskin * syntax.c (compare_word_to_right): Fix recent breakage - rules diff --git a/edit/syntax.c b/edit/syntax.c index d8bdbcf7c..28250b92c 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -147,7 +147,7 @@ compare_word_to_right (WEdit *edit, long i, const char *text, const char *whole_left, const char *whole_right, int line_start) { - unsigned char *p, *q; + const unsigned char *p, *q; int c, d, j; if (!*text) return -1; @@ -220,12 +220,12 @@ compare_word_to_right (WEdit *edit, long i, const char *text, for (;; i++) { d = c; c = edit_get_byte (edit, i); - for (j = 0; p[j] != SYNTAX_TOKEN_BRACKET; j++) + for (j = 0; p[j] != SYNTAX_TOKEN_BRACKET && p[j]; j++) if (c == p[j]) goto found_char2; break; found_char2: - j = c; /* dummy command */ + ; /* dummy command */ } i--; while (*p != SYNTAX_TOKEN_BRACKET && p <= q) @@ -239,12 +239,13 @@ compare_word_to_right (WEdit *edit, long i, const char *text, if (++p > q) return -1; c = edit_get_byte (edit, i); - for (; *p != SYNTAX_TOKEN_BRACE; p++) + for (; *p != SYNTAX_TOKEN_BRACE && *p; p++) if (c == *p) goto found_char3; return -1; found_char3: - for (; *p != SYNTAX_TOKEN_BRACE && p <= q; p++); + while (*p != SYNTAX_TOKEN_BRACE && p < q) + p++; break; default: if (*p != edit_get_byte (edit, i))