aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2013-03-10 17:52:01 -0400
committerStefan Monnier2013-03-10 17:52:01 -0400
commitd2e24f924a37982172ec0708369570a0af315c7e (patch)
tree92508c41d85d599c83eea305cfb3329b7599fbb8 /src
parent99ec16475a6d1bbe3b308f89e45afb0096e02f0e (diff)
downloademacs-d2e24f924a37982172ec0708369570a0af315c7e.tar.gz
emacs-d2e24f924a37982172ec0708369570a0af315c7e.zip
* src/lread.c: Minor cleanup.
(FROM_FILE_P): New macro. (skip_dyn_bytes, unreadchar, read1): Use it. (read_list): Consolidate duplicated code.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/lread.c74
2 files changed, 32 insertions, 47 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 044bd5fa245..117c08d1875 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
12013-03-10 Stefan Monnier <monnier@iro.umontreal.ca> 12013-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * lread.c: Minor cleanup.
4 (FROM_FILE_P): New macro.
5 (skip_dyn_bytes, unreadchar, read1): Use it.
6 (read_list): Consolidate duplicated code.
7
3 * bytecode.c (struct byte_stack): Remove `constants' when unused. 8 * bytecode.c (struct byte_stack): Remove `constants' when unused.
4 9
52013-03-10 Eli Zaretskii <eliz@gnu.org> 102013-03-10 Eli Zaretskii <eliz@gnu.org>
diff --git a/src/lread.c b/src/lread.c
index e7af86aa664..f8ab03af218 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -348,11 +348,14 @@ readchar (Lisp_Object readcharfun, bool *multibyte)
348 return STRING_CHAR (buf); 348 return STRING_CHAR (buf);
349} 349}
350 350
351#define FROM_FILE_P(readcharfun) \
352 (EQ (readcharfun, Qget_file_char) \
353 || EQ (readcharfun, Qget_emacs_mule_file_char))
354
351static void 355static void
352skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n) 356skip_dyn_bytes (Lisp_Object readcharfun, ptrdiff_t n)
353{ 357{
354 if (EQ (readcharfun, Qget_file_char) 358 if (FROM_FILE_P (readcharfun))
355 || EQ (readcharfun, Qget_emacs_mule_file_char))
356 { 359 {
357 block_input (); /* FIXME: Not sure if it's needed. */ 360 block_input (); /* FIXME: Not sure if it's needed. */
358 fseek (instream, n, SEEK_CUR); 361 fseek (instream, n, SEEK_CUR);
@@ -423,8 +426,7 @@ unreadchar (Lisp_Object readcharfun, int c)
423 { 426 {
424 unread_char = c; 427 unread_char = c;
425 } 428 }
426 else if (EQ (readcharfun, Qget_file_char) 429 else if (FROM_FILE_P (readcharfun))
427 || EQ (readcharfun, Qget_emacs_mule_file_char))
428 { 430 {
429 unread_char = c; 431 unread_char = c;
430 } 432 }
@@ -2636,8 +2638,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2636 UNREAD (c); 2638 UNREAD (c);
2637 2639
2638 if (load_force_doc_strings 2640 if (load_force_doc_strings
2639 && (EQ (readcharfun, Qget_file_char) 2641 && (FROM_FILE_P (readcharfun)))
2640 || EQ (readcharfun, Qget_emacs_mule_file_char)))
2641 { 2642 {
2642 /* If we are supposed to force doc strings into core right now, 2643 /* If we are supposed to force doc strings into core right now,
2643 record the last string that we skipped, 2644 record the last string that we skipped,
@@ -3573,8 +3574,10 @@ read_list (bool flag, Lisp_Object readcharfun)
3573 { 3574 {
3574 if (doc_reference == 1) 3575 if (doc_reference == 1)
3575 return make_number (0); 3576 return make_number (0);
3576 if (doc_reference == 2) 3577 if (doc_reference == 2 && INTEGERP (XCDR (val)))
3577 { 3578 {
3579 char *saved = NULL;
3580 file_offset saved_position;
3578 /* Get a doc string from the file we are loading. 3581 /* Get a doc string from the file we are loading.
3579 If it's in saved_doc_string, get it from there. 3582 If it's in saved_doc_string, get it from there.
3580 3583
@@ -3591,65 +3594,42 @@ read_list (bool flag, Lisp_Object readcharfun)
3591 && pos < (saved_doc_string_position 3594 && pos < (saved_doc_string_position
3592 + saved_doc_string_length)) 3595 + saved_doc_string_length))
3593 { 3596 {
3594 ptrdiff_t start = pos - saved_doc_string_position; 3597 saved = saved_doc_string;
3595 ptrdiff_t from, to; 3598 saved_position = saved_doc_string_position;
3596
3597 /* Process quoting with ^A,
3598 and find the end of the string,
3599 which is marked with ^_ (037). */
3600 for (from = start, to = start;
3601 saved_doc_string[from] != 037;)
3602 {
3603 int c = saved_doc_string[from++];
3604 if (c == 1)
3605 {
3606 c = saved_doc_string[from++];
3607 if (c == 1)
3608 saved_doc_string[to++] = c;
3609 else if (c == '0')
3610 saved_doc_string[to++] = 0;
3611 else if (c == '_')
3612 saved_doc_string[to++] = 037;
3613 }
3614 else
3615 saved_doc_string[to++] = c;
3616 }
3617
3618 return make_unibyte_string (saved_doc_string + start,
3619 to - start);
3620 } 3599 }
3621 /* Look in prev_saved_doc_string the same way. */ 3600 /* Look in prev_saved_doc_string the same way. */
3622 else if (pos >= prev_saved_doc_string_position 3601 else if (pos >= prev_saved_doc_string_position
3623 && pos < (prev_saved_doc_string_position 3602 && pos < (prev_saved_doc_string_position
3624 + prev_saved_doc_string_length)) 3603 + prev_saved_doc_string_length))
3625 { 3604 {
3626 ptrdiff_t start = 3605 saved = prev_saved_doc_string;
3627 pos - prev_saved_doc_string_position; 3606 saved_position = prev_saved_doc_string_position;
3607 }
3608 if (saved)
3609 {
3610 ptrdiff_t start = pos - saved_position;
3628 ptrdiff_t from, to; 3611 ptrdiff_t from, to;
3629 3612
3630 /* Process quoting with ^A, 3613 /* Process quoting with ^A,
3631 and find the end of the string, 3614 and find the end of the string,
3632 which is marked with ^_ (037). */ 3615 which is marked with ^_ (037). */
3633 for (from = start, to = start; 3616 for (from = start, to = start;
3634 prev_saved_doc_string[from] != 037;) 3617 saved[from] != 037;)
3635 { 3618 {
3636 int c = prev_saved_doc_string[from++]; 3619 int c = saved[from++];
3637 if (c == 1) 3620 if (c == 1)
3638 { 3621 {
3639 c = prev_saved_doc_string[from++]; 3622 c = saved[from++];
3640 if (c == 1) 3623 saved[to++] = (c == 1 ? c
3641 prev_saved_doc_string[to++] = c; 3624 : c == '0' ? 0
3642 else if (c == '0') 3625 : c == '_' ? 037
3643 prev_saved_doc_string[to++] = 0; 3626 : c);
3644 else if (c == '_')
3645 prev_saved_doc_string[to++] = 037;
3646 } 3627 }
3647 else 3628 else
3648 prev_saved_doc_string[to++] = c; 3629 saved[to++] = c;
3649 } 3630 }
3650 3631
3651 return make_unibyte_string (prev_saved_doc_string 3632 return make_unibyte_string (saved + start,
3652 + start,
3653 to - start); 3633 to - start);
3654 } 3634 }
3655 else 3635 else