Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
9690d026
Commit
9690d026
authored
Sep 28, 2000
by
Kenichi Handa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(skip_chars): Handle negation correctly.
parent
8610d903
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
49 deletions
+30
-49
src/syntax.c
src/syntax.c
+30
-49
No files found.
src/syntax.c
View file @
9690d026
...
@@ -1346,12 +1346,8 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1346,12 +1346,8 @@ skip_chars (forwardp, syntaxp, string, lim)
register
int
ch
;
register
int
ch
;
unsigned
char
fastmap
[
0400
];
unsigned
char
fastmap
[
0400
];
/* If SYNTAXP is 0, STRING may contain multi-byte form of characters
/* If SYNTAXP is 0, STRING may contain multi-byte form of characters
of which codes don't fit in FASTMAP. In that case, we set the
of which codes don't fit in FASTMAP. In that case, set the
first byte of multibyte form (i.e. base leading-code) in FASTMAP
ranges of characters in CHAR_RANGES. */
and set the actual ranges of characters in CHAR_RANGES. In the
form "X-Y" of STRING, both X and Y must belong to the same
character set because a range striding across character sets is
meaningless. */
int
*
char_ranges
;
int
*
char_ranges
;
int
n_char_ranges
=
0
;
int
n_char_ranges
=
0
;
int
negate
=
0
;
int
negate
=
0
;
...
@@ -1414,8 +1410,6 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1414,8 +1410,6 @@ skip_chars (forwardp, syntaxp, string, lim)
while
(
i_byte
<
size_byte
)
while
(
i_byte
<
size_byte
)
{
{
int
c_leading_code
=
str
[
i_byte
];
c
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
c
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
i_byte
+=
len
;
i_byte
+=
len
;
...
@@ -1428,14 +1422,13 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1428,14 +1422,13 @@ skip_chars (forwardp, syntaxp, string, lim)
if
(
i_byte
==
size_byte
)
if
(
i_byte
==
size_byte
)
break
;
break
;
c_leading_code
=
str
[
i_byte
];
c
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
c
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
i_byte
+=
len
;
i_byte
+=
len
;
}
}
if
(
i_byte
<
size_byte
if
(
i_byte
<
size_byte
&&
str
[
i_byte
]
==
'-'
)
&&
str
[
i_byte
]
==
'-'
)
{
{
unsigned
int
c2
,
c2_leading_code
;
unsigned
int
c2
;
/* Skip over the dash. */
/* Skip over the dash. */
i_byte
++
;
i_byte
++
;
...
@@ -1444,7 +1437,6 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1444,7 +1437,6 @@ skip_chars (forwardp, syntaxp, string, lim)
break
;
break
;
/* Get the end of the range. */
/* Get the end of the range. */
c2_leading_code
=
str
[
i_byte
];
c2
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
c2
=
STRING_CHAR_AND_LENGTH
(
str
+
i_byte
,
size_byte
-
i_byte
,
len
);
i_byte
+=
len
;
i_byte
+=
len
;
...
@@ -1460,7 +1452,6 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1460,7 +1452,6 @@ skip_chars (forwardp, syntaxp, string, lim)
int
charset
=
CHAR_CHARSET
(
c2
);
int
charset
=
CHAR_CHARSET
(
c2
);
int
c1
=
MAKE_CHAR
(
charset
,
0
,
0
);
int
c1
=
MAKE_CHAR
(
charset
,
0
,
0
);
fastmap
[
c2_leading_code
]
=
1
;
char_ranges
[
n_char_ranges
++
]
=
c1
;
char_ranges
[
n_char_ranges
++
]
=
c1
;
char_ranges
[
n_char_ranges
++
]
=
c2
;
char_ranges
[
n_char_ranges
++
]
=
c2
;
c2
=
0237
;
c2
=
0237
;
...
@@ -1471,17 +1462,10 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1471,17 +1462,10 @@ skip_chars (forwardp, syntaxp, string, lim)
c
++
;
c
++
;
}
}
}
}
else
if
(
!
SINGLE_BYTE_CHAR_P
(
c2
))
else
if
(
c
<=
c2
)
/* Both C and C2 are multibyte char. */
{
{
if
(
c_leading_code
!=
c2_leading_code
)
char_ranges
[
n_char_ranges
++
]
=
c
;
error
(
"Invalid character range: %s"
,
char_ranges
[
n_char_ranges
++
]
=
c2
;
XSTRING
(
string
)
->
data
);
if
(
c
<=
c2
)
{
fastmap
[
c_leading_code
]
=
1
;
char_ranges
[
n_char_ranges
++
]
=
c
;
char_ranges
[
n_char_ranges
++
]
=
c2
;
}
}
}
}
}
else
else
...
@@ -1490,7 +1474,6 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1490,7 +1474,6 @@ skip_chars (forwardp, syntaxp, string, lim)
fastmap
[
c
]
=
1
;
fastmap
[
c
]
=
1
;
else
else
{
{
fastmap
[
c_leading_code
]
=
1
;
char_ranges
[
n_char_ranges
++
]
=
c
;
char_ranges
[
n_char_ranges
++
]
=
c
;
char_ranges
[
n_char_ranges
++
]
=
c
;
char_ranges
[
n_char_ranges
++
]
=
c
;
}
}
...
@@ -1498,19 +1481,10 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1498,19 +1481,10 @@ skip_chars (forwardp, syntaxp, string, lim)
}
}
}
}
/* If ^ was the first character, complement the fastmap. In
/* If ^ was the first character, complement the fastmap. */
addition, as all multibyte characters have possibility of
matching, set all entries for base leading codes, which is
harmless even if SYNTAXP is 1. */
if
(
negate
)
if
(
negate
)
for
(
i
=
0
;
i
<
sizeof
fastmap
;
i
++
)
for
(
i
=
0
;
i
<
sizeof
fastmap
;
i
++
)
{
fastmap
[
i
]
^=
1
;
if
(
!
multibyte
||
!
BASE_LEADING_CODE_P
(
i
))
fastmap
[
i
]
^=
1
;
else
fastmap
[
i
]
=
1
;
}
{
{
int
start_point
=
PT
;
int
start_point
=
PT
;
...
@@ -1585,16 +1559,22 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1585,16 +1559,22 @@ skip_chars (forwardp, syntaxp, string, lim)
if
(
forwardp
)
if
(
forwardp
)
{
{
if
(
multibyte
)
if
(
multibyte
)
while
(
pos
<
XINT
(
lim
)
&&
fastmap
[(
c
=
FETCH_BYTE
(
pos_byte
))]
)
while
(
pos
<
XINT
(
lim
))
{
{
/* If we are looking at a multibyte character, we
c
=
FETCH_MULTIBYTE_CHAR
(
pos_byte
);
must look up the character in the table
if
(
SINGLE_BYTE_CHAR_P
(
c
))
CHAR_RANGES. If there's no data in the table,
{
that character is not what we want to skip. */
if
(
!
fastmap
[
c
])
if
(
BASE_LEADING_CODE_P
(
c
)
break
;
&&
(
c
=
FETCH_MULTIBYTE_CHAR
(
pos_byte
),
}
!
SINGLE_BYTE_CHAR_P
(
c
)))
else
{
{
/* If we are looking at a multibyte character,
we must look up the character in the table
CHAR_RANGES. If there's no data in the
table, that character is not what we want to
skip. */
/* The following code do the right thing even if
/* The following code do the right thing even if
n_char_ranges is zero (i.e. no data in
n_char_ranges is zero (i.e. no data in
CHAR_RANGES). */
CHAR_RANGES). */
...
@@ -1618,14 +1598,15 @@ skip_chars (forwardp, syntaxp, string, lim)
...
@@ -1618,14 +1598,15 @@ skip_chars (forwardp, syntaxp, string, lim)
int
prev_pos_byte
=
pos_byte
;
int
prev_pos_byte
=
pos_byte
;
DEC_POS
(
prev_pos_byte
);
DEC_POS
(
prev_pos_byte
);
if
(
!
fastmap
[(
c
=
FETCH_BYTE
(
prev_pos_byte
)
)])
c
=
FETCH_MULTIBYTE_CHAR
(
prev_pos_byte
)
;
break
;
if
(
SINGLE_BYTE_CHAR_P
(
c
))
{
/* See the comment in the previous similar code. */
if
(
!
fastmap
[
c
])
if
(
BASE_LEADING_CODE_P
(
c
)
break
;
&&
(
c
=
FETCH_MULTIBYTE_CHAR
(
prev_pos_byte
),
}
!
SINGLE_BYTE_CHAR_P
(
c
)))
else
{
{
/* See the comment in the previous similar code. */
for
(
i
=
0
;
i
<
n_char_ranges
;
i
+=
2
)
for
(
i
=
0
;
i
<
n_char_ranges
;
i
+=
2
)
if
(
c
>=
char_ranges
[
i
]
&&
c
<=
char_ranges
[
i
+
1
])
if
(
c
>=
char_ranges
[
i
]
&&
c
<=
char_ranges
[
i
+
1
])
break
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment