aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-10-30 16:04:52 +0000
committerGerd Moellmann2001-10-30 16:04:52 +0000
commita742d646df729e087280d80df30c8fddbe1cdbba (patch)
tree637c7d3a52e7ae97917dc87dabb7a9b180e31733 /src
parentcacbb9e90784b1db46d8827914ba10492e9db631 (diff)
downloademacs-a742d646df729e087280d80df30c8fddbe1cdbba.tar.gz
emacs-a742d646df729e087280d80df30c8fddbe1cdbba.zip
(to_multibyte): New function.
(read1): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/lread.c63
2 files changed, 55 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0e53a27a13d..0eb9c31220d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12001-10-30 Gerd Moellmann <gerd@gnu.org>
2
3 * lread.c (to_multibyte): New function.
4 (read1): Use it.
5
12001-10-30 Eli Zaretskii <eliz@is.elta.co.il> 62001-10-30 Eli Zaretskii <eliz@is.elta.co.il>
2 7
3 * msdos.h (FRAME_LINE_HEIGHT): Define (it's used by xmenu.c). 8 * msdos.h (FRAME_LINE_HEIGHT): Define (it's used by xmenu.c).
diff --git a/src/lread.c b/src/lread.c
index cb7e2d75ad5..59e84105a39 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -193,6 +193,7 @@ int load_dangerous_libraries;
193 193
194static Lisp_Object Vbytecomp_version_regexp; 194static Lisp_Object Vbytecomp_version_regexp;
195 195
196static void to_multibyte P_ ((char **, char **, int *));
196static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, 197static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object,
197 Lisp_Object (*) (), int, 198 Lisp_Object (*) (), int,
198 Lisp_Object, Lisp_Object)); 199 Lisp_Object, Lisp_Object));
@@ -1769,6 +1770,43 @@ read_integer (readcharfun, radix)
1769} 1770}
1770 1771
1771 1772
1773/* Convert unibyte text in read_buffer to multibyte.
1774
1775 Initially, *P is a pointer after the end of the unibyte text, and
1776 the pointer *END points after the end of read_buffer.
1777
1778 If read_buffer doesn't have enough room to hold the result
1779 of the conversion, reallocate it and adjust *P and *END.
1780
1781 At the end, make *P point after the result of the conversion, and
1782 return in *NCHARS the number of characters in the converted
1783 text. */
1784
1785static void
1786to_multibyte (p, end, nchars)
1787 char **p, **end;
1788 int *nchars;
1789{
1790 int nbytes;
1791
1792 parse_str_as_multibyte (read_buffer, *p - read_buffer, &nbytes, nchars);
1793 if (nbytes > read_buffer_size)
1794 {
1795 int offset = *p - read_buffer;
1796 read_buffer_size *= 2;
1797 read_buffer = (char *) xrealloc (read_buffer, read_buffer_size);
1798 *p = read_buffer + offset;
1799 *end = read_buffer + read_buffer_size;
1800 }
1801
1802 if (nbytes != *nchars)
1803 nbytes = str_as_multibyte (read_buffer, read_buffer_size,
1804 *p - read_buffer, nchars);
1805
1806 *p = read_buffer + nbytes;
1807}
1808
1809
1772/* If the next token is ')' or ']' or '.', we store that character 1810/* If the next token is ')' or ']' or '.', we store that character
1773 in *PCH and the return value is not interesting. Else, we store 1811 in *PCH and the return value is not interesting. Else, we store
1774 zero in *PCH and we read and return one lisp object. 1812 zero in *PCH and we read and return one lisp object.
@@ -2122,8 +2160,8 @@ read1 (readcharfun, pch, first_in_list)
2122 2160
2123 case '"': 2161 case '"':
2124 { 2162 {
2125 register char *p = read_buffer; 2163 char *p = read_buffer;
2126 register char *end = read_buffer + read_buffer_size; 2164 char *end = read_buffer + read_buffer_size;
2127 register int c; 2165 register int c;
2128 /* Nonzero if we saw an escape sequence specifying 2166 /* Nonzero if we saw an escape sequence specifying
2129 a multibyte character. */ 2167 a multibyte character. */
@@ -2208,15 +2246,13 @@ read1 (readcharfun, pch, first_in_list)
2208 return make_number (0); 2246 return make_number (0);
2209 2247
2210 if (force_multibyte) 2248 if (force_multibyte)
2211 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, 2249 to_multibyte (&p, &end, &nchars);
2212 p - read_buffer, &nchars);
2213 else if (force_singlebyte) 2250 else if (force_singlebyte)
2214 nchars = p - read_buffer; 2251 nchars = p - read_buffer;
2215 else if (load_convert_to_unibyte) 2252 else if (load_convert_to_unibyte)
2216 { 2253 {
2217 Lisp_Object string; 2254 Lisp_Object string;
2218 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, 2255 to_multibyte (&p, &end, &nchars);
2219 p - read_buffer, &nchars);
2220 if (p - read_buffer != nchars) 2256 if (p - read_buffer != nchars)
2221 { 2257 {
2222 string = make_multibyte_string (read_buffer, nchars, 2258 string = make_multibyte_string (read_buffer, nchars,
@@ -2226,13 +2262,14 @@ read1 (readcharfun, pch, first_in_list)
2226 } 2262 }
2227 else if (EQ (readcharfun, Qget_file_char) 2263 else if (EQ (readcharfun, Qget_file_char)
2228 || EQ (readcharfun, Qlambda)) 2264 || EQ (readcharfun, Qlambda))
2229 /* Nowadays, reading directly from a file is used only for 2265 {
2230 compiled Emacs Lisp files, and those always use the 2266 /* Nowadays, reading directly from a file is used only for
2231 Emacs internal encoding. Meanwhile, Qlambda is used 2267 compiled Emacs Lisp files, and those always use the
2232 for reading dynamic byte code (compiled with 2268 Emacs internal encoding. Meanwhile, Qlambda is used
2233 byte-compile-dynamic = t). */ 2269 for reading dynamic byte code (compiled with
2234 p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer, 2270 byte-compile-dynamic = t). */
2235 p - read_buffer, &nchars); 2271 to_multibyte (&p, &end, &nchars);
2272 }
2236 else 2273 else
2237 /* In all other cases, if we read these bytes as 2274 /* In all other cases, if we read these bytes as
2238 separate characters, treat them as separate characters now. */ 2275 separate characters, treat them as separate characters now. */