summaryrefslogtreecommitdiff
path: root/src/lread.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2005-12-30 04:55:06 +0000
committerRichard M. Stallman <rms@gnu.org>2005-12-30 04:55:06 +0000
commitd11db2c8ddb7e6b0ce43db7f7f0582bb5c48cdb2 (patch)
tree8383f3a63ad72d557267ec1f7330b4a3fa6da64d /src/lread.c
parentc36238ee75f3dfab037a2694cf21c0f213432a92 (diff)
downloademacs-d11db2c8ddb7e6b0ce43db7f7f0582bb5c48cdb2.tar.gz
(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.c33
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,
int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
struct buffer *b = 0;
+ int bpos;
int continue_reading_p;
+ /* Nonzero if reading an entire buffer. */
+ int whole_buffer = 0;
+ /* 1 on the first time around. */
+ int first_sexp = 1;
+
+ if (MARKERP (readcharfun))
+ {
+ if (NILP (start))
+ start = readcharfun;
+ }
if (BUFFERP (readcharfun))
b = XBUFFER (readcharfun);
@@ -1344,7 +1355,6 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
if (b != 0 && NILP (b->name))
error ("Reading from killed buffer");
-
if (!NILP (start))
{
/* Switch to the buffer we are reading from. */
@@ -1359,9 +1369,20 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
/* Set point and ZV around stuff to be read. */
Fgoto_char (start);
- Fnarrow_to_region (make_number (BEGV), end);
+ if (!NILP (end))
+ Fnarrow_to_region (make_number (BEGV), end);
+
+ /* Just for cleanliness, convert END to a marker
+ if it is an integer. */
+ if (INTEGERP (end))
+ end = Fpoint_max_marker ();
}
+ /* On the first cycle, we can easily test here
+ whether we are reading the whole buffer. */
+ if (b && first_sexp)
+ whole_buffer = (PT == BEG && ZV == Z);
+
instream = stream;
read_next:
c = READCHAR;
@@ -1411,8 +1432,11 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
if (!NILP (start) && continue_reading_p)
start = Fpoint_marker ();
+
+ /* Restore saved point and BEGV. */
unbind_to (count1, Qnil);
+ /* Now eval what we just read. */
val = (*evalfun) (val);
if (printflag)
@@ -1423,11 +1447,12 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
else
Fprint (val, Qnil);
}
+
+ first_sexp = 0;
}
build_load_history (sourcename,
- stream || (INTEGERP (start) && INTEGERP (end)
- && XINT (start) == BEG && XINT (end) == Z));
+ stream || whole_buffer);
UNGCPRO;