diff options
| author | Stefan Monnier | 2013-05-09 14:30:46 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-09 14:30:46 -0400 |
| commit | 759fd76395eb3c4bc8605fdb656d8431b9ca404d (patch) | |
| tree | 4ff99fc2f1574146ec671c539b9ec3ce3f696536 /src/lread.c | |
| parent | 027c0f7538ba48f1eca0c8e0c339fb794e7d21e3 (diff) | |
| download | emacs-759fd76395eb3c4bc8605fdb656d8431b9ca404d.tar.gz emacs-759fd76395eb3c4bc8605fdb656d8431b9ca404d.zip | |
* 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.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 21 |
1 files changed, 20 insertions, 1 deletions
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 | ||
| 381 | static void | ||
| 382 | skip_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 |