Commit 93daa011 authored by Kenichi Handa's avatar Kenichi Handa

(compile_pattern_1): Don't adjust the multibyteness of

the regexp pattern and the matching target.  Set cp->buf.multibyte
to the multibyteness of the regexp pattern.  Set
cp->but.target_multibyte to the multibyteness of the matching
target.
(wordify): Use FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE instead of
FETCH_STRING_CHAR_ADVANCE.
(Freplace_match): Convert unibyte chars to multibyte.
parent bf216479
......@@ -117,51 +117,20 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
int posix;
int multibyte;
{
unsigned char *raw_pattern;
int raw_pattern_size;
char *val;
reg_syntax_t old;
/* MULTIBYTE says whether the text to be searched is multibyte.
We must convert PATTERN to match that, or we will not really
find things right. */
if (multibyte == STRING_MULTIBYTE (pattern))
{
raw_pattern = (unsigned char *) XSTRING (pattern)->data;
raw_pattern_size = STRING_BYTES (XSTRING (pattern));
}
else if (multibyte)
{
raw_pattern_size = count_size_as_multibyte (XSTRING (pattern)->data,
XSTRING (pattern)->size);
raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
copy_text (XSTRING (pattern)->data, raw_pattern,
XSTRING (pattern)->size, 0, 1);
}
else
{
/* Converting multibyte to single-byte.
??? Perhaps this conversion should be done in a special way
by subtracting nonascii-insert-offset from each non-ASCII char,
so that only the multibyte chars which really correspond to
the chosen single-byte character set can possibly match. */
raw_pattern_size = XSTRING (pattern)->size;
raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
copy_text (XSTRING (pattern)->data, raw_pattern,
STRING_BYTES (XSTRING (pattern)), 1, 0);
}
cp->regexp = Qnil;
cp->buf.translate = (! NILP (translate) ? translate : make_number (0));
cp->posix = posix;
cp->buf.multibyte = multibyte;
cp->buf.multibyte = STRING_MULTIBYTE (pattern);
cp->buf.target_multibyte = multibyte;
BLOCK_INPUT;
old = re_set_syntax (RE_SYNTAX_EMACS
| (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
val = (char *) re_compile_pattern ((char *)raw_pattern,
raw_pattern_size, &cp->buf);
val = (char *) re_compile_pattern ((char *) (XSTRING (pattern)->data),
STRING_BYTES (XSTRING (pattern)),
&cp->buf);
re_set_syntax (old);
UNBLOCK_INPUT;
if (val)
......@@ -1952,7 +1921,7 @@ wordify (string)
{
int c;
FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte);
if (SYNTAX (c) != Sword)
{
......@@ -1987,7 +1956,7 @@ wordify (string)
int c;
int i_byte_orig = i_byte;
FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte);
if (SYNTAX (c) == Sword)
{
......@@ -2245,21 +2214,14 @@ since only regular expressions have distinguished subexpressions. */)
{
/* Decide how to casify by examining the matched text. */
int last;
int multibyte;
pos = search_regs.start[sub];
last = search_regs.end[sub];
if (NILP (string))
{
pos_byte = CHAR_TO_BYTE (pos);
multibyte = ! NILP (current_buffer->enable_multibyte_characters);
}
pos_byte = CHAR_TO_BYTE (pos);
else
{
pos_byte = string_char_to_byte (string, pos);
multibyte = STRING_MULTIBYTE (string);
}
pos_byte = string_char_to_byte (string, pos);
prevc = '\n';
case_action = all_caps;
......@@ -2275,15 +2237,11 @@ since only regular expressions have distinguished subexpressions. */)
{
if (NILP (string))
{
c = FETCH_CHAR (pos_byte);
c = FETCH_CHAR_AS_MULTIBYTE (pos_byte);
INC_BOTH (pos, pos_byte);
}
else
FETCH_STRING_CHAR_ADVANCE (c, string, pos, pos_byte);
if (! multibyte)
{
MAKE_CHAR_MULTIBYTE (c);
}
FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, pos, pos_byte);
if (LOWERCASEP (c))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment