return str[0];
}
-/* Read a \-escape sequence, assuming we already read the `\'. */
+/* Read a \-escape sequence, assuming we already read the `\'.
+ If the escape sequence forces unibyte, store 1 into *BYTEREP.
+ If the escape sequence forces multibyte, store 2 into *BYTEREP.
+ Otherwise store 0 into *BYTEREP. */
static int
-read_escape (readcharfun, stringp)
+read_escape (readcharfun, stringp, byterep)
Lisp_Object readcharfun;
int stringp;
+ int *byterep;
{
register int c = READCHAR;
+
+ *byterep = 0;
+
switch (c)
{
case -1:
error ("Invalid escape character syntax");
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
return c | meta_modifier;
case 'S':
error ("Invalid escape character syntax");
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
return c | shift_modifier;
case 'H':
error ("Invalid escape character syntax");
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
return c | hyper_modifier;
case 'A':
error ("Invalid escape character syntax");
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
return c | alt_modifier;
case 's':
error ("Invalid escape character syntax");
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
return c | super_modifier;
case 'C':
case '^':
c = READCHAR;
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, byterep);
if ((c & ~CHAR_MODIFIER_MASK) == '?')
return 0177 | (c & CHAR_MODIFIER_MASK);
else if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))
break;
}
}
+
+ *byterep = 1;
return i;
}
break;
}
}
+
+ *byterep = 2;
return i;
}
case '?':
{
+ int discard;
+
c = READCHAR;
if (c < 0)
end_of_file_error ();
if (c == '\\')
- c = read_escape (readcharfun, 0);
+ c = read_escape (readcharfun, 0, &discard);
else if (BASE_LEADING_CODE_P (c))
c = read_multibyte (c, readcharfun);
if (c == '\\')
{
- c = read_escape (readcharfun, 1);
+ int byterep;
+
+ c = read_escape (readcharfun, 1, &byterep);
/* C is -1 if \ newline has just been seen */
if (c == -1)
continue;
}
- /* If an escape specifies a non-ASCII single-byte character,
- this must be a unibyte string. */
- if (SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))
- && ! ASCII_BYTE_P ((c & ~CHAR_MODIFIER_MASK)))
+ if (byterep == 1)
force_singlebyte = 1;
+ else if (byterep == 2)
+ force_multibyte = 1;
}
if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK)))