aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2005-04-20 07:50:30 +0000
committerKenichi Handa2005-04-20 07:50:30 +0000
commit256d566c94e35486a941b170ddc97deda4edc545 (patch)
treedf0eb7dddeb2a04c8b629d4f141286c987063b9f /src
parent2a7a8e99f219091c36b205445d664d933c151142 (diff)
downloademacs-256d566c94e35486a941b170ddc97deda4edc545.tar.gz
emacs-256d566c94e35486a941b170ddc97deda4edc545.zip
(Faref): Handle special slots used as default values of
ascii, eight-bit-control, eight-bit-control. Don't ignore a default value set for a group of characters. (Faset): Signal an error if IDXVAL is not a valid character code. Make a sub-chartable with correct initial value.
Diffstat (limited to 'src')
-rw-r--r--src/data.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/data.c b/src/data.c
index 25691a4678b..f6285320315 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1979,10 +1979,20 @@ or a byte-code object. IDX starts at 0. */)
1979 args_out_of_range (array, idx); 1979 args_out_of_range (array, idx);
1980 if (idxval < CHAR_TABLE_ORDINARY_SLOTS) 1980 if (idxval < CHAR_TABLE_ORDINARY_SLOTS)
1981 { 1981 {
1982 if (! SINGLE_BYTE_CHAR_P (idxval))
1983 args_out_of_range (array, idx);
1982 /* For ASCII and 8-bit European characters, the element is 1984 /* For ASCII and 8-bit European characters, the element is
1983 stored in the top table. */ 1985 stored in the top table. */
1984 val = XCHAR_TABLE (array)->contents[idxval]; 1986 val = XCHAR_TABLE (array)->contents[idxval];
1985 if (NILP (val)) 1987 if (NILP (val))
1988 {
1989 int default_slot
1990 = (idxval < 0x80 ? CHAR_TABLE_DEFAULT_SLOT_ASCII
1991 : idxval < 0xA0 ? CHAR_TABLE_DEFAULT_SLOT_8_BIT_CONTROL
1992 : CHAR_TABLE_DEFAULT_SLOT_8_BIT_GRAPHIC);
1993 val = XCHAR_TABLE (array)->contents[default_slot];
1994 }
1995 if (NILP (val))
1986 val = XCHAR_TABLE (array)->defalt; 1996 val = XCHAR_TABLE (array)->defalt;
1987 while (NILP (val)) /* Follow parents until we find some value. */ 1997 while (NILP (val)) /* Follow parents until we find some value. */
1988 { 1998 {
@@ -1999,6 +2009,7 @@ or a byte-code object. IDX starts at 0. */)
1999 { 2009 {
2000 int code[4], i; 2010 int code[4], i;
2001 Lisp_Object sub_table; 2011 Lisp_Object sub_table;
2012 Lisp_Object current_default;
2002 2013
2003 SPLIT_CHAR (idxval, code[0], code[1], code[2]); 2014 SPLIT_CHAR (idxval, code[0], code[1], code[2]);
2004 if (code[1] < 32) code[1] = -1; 2015 if (code[1] < 32) code[1] = -1;
@@ -2012,16 +2023,21 @@ or a byte-code object. IDX starts at 0. */)
2012 code[3] = -1; /* anchor */ 2023 code[3] = -1; /* anchor */
2013 2024
2014 try_parent_char_table: 2025 try_parent_char_table:
2026 current_default = XCHAR_TABLE (array)->defalt;
2015 sub_table = array; 2027 sub_table = array;
2016 for (i = 0; code[i] >= 0; i++) 2028 for (i = 0; code[i] >= 0; i++)
2017 { 2029 {
2018 val = XCHAR_TABLE (sub_table)->contents[code[i]]; 2030 val = XCHAR_TABLE (sub_table)->contents[code[i]];
2019 if (SUB_CHAR_TABLE_P (val)) 2031 if (SUB_CHAR_TABLE_P (val))
2020 sub_table = val; 2032 {
2033 sub_table = val;
2034 if (! NILP (XCHAR_TABLE (sub_table)->defalt))
2035 current_default = XCHAR_TABLE (sub_table)->defalt;
2036 }
2021 else 2037 else
2022 { 2038 {
2023 if (NILP (val)) 2039 if (NILP (val))
2024 val = XCHAR_TABLE (sub_table)->defalt; 2040 val = current_default;
2025 if (NILP (val)) 2041 if (NILP (val))
2026 { 2042 {
2027 array = XCHAR_TABLE (array)->parent; 2043 array = XCHAR_TABLE (array)->parent;
@@ -2031,9 +2047,12 @@ or a byte-code object. IDX starts at 0. */)
2031 return val; 2047 return val;
2032 } 2048 }
2033 } 2049 }
2034 /* Here, VAL is a sub char table. We try the default value 2050 /* Reaching here means IDXVAL is a generic character in
2035 and parent. */ 2051 which each character or a group has independent value.
2036 val = XCHAR_TABLE (val)->defalt; 2052 Essentially it's nonsense to get a value for such a
2053 generic character, but for backward compatibility, we try
2054 the default value and parent. */
2055 val = current_default;
2037 if (NILP (val)) 2056 if (NILP (val))
2038 { 2057 {
2039 array = XCHAR_TABLE (array)->parent; 2058 array = XCHAR_TABLE (array)->parent;
@@ -2102,7 +2121,11 @@ bool-vector. IDX starts at 0. */)
2102 if (idxval < 0) 2121 if (idxval < 0)
2103 args_out_of_range (array, idx); 2122 args_out_of_range (array, idx);
2104 if (idxval < CHAR_TABLE_ORDINARY_SLOTS) 2123 if (idxval < CHAR_TABLE_ORDINARY_SLOTS)
2105 XCHAR_TABLE (array)->contents[idxval] = newelt; 2124 {
2125 if (! SINGLE_BYTE_CHAR_P (idxval))
2126 args_out_of_range (array, idx);
2127 XCHAR_TABLE (array)->contents[idxval] = newelt;
2128 }
2106 else 2129 else
2107 { 2130 {
2108 int code[4], i; 2131 int code[4], i;
@@ -2125,12 +2148,9 @@ bool-vector. IDX starts at 0. */)
2125 Lisp_Object temp; 2148 Lisp_Object temp;
2126 2149
2127 /* VAL is a leaf. Create a sub char table with the 2150 /* VAL is a leaf. Create a sub char table with the
2128 default value VAL or XCHAR_TABLE (array)->defalt 2151 initial value VAL and look into it. */
2129 and look into it. */
2130 2152
2131 temp = make_sub_char_table (NILP (val) 2153 temp = make_sub_char_table (val);
2132 ? XCHAR_TABLE (array)->defalt
2133 : val);
2134 XCHAR_TABLE (array)->contents[code[i]] = temp; 2154 XCHAR_TABLE (array)->contents[code[i]] = temp;
2135 array = temp; 2155 array = temp;
2136 } 2156 }