2145 |
char *p = read_buffer; |
char *p = read_buffer; |
2146 |
char *end = read_buffer + read_buffer_size; |
char *end = read_buffer + read_buffer_size; |
2147 |
register int c; |
register int c; |
2148 |
/* Nonzero if we saw an escape sequence specifying |
/* 1 if we saw an escape sequence specifying |
2149 |
a multibyte character. */ |
a multibyte character, or a multibyte character. */ |
2150 |
int force_multibyte = 0; |
int force_multibyte = 0; |
2151 |
/* Nonzero if we saw an escape sequence specifying |
/* 1 if we saw an escape sequence specifying |
2152 |
a single-byte character. */ |
a single-byte character. */ |
2153 |
int force_singlebyte = 0; |
int force_singlebyte = 0; |
2154 |
|
/* 1 if read_buffer contains multibyte text now. */ |
2155 |
|
int is_multibyte = 0; |
2156 |
int cancel = 0; |
int cancel = 0; |
2157 |
int nchars; |
int nchars = 0; |
2158 |
|
|
2159 |
while ((c = READCHAR) >= 0 |
while ((c = READCHAR) >= 0 |
2160 |
&& c != '\"') |
&& c != '\"') |
2188 |
force_multibyte = 1; |
force_multibyte = 1; |
2189 |
} |
} |
2190 |
|
|
2191 |
if (! SINGLE_BYTE_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) |
/* A character that must be multibyte forces multibyte. */ |
2192 |
|
if (! SINGLE_BYTE_CHAR_P (c & ~CHAR_MODIFIER_MASK)) |
2193 |
|
force_multibyte = 1; |
2194 |
|
|
2195 |
|
/* If we just discovered the need to be multibyte, |
2196 |
|
convert the text accumulated thus far. */ |
2197 |
|
if (force_multibyte && ! is_multibyte) |
2198 |
{ |
{ |
2199 |
/* Any modifiers for a multibyte character are invalid. */ |
is_multibyte = 1; |
2200 |
if (c & CHAR_MODIFIER_MASK) |
to_multibyte (&p, &end, &nchars); |
|
error ("Invalid modifier in string"); |
|
|
p += CHAR_STRING (c, p); |
|
|
force_multibyte = 1; |
|
2201 |
} |
} |
|
else |
|
|
{ |
|
|
/* Allow `\C- ' and `\C-?'. */ |
|
|
if (c == (CHAR_CTL | ' ')) |
|
|
c = 0; |
|
|
else if (c == (CHAR_CTL | '?')) |
|
|
c = 127; |
|
2202 |
|
|
2203 |
if (c & CHAR_SHIFT) |
/* Allow `\C- ' and `\C-?'. */ |
2204 |
{ |
if (c == (CHAR_CTL | ' ')) |
2205 |
/* Shift modifier is valid only with [A-Za-z]. */ |
c = 0; |
2206 |
if ((c & 0377) >= 'A' && (c & 0377) <= 'Z') |
else if (c == (CHAR_CTL | '?')) |
2207 |
c &= ~CHAR_SHIFT; |
c = 127; |
|
else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') |
|
|
c = (c & ~CHAR_SHIFT) - ('a' - 'A'); |
|
|
} |
|
2208 |
|
|
2209 |
if (c & CHAR_META) |
if (c & CHAR_SHIFT) |
2210 |
/* Move the meta bit to the right place for a string. */ |
{ |
2211 |
c = (c & ~CHAR_META) | 0x80; |
/* Shift modifier is valid only with [A-Za-z]. */ |
2212 |
if (c & ~0xff) |
if ((c & 0377) >= 'A' && (c & 0377) <= 'Z') |
2213 |
error ("Invalid modifier in string"); |
c &= ~CHAR_SHIFT; |
2214 |
*p++ = c; |
else if ((c & 0377) >= 'a' && (c & 0377) <= 'z') |
2215 |
|
c = (c & ~CHAR_SHIFT) - ('a' - 'A'); |
2216 |
} |
} |
2217 |
|
|
2218 |
|
if (c & CHAR_META) |
2219 |
|
/* Move the meta bit to the right place for a string. */ |
2220 |
|
c = (c & ~CHAR_META) | 0x80; |
2221 |
|
if (c & CHAR_MODIFIER_MASK) |
2222 |
|
error ("Invalid modifier in string"); |
2223 |
|
|
2224 |
|
if (is_multibyte) |
2225 |
|
p += CHAR_STRING (c, p); |
2226 |
|
else |
2227 |
|
*p++ = c; |
2228 |
|
|
2229 |
|
nchars++; |
2230 |
} |
} |
2231 |
|
|
2232 |
if (c < 0) |
if (c < 0) |
2233 |
end_of_file_error (); |
end_of_file_error (); |
2234 |
|
|
2238 |
if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
2239 |
return make_number (0); |
return make_number (0); |
2240 |
|
|
2241 |
if (force_multibyte) |
if (is_multibyte || force_singlebyte) |
2242 |
to_multibyte (&p, &end, &nchars); |
; |
|
else if (force_singlebyte) |
|
|
nchars = p - read_buffer; |
|
2243 |
else if (load_convert_to_unibyte) |
else if (load_convert_to_unibyte) |
2244 |
{ |
{ |
2245 |
Lisp_Object string; |
Lisp_Object string; |
2250 |
p - read_buffer); |
p - read_buffer); |
2251 |
return Fstring_make_unibyte (string); |
return Fstring_make_unibyte (string); |
2252 |
} |
} |
2253 |
|
/* We can make a unibyte string directly. */ |
2254 |
|
is_multibyte = 0; |
2255 |
} |
} |
2256 |
else if (EQ (readcharfun, Qget_file_char) |
else if (EQ (readcharfun, Qget_file_char) |
2257 |
|| EQ (readcharfun, Qlambda)) |
|| EQ (readcharfun, Qlambda)) |
2262 |
for reading dynamic byte code (compiled with |
for reading dynamic byte code (compiled with |
2263 |
byte-compile-dynamic = t). */ |
byte-compile-dynamic = t). */ |
2264 |
to_multibyte (&p, &end, &nchars); |
to_multibyte (&p, &end, &nchars); |
2265 |
|
is_multibyte = 1; |
2266 |
} |
} |
2267 |
else |
else |
2268 |
/* In all other cases, if we read these bytes as |
/* In all other cases, if we read these bytes as |
2269 |
separate characters, treat them as separate characters now. */ |
separate characters, treat them as separate characters now. */ |
2270 |
nchars = p - read_buffer; |
; |
2271 |
|
|
2272 |
if (read_pure) |
if (read_pure) |
2273 |
return make_pure_string (read_buffer, nchars, p - read_buffer, |
return make_pure_string (read_buffer, nchars, p - read_buffer, |
2274 |
(force_multibyte |
is_multibyte); |
|
|| (p - read_buffer != nchars))); |
|
2275 |
return make_specified_string (read_buffer, nchars, p - read_buffer, |
return make_specified_string (read_buffer, nchars, p - read_buffer, |
2276 |
(force_multibyte |
is_multibyte); |
|
|| (p - read_buffer != nchars))); |
|
2277 |
} |
} |
2278 |
|
|
2279 |
case '.': |
case '.': |