diff options
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/lread.c b/src/lread.c index f252993207d..639d574ac6b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2619,21 +2619,38 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2619 | c = READCHAR; | 2619 | c = READCHAR; |
| 2620 | if (c == '[') | 2620 | if (c == '[') |
| 2621 | { | 2621 | { |
| 2622 | Lisp_Object tmp; | 2622 | /* Sub char-table can't be read as a regular |
| 2623 | int depth; | 2623 | vector because of a two C integer fields. */ |
| 2624 | ptrdiff_t size; | 2624 | Lisp_Object tbl, tmp = read_list (1, readcharfun); |
| 2625 | ptrdiff_t size = XINT (Flength (tmp)); | ||
| 2626 | int i, depth, min_char; | ||
| 2627 | struct Lisp_Cons *cell; | ||
| 2625 | 2628 | ||
| 2626 | tmp = read_vector (readcharfun, 0); | ||
| 2627 | size = ASIZE (tmp); | ||
| 2628 | if (size == 0) | 2629 | if (size == 0) |
| 2629 | error ("Invalid size char-table"); | 2630 | error ("Zero-sized sub char-table"); |
| 2630 | if (! RANGED_INTEGERP (1, AREF (tmp, 0), 3)) | 2631 | |
| 2631 | error ("Invalid depth in char-table"); | 2632 | if (! RANGED_INTEGERP (1, XCAR (tmp), 3)) |
| 2632 | depth = XINT (AREF (tmp, 0)); | 2633 | error ("Invalid depth in sub char-table"); |
| 2634 | depth = XINT (XCAR (tmp)); | ||
| 2633 | if (chartab_size[depth] != size - 2) | 2635 | if (chartab_size[depth] != size - 2) |
| 2634 | error ("Invalid size char-table"); | 2636 | error ("Invalid size in sub char-table"); |
| 2635 | XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE); | 2637 | cell = XCONS (tmp), tmp = XCDR (tmp), size--; |
| 2636 | return tmp; | 2638 | free_cons (cell); |
| 2639 | |||
| 2640 | if (! RANGED_INTEGERP (0, XCAR (tmp), MAX_CHAR)) | ||
| 2641 | error ("Invalid minimum character in sub-char-table"); | ||
| 2642 | min_char = XINT (XCAR (tmp)); | ||
| 2643 | cell = XCONS (tmp), tmp = XCDR (tmp), size--; | ||
| 2644 | free_cons (cell); | ||
| 2645 | |||
| 2646 | tbl = make_uninit_sub_char_table (depth, min_char); | ||
| 2647 | for (i = 0; i < size; i++) | ||
| 2648 | { | ||
| 2649 | XSUB_CHAR_TABLE (tbl)->contents[i] = XCAR (tmp); | ||
| 2650 | cell = XCONS (tmp), tmp = XCDR (tmp); | ||
| 2651 | free_cons (cell); | ||
| 2652 | } | ||
| 2653 | return tbl; | ||
| 2637 | } | 2654 | } |
| 2638 | invalid_syntax ("#^^"); | 2655 | invalid_syntax ("#^^"); |
| 2639 | } | 2656 | } |