aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lread.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/lread.c b/src/lread.c
index 73a209c20ef..01782865271 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -206,6 +206,7 @@ static Lisp_Object Vbytecomp_version_regexp;
206static void to_multibyte P_ ((char **, char **, int *)); 206static void to_multibyte P_ ((char **, char **, int *));
207static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, 207static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object,
208 Lisp_Object (*) (), int, 208 Lisp_Object (*) (), int,
209 Lisp_Object, Lisp_Object,
209 Lisp_Object, Lisp_Object)); 210 Lisp_Object, Lisp_Object));
210static Lisp_Object load_unwind P_ ((Lisp_Object)); 211static Lisp_Object load_unwind P_ ((Lisp_Object));
211static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object)); 212static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object));
@@ -912,7 +913,8 @@ Return t if file exists. */)
912 load_descriptor_list 913 load_descriptor_list
913 = Fcons (make_number (fileno (stream)), load_descriptor_list); 914 = Fcons (make_number (fileno (stream)), load_descriptor_list);
914 load_in_progress++; 915 load_in_progress++;
915 readevalloop (Qget_file_char, stream, file, Feval, 0, Qnil, Qnil); 916 readevalloop (Qget_file_char, stream, file, Feval,
917 0, Qnil, Qnil, Qnil, Qnil);
916 unbind_to (count, Qnil); 918 unbind_to (count, Qnil);
917 919
918 /* Run any load-hooks for this file. */ 920 /* Run any load-hooks for this file. */
@@ -1290,16 +1292,19 @@ end_of_file_error ()
1290 1292
1291/* UNIBYTE specifies how to set load_convert_to_unibyte 1293/* UNIBYTE specifies how to set load_convert_to_unibyte
1292 for this invocation. 1294 for this invocation.
1293 READFUN, if non-nil, is used instead of `read'. */ 1295 READFUN, if non-nil, is used instead of `read'.
1296 START, END is region in current buffer (from eval-region). */
1294 1297
1295static void 1298static void
1296readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, readfun) 1299readevalloop (readcharfun, stream, sourcename, evalfun,
1300 printflag, unibyte, readfun, start, end)
1297 Lisp_Object readcharfun; 1301 Lisp_Object readcharfun;
1298 FILE *stream; 1302 FILE *stream;
1299 Lisp_Object sourcename; 1303 Lisp_Object sourcename;
1300 Lisp_Object (*evalfun) (); 1304 Lisp_Object (*evalfun) ();
1301 int printflag; 1305 int printflag;
1302 Lisp_Object unibyte, readfun; 1306 Lisp_Object unibyte, readfun;
1307 Lisp_Object start, end;
1303{ 1308{
1304 register int c; 1309 register int c;
1305 register Lisp_Object val; 1310 register Lisp_Object val;
@@ -1327,28 +1332,41 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
1327 continue_reading_p = 1; 1332 continue_reading_p = 1;
1328 while (continue_reading_p) 1333 while (continue_reading_p)
1329 { 1334 {
1335 int count1 = SPECPDL_INDEX ();
1336
1330 if (b != 0 && NILP (b->name)) 1337 if (b != 0 && NILP (b->name))
1331 error ("Reading from killed buffer"); 1338 error ("Reading from killed buffer");
1332 1339
1340 if (!NILP (start))
1341 {
1342 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1343 record_unwind_protect (save_restriction_restore, save_restriction_save ());
1344 Fgoto_char (start);
1345 Fnarrow_to_region (make_number (BEGV), end);
1346 }
1347
1333 instream = stream; 1348 instream = stream;
1349 read_next:
1334 c = READCHAR; 1350 c = READCHAR;
1335 if (c == ';') 1351 if (c == ';')
1336 { 1352 {
1337 while ((c = READCHAR) != '\n' && c != -1); 1353 while ((c = READCHAR) != '\n' && c != -1);
1338 continue; 1354 goto read_next;
1355 }
1356 if (c < 0)
1357 {
1358 unbind_to (count1, Qnil);
1359 break;
1339 } 1360 }
1340 if (c < 0) break;
1341 1361
1342 /* Ignore whitespace here, so we can detect eof. */ 1362 /* Ignore whitespace here, so we can detect eof. */
1343 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r') 1363 if (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r')
1344 continue; 1364 goto read_next;
1345 1365
1346 if (!NILP (Vpurify_flag) && c == '(') 1366 if (!NILP (Vpurify_flag) && c == '(')
1347 { 1367 {
1348 int count1 = SPECPDL_INDEX ();
1349 record_unwind_protect (unreadpure, Qnil); 1368 record_unwind_protect (unreadpure, Qnil);
1350 val = read_list (-1, readcharfun); 1369 val = read_list (-1, readcharfun);
1351 unbind_to (count1, Qnil);
1352 } 1370 }
1353 else 1371 else
1354 { 1372 {
@@ -1374,6 +1392,10 @@ readevalloop (readcharfun, stream, sourcename, evalfun, printflag, unibyte, read
1374 val = read_internal_start (readcharfun, Qnil, Qnil); 1392 val = read_internal_start (readcharfun, Qnil, Qnil);
1375 } 1393 }
1376 1394
1395 if (!NILP (start) && continue_reading_p)
1396 start = Fpoint_marker ();
1397 unbind_to (count1, Qnil);
1398
1377 val = (*evalfun) (val); 1399 val = (*evalfun) (val);
1378 1400
1379 if (printflag) 1401 if (printflag)
@@ -1432,7 +1454,8 @@ This function preserves the position of point. */)
1432 specbind (Qstandard_output, tem); 1454 specbind (Qstandard_output, tem);
1433 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 1455 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1434 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 1456 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
1435 readevalloop (buf, 0, filename, Feval, !NILP (printflag), unibyte, Qnil); 1457 readevalloop (buf, 0, filename, Feval,
1458 !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
1436 unbind_to (count, Qnil); 1459 unbind_to (count, Qnil);
1437 1460
1438 return Qnil; 1461 return Qnil;
@@ -1464,15 +1487,10 @@ This function does not move point. */)
1464 tem = printflag; 1487 tem = printflag;
1465 specbind (Qstandard_output, tem); 1488 specbind (Qstandard_output, tem);
1466 1489
1467 if (NILP (printflag)) 1490 /* readevalloop calls functions which check the type of start and end. */
1468 record_unwind_protect (save_excursion_restore, save_excursion_save ());
1469 record_unwind_protect (save_restriction_restore, save_restriction_save ());
1470
1471 /* This both uses start and checks its type. */
1472 Fgoto_char (start);
1473 Fnarrow_to_region (make_number (BEGV), end);
1474 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, 1491 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval,
1475 !NILP (printflag), Qnil, read_function); 1492 !NILP (printflag), Qnil, read_function,
1493 start, end);
1476 1494
1477 return unbind_to (count, Qnil); 1495 return unbind_to (count, Qnil);
1478} 1496}