diff options
| author | Stefan Monnier | 2010-12-10 19:13:08 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2010-12-10 19:13:08 -0500 |
| commit | 2c302df3a13236bfbf8ea1b771d13618fcda8d71 (patch) | |
| tree | f26dc9f22861dc37610de319d05255de058c221b /src/lread.c | |
| parent | 0c747cb143fa227e78f350ac353d703f489209df (diff) | |
| parent | 175069efeb080517afefdd44a06f7a779ea8c25c (diff) | |
| download | emacs-2c302df3a13236bfbf8ea1b771d13618fcda8d71.tar.gz emacs-2c302df3a13236bfbf8ea1b771d13618fcda8d71.zip | |
Merge from trunk
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 130 |
1 files changed, 62 insertions, 68 deletions
diff --git a/src/lread.c b/src/lread.c index e150078f6e2..83c94b02e23 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | /* Lisp parsing and input streams. | 1 | /* Lisp parsing and input streams. |
| 2 | Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, | 2 | |
| 3 | 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 | Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, |
| 4 | 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 4 | 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
| 5 | 2009, 2010 Free Software Foundation, Inc. | ||
| 5 | 6 | ||
| 6 | This file is part of GNU Emacs. | 7 | This file is part of GNU Emacs. |
| 7 | 8 | ||
| @@ -557,8 +558,6 @@ readbyte_from_string (int c, Lisp_Object readcharfun) | |||
| 557 | encoded in `emacs-mule' and the first byte is already read in | 558 | encoded in `emacs-mule' and the first byte is already read in |
| 558 | C. */ | 559 | C. */ |
| 559 | 560 | ||
| 560 | extern char emacs_mule_bytes[256]; | ||
| 561 | |||
| 562 | static int | 561 | static int |
| 563 | read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object readcharfun) | 562 | read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object readcharfun) |
| 564 | { | 563 | { |
| @@ -589,7 +588,7 @@ read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object rea | |||
| 589 | 588 | ||
| 590 | if (len == 2) | 589 | if (len == 2) |
| 591 | { | 590 | { |
| 592 | charset = emacs_mule_charset[buf[0]]; | 591 | charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]); |
| 593 | code = buf[1] & 0x7F; | 592 | code = buf[1] & 0x7F; |
| 594 | } | 593 | } |
| 595 | else if (len == 3) | 594 | else if (len == 3) |
| @@ -597,18 +596,18 @@ read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object rea | |||
| 597 | if (buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_11 | 596 | if (buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_11 |
| 598 | || buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_12) | 597 | || buf[0] == EMACS_MULE_LEADING_CODE_PRIVATE_12) |
| 599 | { | 598 | { |
| 600 | charset = emacs_mule_charset[buf[1]]; | 599 | charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]); |
| 601 | code = buf[2] & 0x7F; | 600 | code = buf[2] & 0x7F; |
| 602 | } | 601 | } |
| 603 | else | 602 | else |
| 604 | { | 603 | { |
| 605 | charset = emacs_mule_charset[buf[0]]; | 604 | charset = CHARSET_FROM_ID (emacs_mule_charset[buf[0]]); |
| 606 | code = ((buf[1] << 8) | buf[2]) & 0x7F7F; | 605 | code = ((buf[1] << 8) | buf[2]) & 0x7F7F; |
| 607 | } | 606 | } |
| 608 | } | 607 | } |
| 609 | else | 608 | else |
| 610 | { | 609 | { |
| 611 | charset = emacs_mule_charset[buf[1]]; | 610 | charset = CHARSET_FROM_ID (emacs_mule_charset[buf[1]]); |
| 612 | code = ((buf[2] << 8) | buf[3]) & 0x7F7F; | 611 | code = ((buf[2] << 8) | buf[3]) & 0x7F7F; |
| 613 | } | 612 | } |
| 614 | c = DECODE_CHAR (charset, code); | 613 | c = DECODE_CHAR (charset, code); |
| @@ -1082,6 +1081,10 @@ Loading a file records its definitions, and its `provide' and | |||
| 1082 | `require' calls, in an element of `load-history' whose | 1081 | `require' calls, in an element of `load-history' whose |
| 1083 | car is the file name loaded. See `load-history'. | 1082 | car is the file name loaded. See `load-history'. |
| 1084 | 1083 | ||
| 1084 | While the file is in the process of being loaded, the variable | ||
| 1085 | `load-in-progress' is non-nil and the variable `load-file-name' | ||
| 1086 | is bound to the file's name. | ||
| 1087 | |||
| 1085 | Return t if the file exists and loads successfully. */) | 1088 | Return t if the file exists and loads successfully. */) |
| 1086 | (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, Lisp_Object nosuffix, Lisp_Object must_suffix) | 1089 | (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, Lisp_Object nosuffix, Lisp_Object must_suffix) |
| 1087 | { | 1090 | { |
| @@ -2770,7 +2773,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2770 | old-style. For Emacs-25, we should completely remove this | 2773 | old-style. For Emacs-25, we should completely remove this |
| 2771 | first_in_list exception (old-style can still be obtained via | 2774 | first_in_list exception (old-style can still be obtained via |
| 2772 | "(\`" anyway). */ | 2775 | "(\`" anyway). */ |
| 2773 | if (first_in_list && next_char == ' ') | 2776 | if (!new_backquote_flag && first_in_list && next_char == ' ') |
| 2774 | { | 2777 | { |
| 2775 | Vold_style_backquotes = Qt; | 2778 | Vold_style_backquotes = Qt; |
| 2776 | goto default_label; | 2779 | goto default_label; |
| @@ -2787,33 +2790,48 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2787 | } | 2790 | } |
| 2788 | } | 2791 | } |
| 2789 | case ',': | 2792 | case ',': |
| 2790 | if (new_backquote_flag) | 2793 | { |
| 2791 | { | 2794 | int next_char = READCHAR; |
| 2792 | Lisp_Object comma_type = Qnil; | 2795 | UNREAD (next_char); |
| 2793 | Lisp_Object value; | 2796 | /* Transition from old-style to new-style: |
| 2794 | int ch = READCHAR; | 2797 | It used to be impossible to have a new-style , other than within |
| 2795 | 2798 | a new-style `. This is sufficient when ` and , are used in the | |
| 2796 | if (ch == '@') | 2799 | normal way, but ` and , can also appear in args to macros that |
| 2797 | comma_type = Qcomma_at; | 2800 | will not interpret them in the usual way, in which case , may be |
| 2798 | else if (ch == '.') | 2801 | used without any ` anywhere near. |
| 2799 | comma_type = Qcomma_dot; | 2802 | So we now use the same heuristic as for backquote: old-style |
| 2800 | else | 2803 | unquotes are only recognized when first on a list, and when |
| 2801 | { | 2804 | followed by a space. |
| 2802 | if (ch >= 0) UNREAD (ch); | 2805 | Because it's more difficult to peak 2 chars ahead, a new-style |
| 2803 | comma_type = Qcomma; | 2806 | ,@ can still not be used outside of a `, unless it's in the middle |
| 2804 | } | 2807 | of a list. */ |
| 2808 | if (new_backquote_flag | ||
| 2809 | || !first_in_list | ||
| 2810 | || (next_char != ' ' && next_char != '@')) | ||
| 2811 | { | ||
| 2812 | Lisp_Object comma_type = Qnil; | ||
| 2813 | Lisp_Object value; | ||
| 2814 | int ch = READCHAR; | ||
| 2805 | 2815 | ||
| 2806 | new_backquote_flag--; | 2816 | if (ch == '@') |
| 2807 | value = read0 (readcharfun); | 2817 | comma_type = Qcomma_at; |
| 2808 | new_backquote_flag++; | 2818 | else if (ch == '.') |
| 2809 | return Fcons (comma_type, Fcons (value, Qnil)); | 2819 | comma_type = Qcomma_dot; |
| 2810 | } | 2820 | else |
| 2811 | else | 2821 | { |
| 2812 | { | 2822 | if (ch >= 0) UNREAD (ch); |
| 2813 | Vold_style_backquotes = Qt; | 2823 | comma_type = Qcomma; |
| 2814 | goto default_label; | 2824 | } |
| 2815 | } | ||
| 2816 | 2825 | ||
| 2826 | value = read0 (readcharfun); | ||
| 2827 | return Fcons (comma_type, Fcons (value, Qnil)); | ||
| 2828 | } | ||
| 2829 | else | ||
| 2830 | { | ||
| 2831 | Vold_style_backquotes = Qt; | ||
| 2832 | goto default_label; | ||
| 2833 | } | ||
| 2834 | } | ||
| 2817 | case '?': | 2835 | case '?': |
| 2818 | { | 2836 | { |
| 2819 | int modifiers; | 2837 | int modifiers; |
| @@ -2840,26 +2858,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2840 | c |= modifiers; | 2858 | c |= modifiers; |
| 2841 | 2859 | ||
| 2842 | next_char = READCHAR; | 2860 | next_char = READCHAR; |
| 2843 | if (next_char == '.') | 2861 | ok = (next_char <= 040 |
| 2844 | { | 2862 | || (next_char < 0200 |
| 2845 | /* Only a dotted-pair dot is valid after a char constant. */ | 2863 | && (strchr ("\"';()[]#?`,.", next_char)))); |
| 2846 | int next_next_char = READCHAR; | ||
| 2847 | UNREAD (next_next_char); | ||
| 2848 | |||
| 2849 | ok = (next_next_char <= 040 | ||
| 2850 | || (next_next_char < 0200 | ||
| 2851 | && (strchr ("\"';([#?", next_next_char) | ||
| 2852 | || (!first_in_list && next_next_char == '`') | ||
| 2853 | || (new_backquote_flag && next_next_char == ',')))); | ||
| 2854 | } | ||
| 2855 | else | ||
| 2856 | { | ||
| 2857 | ok = (next_char <= 040 | ||
| 2858 | || (next_char < 0200 | ||
| 2859 | && (strchr ("\"';()[]#?", next_char) | ||
| 2860 | || (!first_in_list && next_char == '`') | ||
| 2861 | || (new_backquote_flag && next_char == ',')))); | ||
| 2862 | } | ||
| 2863 | UNREAD (next_char); | 2864 | UNREAD (next_char); |
| 2864 | if (ok) | 2865 | if (ok) |
| 2865 | return make_number (c); | 2866 | return make_number (c); |
| @@ -3001,9 +3002,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3001 | 3002 | ||
| 3002 | if (next_char <= 040 | 3003 | if (next_char <= 040 |
| 3003 | || (next_char < 0200 | 3004 | || (next_char < 0200 |
| 3004 | && (strchr ("\"';([#?", next_char) | 3005 | && (strchr ("\"';([#?`,", next_char)))) |
| 3005 | || (!first_in_list && next_char == '`') | ||
| 3006 | || (new_backquote_flag && next_char == ',')))) | ||
| 3007 | { | 3006 | { |
| 3008 | *pch = c; | 3007 | *pch = c; |
| 3009 | return Qnil; | 3008 | return Qnil; |
| @@ -3028,9 +3027,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3028 | while (c > 040 | 3027 | while (c > 040 |
| 3029 | && c != 0x8a0 /* NBSP */ | 3028 | && c != 0x8a0 /* NBSP */ |
| 3030 | && (c >= 0200 | 3029 | && (c >= 0200 |
| 3031 | || (!strchr ("\"';()[]#", c) | 3030 | || !(strchr ("\"';()[]#`,", c)))) |
| 3032 | && !(!first_in_list && c == '`') | ||
| 3033 | && !(new_backquote_flag && c == ',')))) | ||
| 3034 | { | 3031 | { |
| 3035 | if (end - p < MAX_MULTIBYTE_LENGTH) | 3032 | if (end - p < MAX_MULTIBYTE_LENGTH) |
| 3036 | { | 3033 | { |
| @@ -4046,9 +4043,9 @@ defalias (sname, string) | |||
| 4046 | } | 4043 | } |
| 4047 | #endif /* NOTDEF */ | 4044 | #endif /* NOTDEF */ |
| 4048 | 4045 | ||
| 4049 | /* Define an "integer variable"; a symbol whose value is forwarded | 4046 | /* Define an "integer variable"; a symbol whose value is forwarded to a |
| 4050 | to a C variable of type int. Sample call: | 4047 | C variable of type int. Sample call (munged w "xx" to fool make-docfile): |
| 4051 | DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */ | 4048 | DEFxxVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */ |
| 4052 | void | 4049 | void |
| 4053 | defvar_int (struct Lisp_Intfwd *i_fwd, | 4050 | defvar_int (struct Lisp_Intfwd *i_fwd, |
| 4054 | const char *namestring, EMACS_INT *address) | 4051 | const char *namestring, EMACS_INT *address) |
| @@ -4550,8 +4547,7 @@ to load. See also `load-dangerous-libraries'. */); | |||
| 4550 | doc: /* If non-nil, use lexical binding when evaluating code. | 4547 | doc: /* If non-nil, use lexical binding when evaluating code. |
| 4551 | This only applies to code evaluated by `eval-buffer' and `eval-region'. | 4548 | This only applies to code evaluated by `eval-buffer' and `eval-region'. |
| 4552 | This variable is automatically set from the file variables of an interpreted | 4549 | This variable is automatically set from the file variables of an interpreted |
| 4553 | lisp file read using `load'. | 4550 | lisp file read using `load'. */); |
| 4554 | This variable automatically becomes buffer-local when set. */); | ||
| 4555 | Fmake_variable_buffer_local (Qlexical_binding); | 4551 | Fmake_variable_buffer_local (Qlexical_binding); |
| 4556 | 4552 | ||
| 4557 | DEFVAR_LISP ("eval-buffer-list", &Veval_buffer_list, | 4553 | DEFVAR_LISP ("eval-buffer-list", &Veval_buffer_list, |
| @@ -4646,5 +4642,3 @@ This variable automatically becomes buffer-local when set. */); | |||
| 4646 | staticpro (&Qrehash_threshold); | 4642 | staticpro (&Qrehash_threshold); |
| 4647 | } | 4643 | } |
| 4648 | 4644 | ||
| 4649 | /* arch-tag: a0d02733-0f96-4844-a659-9fd53c4f414d | ||
| 4650 | (do not change this comment) */ | ||