Mercurial > emacs
comparison src/alloc.c @ 28997:fc8d42f77d4f
(Fmake_byte_code): If BYTECODE-STRING is multibyte,
convert it to unibyte.
(make_string): Use parse_str_as_multibyte, not chars_in_text.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Fri, 19 May 2000 23:49:35 +0000 |
| parents | f66f2b4d5eb7 |
| children | 1d802b332e0d |
comparison
equal
deleted
inserted
replaced
| 28996:679eb595bbc0 | 28997:fc8d42f77d4f |
|---|---|
| 1388 make_string (contents, nbytes) | 1388 make_string (contents, nbytes) |
| 1389 char *contents; | 1389 char *contents; |
| 1390 int nbytes; | 1390 int nbytes; |
| 1391 { | 1391 { |
| 1392 register Lisp_Object val; | 1392 register Lisp_Object val; |
| 1393 int nchars = chars_in_text (contents, nbytes); | 1393 int nchars, multibyte_nbytes; |
| 1394 | |
| 1395 parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); | |
| 1394 val = make_uninit_multibyte_string (nchars, nbytes); | 1396 val = make_uninit_multibyte_string (nchars, nbytes); |
| 1395 bcopy (contents, XSTRING (val)->data, nbytes); | 1397 bcopy (contents, XSTRING (val)->data, nbytes); |
| 1396 if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size) | 1398 if (nbytes == nchars || nbytes != multibyte_nbytes) |
| 1399 /* CONTENTS contains no multibyte sequences or contains an invalid | |
| 1400 multibyte sequence. We must make unibyte string. */ | |
| 1397 SET_STRING_BYTES (XSTRING (val), -1); | 1401 SET_STRING_BYTES (XSTRING (val), -1); |
| 1398 return val; | 1402 return val; |
| 1399 } | 1403 } |
| 1400 | 1404 |
| 1401 | 1405 |
| 1951 XSETFASTINT (len, nargs); | 1955 XSETFASTINT (len, nargs); |
| 1952 if (!NILP (Vpurify_flag)) | 1956 if (!NILP (Vpurify_flag)) |
| 1953 val = make_pure_vector ((EMACS_INT) nargs); | 1957 val = make_pure_vector ((EMACS_INT) nargs); |
| 1954 else | 1958 else |
| 1955 val = Fmake_vector (len, Qnil); | 1959 val = Fmake_vector (len, Qnil); |
| 1960 | |
| 1961 if (STRINGP (args[1]) && STRING_MULTIBYTE (args[1])) | |
| 1962 /* BYTECODE-STRING must have been produced by Emacs 20.2 or the | |
| 1963 earlier because they produced a raw 8-bit string for byte-code | |
| 1964 and now such a byte-code string is loaded as multibyte while | |
| 1965 raw 8-bit characters converted to multibyte form. Thus, now we | |
| 1966 must convert them back to the original unibyte form. */ | |
| 1967 args[1] = Fstring_as_unibyte (args[1]); | |
| 1968 | |
| 1956 p = XVECTOR (val); | 1969 p = XVECTOR (val); |
| 1957 for (index = 0; index < nargs; index++) | 1970 for (index = 0; index < nargs; index++) |
| 1958 { | 1971 { |
| 1959 if (!NILP (Vpurify_flag)) | 1972 if (!NILP (Vpurify_flag)) |
| 1960 args[index] = Fpurecopy (args[index]); | 1973 args[index] = Fpurecopy (args[index]); |
