From 06274af57fcff96b71346897d2e14f3412798422 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Mon, 18 May 1998 00:59:38 +0000 Subject: [PATCH] (skip_chars): Fix bug in handling a range which contains multibyte characters. --- src/syntax.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/syntax.c b/src/syntax.c index 62cc124a318..9e15cc4ff43 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1319,9 +1319,10 @@ skip_chars (forwardp, syntaxp, string, lim) else c = c_leading_code = XSTRING (string)->data[i++]; } - if (i < XSTRING (string)->size && XSTRING (string)->data[i] == '-') + if (i < XSTRING (string)->size + && XSTRING (string)->data[i_byte] == '-') { - unsigned int c2; + unsigned int c2, c2_leading_code; /* Skip over the dash. */ i++, i_byte++; @@ -1331,18 +1332,29 @@ skip_chars (forwardp, syntaxp, string, lim) /* Get the end of the range. */ if (string_multibyte) - FETCH_STRING_CHAR_ADVANCE (c2, string, i, i_byte); + { + c2_leading_code = XSTRING (string)->data[i_byte]; + FETCH_STRING_CHAR_ADVANCE (c2, string, i, i_byte); + } else c2 = XSTRING (string)->data[i++]; if (SINGLE_BYTE_CHAR_P (c)) - while (c <= c2) - { - fastmap[c] = 1; - c++; - } + { + if (! SINGLE_BYTE_CHAR_P (c2)) + error ("Invalid charcter range: %s", + XSTRING (string)->data); + while (c <= c2) + { + fastmap[c] = 1; + c++; + } + } else { + if (c_leading_code != c2_leading_code) + error ("Invalid charcter range: %s", + XSTRING (string)->data); fastmap[c_leading_code] = 1; if (c <= c2) { -- 2.39.2