aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
12013-05-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * lread.c (skip_dyn_eof): New function.
4 (read1): Use it to skip the end of a file in response to #@00.
5
6 * doc.c (get_doc_string): Slightly relax the sanity checking.
7
12013-05-09 Jan Djärv <jan.h.d@swipnet.se> 82013-05-09 Jan Djärv <jan.h.d@swipnet.se>
2 9
3 * nsfns.m: Include IOGraphicsLib.h if Cocoa. 10 * 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)
215 if (CONSP (filepos)) 215 if (CONSP (filepos))
216 { 216 {
217 int test = 1; 217 int test = 1;
218 if (get_doc_string_buffer[offset - test++] != ' ') 218 /* A dynamic docstring should be either at the very beginning of a "#@
219 return Qnil; 219 comment" or right after a dynamic docstring delimiter (in case we
220 while (get_doc_string_buffer[offset - test] >= '0' 220 pack several such docstrings within the same comment). */
221 && get_doc_string_buffer[offset - test] <= '9') 221 if (get_doc_string_buffer[offset - test] != '\037')
222 test++; 222 {
223 if (get_doc_string_buffer[offset - test++] != '@' 223 if (get_doc_string_buffer[offset - test++] != ' ')
224 || get_doc_string_buffer[offset - test] != '#') 224 return Qnil;
225 return Qnil; 225 while (get_doc_string_buffer[offset - test] >= '0'
226 && get_doc_string_buffer[offset - test] <= '9')
227 test++;
228 if (get_doc_string_buffer[offset - test++] != '@'
229 || get_doc_string_buffer[offset - test] != '#')
230 return Qnil;
231 }
226 } 232 }
227 else 233 else
228 { 234 {
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)
378 } 378 }
379} 379}
380 380
381static void
382skip_dyn_eof (Lisp_Object readcharfun)
383{
384 if (FROM_FILE_P (readcharfun))
385 {
386 block_input (); /* FIXME: Not sure if it's needed. */
387 fseek (instream, 0, SEEK_END);
388 unblock_input ();
389 }
390 else
391 while (READCHAR >= 0);
392}
393
381/* Unread the character C in the way appropriate for the stream READCHARFUN. 394/* Unread the character C in the way appropriate for the stream READCHARFUN.
382 If the stream is a user function, call it with the char as argument. */ 395 If the stream is a user function, call it with the char as argument. */
383 396
@@ -2622,7 +2635,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2622 if (c == '@') 2635 if (c == '@')
2623 { 2636 {
2624 enum { extra = 100 }; 2637 enum { extra = 100 };
2625 ptrdiff_t i, nskip = 0; 2638 ptrdiff_t i, nskip = 0, digits = 0;
2626 2639
2627 /* Read a decimal integer. */ 2640 /* Read a decimal integer. */
2628 while ((c = READCHAR) >= 0 2641 while ((c = READCHAR) >= 0
@@ -2630,8 +2643,14 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2630 { 2643 {
2631 if ((STRING_BYTES_BOUND - extra) / 10 <= nskip) 2644 if ((STRING_BYTES_BOUND - extra) / 10 <= nskip)
2632 string_overflow (); 2645 string_overflow ();
2646 digits++;
2633 nskip *= 10; 2647 nskip *= 10;
2634 nskip += c - '0'; 2648 nskip += c - '0';
2649 if (digits == 2 && nskip == 0)
2650 { /* We've just seen #@00, which means "skip to end". */
2651 skip_dyn_eof (readcharfun);
2652 return Qnil;
2653 }
2635 } 2654 }
2636 if (nskip > 0) 2655 if (nskip > 0)
2637 /* We can't use UNREAD here, because in the code below we side-step 2656 /* We can't use UNREAD here, because in the code below we side-step