diff options
| author | Andreas Schwab | 2011-07-17 12:29:24 +0200 |
|---|---|---|
| committer | Andreas Schwab | 2011-07-17 12:29:24 +0200 |
| commit | 0a6a104b857cb873072e0ec38ecd27ba635a477d (patch) | |
| tree | 9cbcf46a35a52f32f3df7cf148fe62152a4f6aac /src | |
| parent | 60d847b46dd3b82b42bd49ca1ce4e5c1990bd35c (diff) | |
| download | emacs-0a6a104b857cb873072e0ec38ecd27ba635a477d.tar.gz emacs-0a6a104b857cb873072e0ec38ecd27ba635a477d.zip | |
Make read-symbol-positions-list more accurate
* src/lread.c (read_integer): Unread even EOF character.
(read1): Likewise. Properly record start position of symbol.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/lread.c | 40 |
2 files changed, 17 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 10f4186c31c..c06c98c5418 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2011-07-17 Andreas Schwab <schwab@linux-m68k.org> | 1 | 2011-07-17 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 2 | ||
| 3 | * lread.c (read_integer): Unread even EOF character. | ||
| 4 | (read1): Likewise. Properly record start position of symbol. | ||
| 5 | |||
| 3 | * lread.c (read1): Read `#:' as empty uninterned symbol if no | 6 | * lread.c (read1): Read `#:' as empty uninterned symbol if no |
| 4 | symbol character follows. | 7 | symbol character follows. |
| 5 | 8 | ||
diff --git a/src/lread.c b/src/lread.c index bb0edd898da..ef1b1a812d2 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2327,8 +2327,7 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix) | |||
| 2327 | c = READCHAR; | 2327 | c = READCHAR; |
| 2328 | } | 2328 | } |
| 2329 | 2329 | ||
| 2330 | if (c >= 0) | 2330 | UNREAD (c); |
| 2331 | UNREAD (c); | ||
| 2332 | *p = '\0'; | 2331 | *p = '\0'; |
| 2333 | } | 2332 | } |
| 2334 | 2333 | ||
| @@ -2583,8 +2582,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2583 | nskip *= 10; | 2582 | nskip *= 10; |
| 2584 | nskip += c - '0'; | 2583 | nskip += c - '0'; |
| 2585 | } | 2584 | } |
| 2586 | if (c >= 0) | 2585 | UNREAD (c); |
| 2587 | UNREAD (c); | ||
| 2588 | 2586 | ||
| 2589 | if (load_force_doc_strings | 2587 | if (load_force_doc_strings |
| 2590 | && (EQ (readcharfun, Qget_file_char) | 2588 | && (EQ (readcharfun, Qget_file_char) |
| @@ -2663,12 +2661,11 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2663 | if (!(c > 040 | 2661 | if (!(c > 040 |
| 2664 | && c != 0x8a0 | 2662 | && c != 0x8a0 |
| 2665 | && (c >= 0200 | 2663 | && (c >= 0200 |
| 2666 | || !(strchr ("\"';()[]#`,", c))))) | 2664 | || strchr ("\"';()[]#`,", c) == NULL))) |
| 2667 | { | 2665 | { |
| 2668 | /* No symbol character follows, this is the empty | 2666 | /* No symbol character follows, this is the empty |
| 2669 | symbol. */ | 2667 | symbol. */ |
| 2670 | if (c >= 0) | 2668 | UNREAD (c); |
| 2671 | UNREAD (c); | ||
| 2672 | return Fmake_symbol (build_string ("")); | 2669 | return Fmake_symbol (build_string ("")); |
| 2673 | } | 2670 | } |
| 2674 | goto read_symbol; | 2671 | goto read_symbol; |
| @@ -2852,7 +2849,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2852 | next_char = READCHAR; | 2849 | next_char = READCHAR; |
| 2853 | ok = (next_char <= 040 | 2850 | ok = (next_char <= 040 |
| 2854 | || (next_char < 0200 | 2851 | || (next_char < 0200 |
| 2855 | && (strchr ("\"';()[]#?`,.", next_char)))); | 2852 | && strchr ("\"';()[]#?`,.", next_char) != NULL)); |
| 2856 | UNREAD (next_char); | 2853 | UNREAD (next_char); |
| 2857 | if (ok) | 2854 | if (ok) |
| 2858 | return make_number (c); | 2855 | return make_number (c); |
| @@ -2977,11 +2974,6 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2977 | /* Otherwise, READ_BUFFER contains only ASCII. */ | 2974 | /* Otherwise, READ_BUFFER contains only ASCII. */ |
| 2978 | } | 2975 | } |
| 2979 | 2976 | ||
| 2980 | /* We want readchar_count to be the number of characters, not | ||
| 2981 | bytes. Hence we adjust for multibyte characters in the | ||
| 2982 | string. ... But it doesn't seem to be necessary, because | ||
| 2983 | READCHAR *does* read multibyte characters from buffers. */ | ||
| 2984 | /* readchar_count -= (p - read_buffer) - nchars; */ | ||
| 2985 | if (read_pure) | 2977 | if (read_pure) |
| 2986 | return make_pure_string (read_buffer, nchars, p - read_buffer, | 2978 | return make_pure_string (read_buffer, nchars, p - read_buffer, |
| 2987 | (force_multibyte | 2979 | (force_multibyte |
| @@ -2998,7 +2990,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2998 | 2990 | ||
| 2999 | if (next_char <= 040 | 2991 | if (next_char <= 040 |
| 3000 | || (next_char < 0200 | 2992 | || (next_char < 0200 |
| 3001 | && (strchr ("\"';([#?`,", next_char)))) | 2993 | && strchr ("\"';([#?`,", next_char) != NULL)) |
| 3002 | { | 2994 | { |
| 3003 | *pch = c; | 2995 | *pch = c; |
| 3004 | return Qnil; | 2996 | return Qnil; |
| @@ -3018,6 +3010,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3018 | { | 3010 | { |
| 3019 | char *p = read_buffer; | 3011 | char *p = read_buffer; |
| 3020 | int quoted = 0; | 3012 | int quoted = 0; |
| 3013 | int start_position = readchar_count - 1; | ||
| 3021 | 3014 | ||
| 3022 | { | 3015 | { |
| 3023 | char *end = read_buffer + read_buffer_size; | 3016 | char *end = read_buffer + read_buffer_size; |
| @@ -3048,10 +3041,11 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3048 | else | 3041 | else |
| 3049 | *p++ = c; | 3042 | *p++ = c; |
| 3050 | c = READCHAR; | 3043 | c = READCHAR; |
| 3051 | } while (c > 040 | 3044 | } |
| 3052 | && c != 0x8a0 /* NBSP */ | 3045 | while (c > 040 |
| 3053 | && (c >= 0200 | 3046 | && c != 0x8a0 /* NBSP */ |
| 3054 | || !(strchr ("\"';()[]#`,", c)))); | 3047 | && (c >= 0200 |
| 3048 | || strchr ("\"';()[]#`,", c) == NULL)); | ||
| 3055 | 3049 | ||
| 3056 | if (p == end) | 3050 | if (p == end) |
| 3057 | { | 3051 | { |
| @@ -3064,8 +3058,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3064 | end = read_buffer + read_buffer_size; | 3058 | end = read_buffer + read_buffer_size; |
| 3065 | } | 3059 | } |
| 3066 | *p = 0; | 3060 | *p = 0; |
| 3067 | if (c >= 0) | 3061 | UNREAD (c); |
| 3068 | UNREAD (c); | ||
| 3069 | } | 3062 | } |
| 3070 | 3063 | ||
| 3071 | if (!quoted && !uninterned_symbol) | 3064 | if (!quoted && !uninterned_symbol) |
| @@ -3093,12 +3086,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3093 | if (EQ (Vread_with_symbol_positions, Qt) | 3086 | if (EQ (Vread_with_symbol_positions, Qt) |
| 3094 | || EQ (Vread_with_symbol_positions, readcharfun)) | 3087 | || EQ (Vread_with_symbol_positions, readcharfun)) |
| 3095 | Vread_symbol_positions_list = | 3088 | Vread_symbol_positions_list = |
| 3096 | /* Kind of a hack; this will probably fail if characters | 3089 | Fcons (Fcons (result, make_number (start_position)), |
| 3097 | in the symbol name were escaped. Not really a big | ||
| 3098 | deal, though. */ | ||
| 3099 | Fcons (Fcons (result, | ||
| 3100 | make_number (readchar_count | ||
| 3101 | - XFASTINT (Flength (Fsymbol_name (result))))), | ||
| 3102 | Vread_symbol_positions_list); | 3090 | Vread_symbol_positions_list); |
| 3103 | return result; | 3091 | return result; |
| 3104 | } | 3092 | } |