Commit a742d646 authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(to_multibyte): New function.

(read1): Use it.
parent cacbb9e9
2001-10-30 Gerd Moellmann <gerd@gnu.org>
* lread.c (to_multibyte): New function.
(read1): Use it.
2001-10-30 Eli Zaretskii <eliz@is.elta.co.il> 2001-10-30 Eli Zaretskii <eliz@is.elta.co.il>
* msdos.h (FRAME_LINE_HEIGHT): Define (it's used by xmenu.c). * msdos.h (FRAME_LINE_HEIGHT): Define (it's used by xmenu.c).
......
...@@ -193,6 +193,7 @@ int load_dangerous_libraries; ...@@ -193,6 +193,7 @@ int load_dangerous_libraries;
static Lisp_Object Vbytecomp_version_regexp; static Lisp_Object Vbytecomp_version_regexp;
static void to_multibyte P_ ((char **, char **, int *));
static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object,
Lisp_Object (*) (), int, Lisp_Object (*) (), int,
Lisp_Object, Lisp_Object)); Lisp_Object, Lisp_Object));
...@@ -1769,6 +1770,43 @@ read_integer (readcharfun, radix) ...@@ -1769,6 +1770,43 @@ read_integer (readcharfun, radix)
} }
/* Convert unibyte text in read_buffer to multibyte.
Initially, *P is a pointer after the end of the unibyte text, and
the pointer *END points after the end of read_buffer.
If read_buffer doesn't have enough room to hold the result
of the conversion, reallocate it and adjust *P and *END.
At the end, make *P point after the result of the conversion, and
return in *NCHARS the number of characters in the converted
text. */
static void
to_multibyte (p, end, nchars)
char **p, **end;
int *nchars;
{
int nbytes;
parse_str_as_multibyte (read_buffer, *p - read_buffer, &nbytes, nchars);
if (nbytes > read_buffer_size)
{
int offset = *p - read_buffer;
read_buffer_size *= 2;
read_buffer = (char *) xrealloc (read_buffer, read_buffer_size);
*p = read_buffer + offset;
*end = read_buffer + read_buffer_size;
}
if (nbytes != *nchars)
nbytes = str_as_multibyte (read_buffer, read_buffer_size,
*p - read_buffer, nchars);
*p = read_buffer + nbytes;
}
/* If the next token is ')' or ']' or '.', we store that character /* If the next token is ')' or ']' or '.', we store that character
in *PCH and the return value is not interesting. Else, we store in *PCH and the return value is not interesting. Else, we store
zero in *PCH and we read and return one lisp object. zero in *PCH and we read and return one lisp object.
...@@ -2122,8 +2160,8 @@ read1 (readcharfun, pch, first_in_list) ...@@ -2122,8 +2160,8 @@ read1 (readcharfun, pch, first_in_list)
case '"': case '"':
{ {
register char *p = read_buffer; char *p = read_buffer;
register char *end = read_buffer + read_buffer_size; char *end = read_buffer + read_buffer_size;
register int c; register int c;
/* Nonzero if we saw an escape sequence specifying /* Nonzero if we saw an escape sequence specifying
a multibyte character. */ a multibyte character. */
...@@ -2208,15 +2246,13 @@ read1 (readcharfun, pch, first_in_list) ...@@ -2208,15 +2246,13 @@ read1 (readcharfun, pch, first_in_list)
return make_number (0); return make_number (0);
if (force_multibyte) if (force_multibyte)
p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, to_multibyte (&p, &end, &nchars);
p - read_buffer, &nchars);
else if (force_singlebyte) else if (force_singlebyte)
nchars = p - read_buffer; nchars = p - read_buffer;
else if (load_convert_to_unibyte) else if (load_convert_to_unibyte)
{ {
Lisp_Object string; Lisp_Object string;
p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, to_multibyte (&p, &end, &nchars);
p - read_buffer, &nchars);
if (p - read_buffer != nchars) if (p - read_buffer != nchars)
{ {
string = make_multibyte_string (read_buffer, nchars, string = make_multibyte_string (read_buffer, nchars,
...@@ -2226,13 +2262,14 @@ read1 (readcharfun, pch, first_in_list) ...@@ -2226,13 +2262,14 @@ read1 (readcharfun, pch, first_in_list)
} }
else if (EQ (readcharfun, Qget_file_char) else if (EQ (readcharfun, Qget_file_char)
|| EQ (readcharfun, Qlambda)) || EQ (readcharfun, Qlambda))
/* Nowadays, reading directly from a file is used only for {
compiled Emacs Lisp files, and those always use the /* Nowadays, reading directly from a file is used only for
Emacs internal encoding. Meanwhile, Qlambda is used compiled Emacs Lisp files, and those always use the
for reading dynamic byte code (compiled with Emacs internal encoding. Meanwhile, Qlambda is used
byte-compile-dynamic = t). */ for reading dynamic byte code (compiled with
p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, byte-compile-dynamic = t). */
p - read_buffer, &nchars); to_multibyte (&p, &end, &nchars);
}
else else
/* In all other cases, if we read these bytes as /* In all other cases, if we read these bytes as
separate characters, treat them as separate characters now. */ separate characters, treat them as separate characters now. */
......
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