summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-05-18 00:59:38 +0000
committerKenichi Handa <handa@m17n.org>1998-05-18 00:59:38 +0000
commitb99d6bd2e1b131f41276c054fa70cd28ea443494 (patch)
tree1f74321976e46d3a2917d474b14b4d63b620eb53
parentb7c85de15ef49f3351a951985bedc793838c7d82 (diff)
downloademacs-b99d6bd2e1b131f41276c054fa70cd28ea443494.tar.gz
(skip_chars): Fix bug in handling a range which
contains multibyte characters.
-rw-r--r--src/syntax.c28
1 files 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)
{