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)
{
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)
{
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)
{
{
/* 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;
{
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))
{