diff options
| author | Richard M. Stallman | 2005-12-30 04:55:06 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-12-30 04:55:06 +0000 |
| commit | d11db2c8ddb7e6b0ce43db7f7f0582bb5c48cdb2 (patch) | |
| tree | 8383f3a63ad72d557267ec1f7330b4a3fa6da64d /src/lread.c | |
| parent | c36238ee75f3dfab037a2694cf21c0f213432a92 (diff) | |
| download | emacs-d11db2c8ddb7e6b0ce43db7f7f0582bb5c48cdb2.tar.gz emacs-d11db2c8ddb7e6b0ce43db7f7f0582bb5c48cdb2.zip | |
(readevalloop): Test for reading a whole buffer
before actually reading anything. Handle all cases, including
START = END = nil and an already-narrowed buffer.
Convert END to a marker if it is a number.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/lread.c b/src/lread.c index c8aa55780c2..4d9ddfbd009 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1318,7 +1318,18 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1318 | int count = SPECPDL_INDEX (); | 1318 | int count = SPECPDL_INDEX (); |
| 1319 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1319 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1320 | struct buffer *b = 0; | 1320 | struct buffer *b = 0; |
| 1321 | int bpos; | ||
| 1321 | int continue_reading_p; | 1322 | int continue_reading_p; |
| 1323 | /* Nonzero if reading an entire buffer. */ | ||
| 1324 | int whole_buffer = 0; | ||
| 1325 | /* 1 on the first time around. */ | ||
| 1326 | int first_sexp = 1; | ||
| 1327 | |||
| 1328 | if (MARKERP (readcharfun)) | ||
| 1329 | { | ||
| 1330 | if (NILP (start)) | ||
| 1331 | start = readcharfun; | ||
| 1332 | } | ||
| 1322 | 1333 | ||
| 1323 | if (BUFFERP (readcharfun)) | 1334 | if (BUFFERP (readcharfun)) |
| 1324 | b = XBUFFER (readcharfun); | 1335 | b = XBUFFER (readcharfun); |
| @@ -1344,7 +1355,6 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1344 | if (b != 0 && NILP (b->name)) | 1355 | if (b != 0 && NILP (b->name)) |
| 1345 | error ("Reading from killed buffer"); | 1356 | error ("Reading from killed buffer"); |
| 1346 | 1357 | ||
| 1347 | |||
| 1348 | if (!NILP (start)) | 1358 | if (!NILP (start)) |
| 1349 | { | 1359 | { |
| 1350 | /* Switch to the buffer we are reading from. */ | 1360 | /* Switch to the buffer we are reading from. */ |
| @@ -1359,9 +1369,20 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1359 | 1369 | ||
| 1360 | /* Set point and ZV around stuff to be read. */ | 1370 | /* Set point and ZV around stuff to be read. */ |
| 1361 | Fgoto_char (start); | 1371 | Fgoto_char (start); |
| 1362 | Fnarrow_to_region (make_number (BEGV), end); | 1372 | if (!NILP (end)) |
| 1373 | Fnarrow_to_region (make_number (BEGV), end); | ||
| 1374 | |||
| 1375 | /* Just for cleanliness, convert END to a marker | ||
| 1376 | if it is an integer. */ | ||
| 1377 | if (INTEGERP (end)) | ||
| 1378 | end = Fpoint_max_marker (); | ||
| 1363 | } | 1379 | } |
| 1364 | 1380 | ||
| 1381 | /* On the first cycle, we can easily test here | ||
| 1382 | whether we are reading the whole buffer. */ | ||
| 1383 | if (b && first_sexp) | ||
| 1384 | whole_buffer = (PT == BEG && ZV == Z); | ||
| 1385 | |||
| 1365 | instream = stream; | 1386 | instream = stream; |
| 1366 | read_next: | 1387 | read_next: |
| 1367 | c = READCHAR; | 1388 | c = READCHAR; |
| @@ -1411,8 +1432,11 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1411 | 1432 | ||
| 1412 | if (!NILP (start) && continue_reading_p) | 1433 | if (!NILP (start) && continue_reading_p) |
| 1413 | start = Fpoint_marker (); | 1434 | start = Fpoint_marker (); |
| 1435 | |||
| 1436 | /* Restore saved point and BEGV. */ | ||
| 1414 | unbind_to (count1, Qnil); | 1437 | unbind_to (count1, Qnil); |
| 1415 | 1438 | ||
| 1439 | /* Now eval what we just read. */ | ||
| 1416 | val = (*evalfun) (val); | 1440 | val = (*evalfun) (val); |
| 1417 | 1441 | ||
| 1418 | if (printflag) | 1442 | if (printflag) |
| @@ -1423,11 +1447,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun, | |||
| 1423 | else | 1447 | else |
| 1424 | Fprint (val, Qnil); | 1448 | Fprint (val, Qnil); |
| 1425 | } | 1449 | } |
| 1450 | |||
| 1451 | first_sexp = 0; | ||
| 1426 | } | 1452 | } |
| 1427 | 1453 | ||
| 1428 | build_load_history (sourcename, | 1454 | build_load_history (sourcename, |
| 1429 | stream || (INTEGERP (start) && INTEGERP (end) | 1455 | stream || whole_buffer); |
| 1430 | && XINT (start) == BEG && XINT (end) == Z)); | ||
| 1431 | 1456 | ||
| 1432 | UNGCPRO; | 1457 | UNGCPRO; |
| 1433 | 1458 | ||