summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-05-09 14:30:46 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-05-09 14:30:46 -0400
commit759fd76395eb3c4bc8605fdb656d8431b9ca404d (patch)
tree4ff99fc2f1574146ec671c539b9ec3ce3f696536
parent027c0f7538ba48f1eca0c8e0c339fb794e7d21e3 (diff)
downloademacs-759fd76395eb3c4bc8605fdb656d8431b9ca404d.tar.gz
* src/doc.c (get_doc_string): Slightly relax the sanity checking.
* src/lread.c (skip_dyn_eof): New function. (read1): Use it to skip the end of a file in response to #@00.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/doc.c22
-rw-r--r--src/lread.c21
3 files changed, 41 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 95b15a0f5a0..f6685824933 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-09 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * lread.c (skip_dyn_eof): New function.
+ (read1): Use it to skip the end of a file in response to #@00.
+
+ * doc.c (get_doc_string): Slightly relax the sanity checking.
+
2013-05-09 Jan Djärv <jan.h.d@swipnet.se>
* nsfns.m: Include IOGraphicsLib.h if Cocoa.
diff --git a/src/doc.c b/src/doc.c
index 7234fb38bf9..770cb1eb646 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -215,14 +215,20 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
if (CONSP (filepos))
{
int test = 1;
- if (get_doc_string_buffer[offset - test++] != ' ')
- return Qnil;
- while (get_doc_string_buffer[offset - test] >= '0'
- && get_doc_string_buffer[offset - test] <= '9')
- test++;
- if (get_doc_string_buffer[offset - test++] != '@'
- || get_doc_string_buffer[offset - test] != '#')
- return Qnil;
+ /* A dynamic docstring should be either at the very beginning of a "#@
+ comment" or right after a dynamic docstring delimiter (in case we
+ pack several such docstrings within the same comment). */
+ if (get_doc_string_buffer[offset - test] != '\037')
+ {
+ if (get_doc_string_buffer[offset - test++] != ' ')
+ return Qnil;
+ while (get_doc_string_buffer[offset - test] >= '0'
+ && get_doc_string_buffer[offset - test] <= '9')
+ test++;
+ if (get_doc_string_buffer[offset - test++] != '@'
+ || get_doc_string_buffer[offset - test] != '#')
+ return Qnil;
+ }
}
else
{
diff --git a/src/lread.c b/src/lread.c
index 272f252cf7b..15821662fc8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -378,6 +378,19 @@ skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n)
}
}
+static void
+skip_dyn_eof (Lisp_Object readcharfun)
+{
+ if (FROM_FILE_P (readcharfun))
+ {
+ block_input (); /* FIXME: Not sure if it's needed. */
+ fseek (instream, 0, SEEK_END);
+ unblock_input ();
+ }
+ else
+ while (READCHAR >= 0);
+}
+
/* Unread the character C in the way appropriate for the stream READCHARFUN.
If the stream is a user function, call it with the char as argument. */
@@ -2622,7 +2635,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (c == '@')
{
enum { extra = 100 };
- ptrdiff_t i, nskip = 0;
+ ptrdiff_t i, nskip = 0, digits = 0;
/* Read a decimal integer. */
while ((c = READCHAR) >= 0
@@ -2630,8 +2643,14 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
{
if ((STRING_BYTES_BOUND - extra) / 10 <= nskip)
string_overflow ();
+ digits++;
nskip *= 10;
nskip += c - '0';
+ if (digits == 2 && nskip == 0)
+ { /* We've just seen #@00, which means "skip to end". */
+ skip_dyn_eof (readcharfun);
+ return Qnil;
+ }
}
if (nskip > 0)
/* We can't use UNREAD here, because in the code below we side-step