diff options
| author | Richard M. Stallman | 1998-01-09 22:52:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-09 22:52:08 +0000 |
| commit | e28552a46a6fd55e3e2b76a214301e348cb6de54 (patch) | |
| tree | 8d3a3f3ded2aeec6fa5d529c142556794976141d /src | |
| parent | 2b08380873ba2aaa735051e5cf2cc12d7438c9d8 (diff) | |
| download | emacs-e28552a46a6fd55e3e2b76a214301e348cb6de54.tar.gz emacs-e28552a46a6fd55e3e2b76a214301e348cb6de54.zip | |
(read_escape): `\ ' stands for nothing at all.
(oblookup): Take args SIZE and SIZE_BYTE. Callers changed.
(init_obarray, read1, make_symbol):
Pass new arg to make_pure_string.
(Fintern, oblookup, Fintern_soft, intern): Handle size_byte.
(dir_warning): Pass new arg to message_dolog.
(read1): PCH is now int *.
Declare ch as int.
(read0): Declare c as int.
(read_list): Declare ch as int.
(read0): Use Fmake_string not make_string.
(read1): When reading a string, maybe use make_unibyte_string.
(Fread_from_string): Convert string indices to/from bytes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/src/lread.c b/src/lread.c index 2f3418306aa..b882d7fc026 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -526,8 +526,8 @@ Return t if file exists.") | |||
| 526 | 526 | ||
| 527 | /* If we won't print another message, mention this anyway. */ | 527 | /* If we won't print another message, mention this anyway. */ |
| 528 | if (! NILP (nomessage)) | 528 | if (! NILP (nomessage)) |
| 529 | message ("Source file `%s' newer than byte-compiled file", | 529 | message_with_string ("Source file `%s' newer than byte-compiled file", |
| 530 | XSTRING (found)->data); | 530 | found, 1); |
| 531 | } | 531 | } |
| 532 | XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; | 532 | XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; |
| 533 | } | 533 | } |
| @@ -561,12 +561,12 @@ Return t if file exists.") | |||
| 561 | if (NILP (nomessage)) | 561 | if (NILP (nomessage)) |
| 562 | { | 562 | { |
| 563 | if (!compiled) | 563 | if (!compiled) |
| 564 | message ("Loading %s (source)...", XSTRING (file)->data); | 564 | message_with_string ("Loading %s (source)...", file, 1); |
| 565 | else if (newer) | 565 | else if (newer) |
| 566 | message ("Loading %s (compiled; note, source file is newer)...", | 566 | message_with_string ("Loading %s (compiled; note, source file is newer)...", |
| 567 | XSTRING (file)->data); | 567 | file, 1); |
| 568 | else /* The typical case; compiled file newer than source file. */ | 568 | else /* The typical case; compiled file newer than source file. */ |
| 569 | message ("Loading %s...", XSTRING (file)->data); | 569 | message_with_string ("Loading %s...", file, 1); |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | GCPRO1 (file); | 572 | GCPRO1 (file); |
| @@ -597,12 +597,12 @@ Return t if file exists.") | |||
| 597 | if (!noninteractive && NILP (nomessage)) | 597 | if (!noninteractive && NILP (nomessage)) |
| 598 | { | 598 | { |
| 599 | if (!compiled) | 599 | if (!compiled) |
| 600 | message ("Loading %s (source)...done", XSTRING (file)->data); | 600 | message_with_string ("Loading %s (source)...done", file, 1); |
| 601 | else if (newer) | 601 | else if (newer) |
| 602 | message ("Loading %s (compiled; note, source file is newer)...done", | 602 | message_with_string ("Loading %s (compiled; note, source file is newer)...done", |
| 603 | XSTRING (file)->data); | 603 | file, 1); |
| 604 | else /* The typical case; compiled file newer than source file. */ | 604 | else /* The typical case; compiled file newer than source file. */ |
| 605 | message ("Loading %s...done", XSTRING (file)->data); | 605 | message_with_string ("Loading %s...done", file, 1); |
| 606 | } | 606 | } |
| 607 | return Qt; | 607 | return Qt; |
| 608 | } | 608 | } |
| @@ -1125,19 +1125,21 @@ START and END optionally delimit a substring of STRING from which to read;\n\ | |||
| 1125 | CHECK_STRING (string,0); | 1125 | CHECK_STRING (string,0); |
| 1126 | 1126 | ||
| 1127 | if (NILP (end)) | 1127 | if (NILP (end)) |
| 1128 | endval = XSTRING (string)->size; | 1128 | endval = XSTRING (string)->size_byte; |
| 1129 | else | 1129 | else |
| 1130 | { CHECK_NUMBER (end,2); | 1130 | { |
| 1131 | endval = XINT (end); | 1131 | CHECK_NUMBER (end, 2); |
| 1132 | if (endval < 0 || endval > XSTRING (string)->size) | 1132 | endval = string_char_to_byte (string, XINT (end)); |
| 1133 | if (endval < 0 || endval > XSTRING (string)->size_byte) | ||
| 1133 | args_out_of_range (string, end); | 1134 | args_out_of_range (string, end); |
| 1134 | } | 1135 | } |
| 1135 | 1136 | ||
| 1136 | if (NILP (start)) | 1137 | if (NILP (start)) |
| 1137 | startval = 0; | 1138 | startval = 0; |
| 1138 | else | 1139 | else |
| 1139 | { CHECK_NUMBER (start,1); | 1140 | { |
| 1140 | startval = XINT (start); | 1141 | CHECK_NUMBER (start, 1); |
| 1142 | startval = string_char_to_byte (string, XINT (start)); | ||
| 1141 | if (startval < 0 || startval > endval) | 1143 | if (startval < 0 || startval > endval) |
| 1142 | args_out_of_range (string, start); | 1144 | args_out_of_range (string, start); |
| 1143 | } | 1145 | } |
| @@ -1149,21 +1151,26 @@ START and END optionally delimit a substring of STRING from which to read;\n\ | |||
| 1149 | read_objects = Qnil; | 1151 | read_objects = Qnil; |
| 1150 | 1152 | ||
| 1151 | tem = read0 (string); | 1153 | tem = read0 (string); |
| 1152 | return Fcons (tem, make_number (read_from_string_index)); | 1154 | endval = string_byte_to_char (string, |
| 1155 | read_from_string_index); | ||
| 1156 | return Fcons (tem, make_number (endval)); | ||
| 1153 | } | 1157 | } |
| 1154 | 1158 | ||
| 1155 | /* Use this for recursive reads, in contexts where internal tokens | 1159 | /* Use this for recursive reads, in contexts where internal tokens |
| 1156 | are not allowed. */ | 1160 | are not allowed. */ |
| 1161 | |||
| 1157 | static Lisp_Object | 1162 | static Lisp_Object |
| 1158 | read0 (readcharfun) | 1163 | read0 (readcharfun) |
| 1159 | Lisp_Object readcharfun; | 1164 | Lisp_Object readcharfun; |
| 1160 | { | 1165 | { |
| 1161 | register Lisp_Object val; | 1166 | register Lisp_Object val; |
| 1162 | char c; | 1167 | int c; |
| 1163 | 1168 | ||
| 1164 | val = read1 (readcharfun, &c, 0); | 1169 | val = read1 (readcharfun, &c, 0); |
| 1165 | if (c) | 1170 | if (c) |
| 1166 | Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil)); | 1171 | Fsignal (Qinvalid_read_syntax, Fcons (Fmake_string (make_number (c), |
| 1172 | make_number (1)), | ||
| 1173 | Qnil)); | ||
| 1167 | 1174 | ||
| 1168 | return val; | 1175 | return val; |
| 1169 | } | 1176 | } |
| @@ -1225,6 +1232,8 @@ read_escape (readcharfun) | |||
| 1225 | return '\v'; | 1232 | return '\v'; |
| 1226 | case '\n': | 1233 | case '\n': |
| 1227 | return -1; | 1234 | return -1; |
| 1235 | case ' ': | ||
| 1236 | return -1; | ||
| 1228 | 1237 | ||
| 1229 | case 'M': | 1238 | case 'M': |
| 1230 | c = READCHAR; | 1239 | c = READCHAR; |
| @@ -1364,7 +1373,7 @@ read_escape (readcharfun) | |||
| 1364 | static Lisp_Object | 1373 | static Lisp_Object |
| 1365 | read1 (readcharfun, pch, first_in_list) | 1374 | read1 (readcharfun, pch, first_in_list) |
| 1366 | register Lisp_Object readcharfun; | 1375 | register Lisp_Object readcharfun; |
| 1367 | char *pch; | 1376 | int *pch; |
| 1368 | int first_in_list; | 1377 | int first_in_list; |
| 1369 | { | 1378 | { |
| 1370 | register int c; | 1379 | register int c; |
| @@ -1470,7 +1479,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1470 | { | 1479 | { |
| 1471 | Lisp_Object tmp; | 1480 | Lisp_Object tmp; |
| 1472 | struct gcpro gcpro1; | 1481 | struct gcpro gcpro1; |
| 1473 | char ch; | 1482 | int ch; |
| 1474 | 1483 | ||
| 1475 | /* Read the string itself. */ | 1484 | /* Read the string itself. */ |
| 1476 | tmp = read1 (readcharfun, &ch, 0); | 1485 | tmp = read1 (readcharfun, &ch, 0); |
| @@ -1734,9 +1743,12 @@ read1 (readcharfun, pch, first_in_list) | |||
| 1734 | return make_number (0); | 1743 | return make_number (0); |
| 1735 | 1744 | ||
| 1736 | if (read_pure) | 1745 | if (read_pure) |
| 1737 | return make_pure_string (read_buffer, p - read_buffer); | 1746 | return make_pure_string (read_buffer, p - read_buffer, |
| 1738 | else | 1747 | p - read_buffer); |
| 1748 | else if (! NILP (current_buffer->enable_multibyte_characters)) | ||
| 1739 | return make_string (read_buffer, p - read_buffer); | 1749 | return make_string (read_buffer, p - read_buffer); |
| 1750 | else | ||
| 1751 | return make_unibyte_string (read_buffer, p - read_buffer); | ||
| 1740 | } | 1752 | } |
| 1741 | 1753 | ||
| 1742 | case '.': | 1754 | case '.': |
| @@ -1969,7 +1981,7 @@ read_list (flag, readcharfun) | |||
| 1969 | 1981 | ||
| 1970 | while (1) | 1982 | while (1) |
| 1971 | { | 1983 | { |
| 1972 | char ch; | 1984 | int ch; |
| 1973 | GCPRO2 (val, tail); | 1985 | GCPRO2 (val, tail); |
| 1974 | elt = read1 (readcharfun, &ch, first_in_list); | 1986 | elt = read1 (readcharfun, &ch, first_in_list); |
| 1975 | UNGCPRO; | 1987 | UNGCPRO; |
| @@ -2127,7 +2139,7 @@ intern (str) | |||
| 2127 | obarray = Vobarray; | 2139 | obarray = Vobarray; |
| 2128 | if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) | 2140 | if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) |
| 2129 | obarray = check_obarray (obarray); | 2141 | obarray = check_obarray (obarray); |
| 2130 | tem = oblookup (obarray, str, len); | 2142 | tem = oblookup (obarray, str, len, len); |
| 2131 | if (SYMBOLP (tem)) | 2143 | if (SYMBOLP (tem)) |
| 2132 | return tem; | 2144 | return tem; |
| 2133 | return Fintern (make_string (str, len), obarray); | 2145 | return Fintern (make_string (str, len), obarray); |
| @@ -2142,7 +2154,7 @@ make_symbol (str) | |||
| 2142 | int len = strlen (str); | 2154 | int len = strlen (str); |
| 2143 | 2155 | ||
| 2144 | return Fmake_symbol ((!NILP (Vpurify_flag) | 2156 | return Fmake_symbol ((!NILP (Vpurify_flag) |
| 2145 | ? make_pure_string (str, len) | 2157 | ? make_pure_string (str, len, len) |
| 2146 | : make_string (str, len))); | 2158 | : make_string (str, len))); |
| 2147 | } | 2159 | } |
| 2148 | 2160 | ||
| @@ -2161,7 +2173,9 @@ it defaults to the value of `obarray'.") | |||
| 2161 | 2173 | ||
| 2162 | CHECK_STRING (string, 0); | 2174 | CHECK_STRING (string, 0); |
| 2163 | 2175 | ||
| 2164 | tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); | 2176 | tem = oblookup (obarray, XSTRING (string)->data, |
| 2177 | XSTRING (string)->size, | ||
| 2178 | XSTRING (string)->size_byte); | ||
| 2165 | if (!INTEGERP (tem)) | 2179 | if (!INTEGERP (tem)) |
| 2166 | return tem; | 2180 | return tem; |
| 2167 | 2181 | ||
| @@ -2196,7 +2210,9 @@ it defaults to the value of `obarray'.") | |||
| 2196 | 2210 | ||
| 2197 | CHECK_STRING (string, 0); | 2211 | CHECK_STRING (string, 0); |
| 2198 | 2212 | ||
| 2199 | tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); | 2213 | tem = oblookup (obarray, XSTRING (string)->data, |
| 2214 | XSTRING (string)->size, | ||
| 2215 | XSTRING (string)->size_byte); | ||
| 2200 | if (!INTEGERP (tem)) | 2216 | if (!INTEGERP (tem)) |
| 2201 | return tem; | 2217 | return tem; |
| 2202 | return Qnil; | 2218 | return Qnil; |
| @@ -2225,7 +2241,9 @@ OBARRAY defaults to the value of the variable `obarray'.") | |||
| 2225 | string = name; | 2241 | string = name; |
| 2226 | } | 2242 | } |
| 2227 | 2243 | ||
| 2228 | tem = oblookup (obarray, XSTRING (string)->data, XSTRING (string)->size); | 2244 | tem = oblookup (obarray, XSTRING (string)->data, |
| 2245 | XSTRING (string)->size, | ||
| 2246 | XSTRING (string)->size_byte); | ||
| 2229 | if (INTEGERP (tem)) | 2247 | if (INTEGERP (tem)) |
| 2230 | return Qnil; | 2248 | return Qnil; |
| 2231 | /* If arg was a symbol, don't delete anything but that symbol itself. */ | 2249 | /* If arg was a symbol, don't delete anything but that symbol itself. */ |
| @@ -2262,16 +2280,16 @@ OBARRAY defaults to the value of the variable `obarray'.") | |||
| 2262 | } | 2280 | } |
| 2263 | 2281 | ||
| 2264 | /* Return the symbol in OBARRAY whose names matches the string | 2282 | /* Return the symbol in OBARRAY whose names matches the string |
| 2265 | of SIZE characters at PTR. If there is no such symbol in OBARRAY, | 2283 | of SIZE characters (SIZE_BYTE bytes) at PTR. |
| 2266 | return nil. | 2284 | If there is no such symbol in OBARRAY, return nil. |
| 2267 | 2285 | ||
| 2268 | Also store the bucket number in oblookup_last_bucket_number. */ | 2286 | Also store the bucket number in oblookup_last_bucket_number. */ |
| 2269 | 2287 | ||
| 2270 | Lisp_Object | 2288 | Lisp_Object |
| 2271 | oblookup (obarray, ptr, size) | 2289 | oblookup (obarray, ptr, size, size_byte) |
| 2272 | Lisp_Object obarray; | 2290 | Lisp_Object obarray; |
| 2273 | register char *ptr; | 2291 | register char *ptr; |
| 2274 | register int size; | 2292 | int size, size_byte; |
| 2275 | { | 2293 | { |
| 2276 | int hash; | 2294 | int hash; |
| 2277 | int obsize; | 2295 | int obsize; |
| @@ -2287,7 +2305,7 @@ oblookup (obarray, ptr, size) | |||
| 2287 | /* This is sometimes needed in the middle of GC. */ | 2305 | /* This is sometimes needed in the middle of GC. */ |
| 2288 | obsize &= ~ARRAY_MARK_FLAG; | 2306 | obsize &= ~ARRAY_MARK_FLAG; |
| 2289 | /* Combining next two lines breaks VMS C 2.3. */ | 2307 | /* Combining next two lines breaks VMS C 2.3. */ |
| 2290 | hash = hash_string (ptr, size); | 2308 | hash = hash_string (ptr, size_byte); |
| 2291 | hash %= obsize; | 2309 | hash %= obsize; |
| 2292 | bucket = XVECTOR (obarray)->contents[hash]; | 2310 | bucket = XVECTOR (obarray)->contents[hash]; |
| 2293 | oblookup_last_bucket_number = hash; | 2311 | oblookup_last_bucket_number = hash; |
| @@ -2298,8 +2316,9 @@ oblookup (obarray, ptr, size) | |||
| 2298 | else | 2316 | else |
| 2299 | for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) | 2317 | for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->next)) |
| 2300 | { | 2318 | { |
| 2301 | if (XSYMBOL (tail)->name->size == size | 2319 | if (XSYMBOL (tail)->name->size_byte == size_byte |
| 2302 | && !bcmp (XSYMBOL (tail)->name->data, ptr, size)) | 2320 | && XSYMBOL (tail)->name->size == size |
| 2321 | && !bcmp (XSYMBOL (tail)->name->data, ptr, size_byte)) | ||
| 2303 | return tail; | 2322 | return tail; |
| 2304 | else if (XSYMBOL (tail)->next == 0) | 2323 | else if (XSYMBOL (tail)->next == 0) |
| 2305 | break; | 2324 | break; |
| @@ -2383,7 +2402,7 @@ init_obarray () | |||
| 2383 | 2402 | ||
| 2384 | XSETFASTINT (oblength, OBARRAY_SIZE); | 2403 | XSETFASTINT (oblength, OBARRAY_SIZE); |
| 2385 | 2404 | ||
| 2386 | Qnil = Fmake_symbol (make_pure_string ("nil", 3)); | 2405 | Qnil = Fmake_symbol (make_pure_string ("nil", 3, 3)); |
| 2387 | Vobarray = Fmake_vector (oblength, make_number (0)); | 2406 | Vobarray = Fmake_vector (oblength, make_number (0)); |
| 2388 | initial_obarray = Vobarray; | 2407 | initial_obarray = Vobarray; |
| 2389 | staticpro (&initial_obarray); | 2408 | staticpro (&initial_obarray); |
| @@ -2396,7 +2415,7 @@ init_obarray () | |||
| 2396 | tem = &XVECTOR (Vobarray)->contents[hash]; | 2415 | tem = &XVECTOR (Vobarray)->contents[hash]; |
| 2397 | *tem = Qnil; | 2416 | *tem = Qnil; |
| 2398 | 2417 | ||
| 2399 | Qunbound = Fmake_symbol (make_pure_string ("unbound", 7)); | 2418 | Qunbound = Fmake_symbol (make_pure_string ("unbound", 7, 7)); |
| 2400 | XSYMBOL (Qnil)->function = Qunbound; | 2419 | XSYMBOL (Qnil)->function = Qunbound; |
| 2401 | XSYMBOL (Qunbound)->value = Qunbound; | 2420 | XSYMBOL (Qunbound)->value = Qunbound; |
| 2402 | XSYMBOL (Qunbound)->function = Qunbound; | 2421 | XSYMBOL (Qunbound)->function = Qunbound; |
| @@ -2733,7 +2752,7 @@ dir_warning (format, dirname) | |||
| 2733 | 2752 | ||
| 2734 | fprintf (stderr, format, XSTRING (dirname)->data); | 2753 | fprintf (stderr, format, XSTRING (dirname)->data); |
| 2735 | sprintf (buffer, format, XSTRING (dirname)->data); | 2754 | sprintf (buffer, format, XSTRING (dirname)->data); |
| 2736 | message_dolog (buffer, strlen (buffer), 0); | 2755 | message_dolog (buffer, strlen (buffer), 0, STRING_MULTIBYTE (dirname)); |
| 2737 | } | 2756 | } |
| 2738 | 2757 | ||
| 2739 | void | 2758 | void |