aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorKarl Heuer1997-02-20 06:47:04 +0000
committerKarl Heuer1997-02-20 06:47:04 +0000
commit8313c4e7a8192a3a222d5bd0b9fed7181f3bc8b0 (patch)
tree6dcaf74aa8a2a498a29d6a30285193856a128945 /src/data.c
parent9e4fd67ba13984f23c7ca58ef36ed90c8fd823df (diff)
downloademacs-8313c4e7a8192a3a222d5bd0b9fed7181f3bc8b0.tar.gz
emacs-8313c4e7a8192a3a222d5bd0b9fed7181f3bc8b0.zip
Include charset.h.
(Qprocess): Now extern, not static. (Faref, Faset): Enable indexing a char table by a multibyte character.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c149
1 files changed, 80 insertions, 69 deletions
diff --git a/src/data.c b/src/data.c
index 96d0a1032e7..f5d81d82b3a 100644
--- a/src/data.c
+++ b/src/data.c
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA. */
24#include <config.h> 24#include <config.h>
25#include "lisp.h" 25#include "lisp.h"
26#include "puresize.h" 26#include "puresize.h"
27#include "charset.h"
27 28
28#ifndef standalone 29#ifndef standalone
29#include "buffer.h" 30#include "buffer.h"
@@ -93,7 +94,8 @@ Lisp_Object Qnumberp, Qnumber_or_marker_p;
93#endif 94#endif
94 95
95static Lisp_Object Qinteger, Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; 96static Lisp_Object Qinteger, Qsymbol, Qstring, Qcons, Qmarker, Qoverlay;
96static Lisp_Object Qfloat, Qwindow_configuration, Qprocess, Qwindow; 97static Lisp_Object Qfloat, Qwindow_configuration, Qwindow;
98Lisp_Object Qprocess;
97static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; 99static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector;
98static Lisp_Object Qchar_table, Qbool_vector; 100static Lisp_Object Qchar_table, Qbool_vector;
99 101
@@ -1545,57 +1547,72 @@ or a byte-code object. IDX starts at 0.")
1545 1547
1546 if (idxval < 0) 1548 if (idxval < 0)
1547 args_out_of_range (array, idx); 1549 args_out_of_range (array, idx);
1548#if 1 1550 if (idxval < CHAR_TABLE_ORDINARY_SLOTS)
1549 if ((unsigned) idxval >= CHAR_TABLE_ORDINARY_SLOTS) 1551 {
1550 args_out_of_range (array, idx); 1552 /* The element is stored in the top table. We may return a
1551 return val = XCHAR_TABLE (array)->contents[idxval]; 1553 deeper char-table. */
1552#else /* 0 */ 1554 val = XCHAR_TABLE (array)->contents[idxval];
1553 if ((unsigned) idxval < CHAR_TABLE_ORDINARY_SLOTS) 1555 if (NILP (val))
1554 val = XCHAR_TABLE (array)->data[idxval]; 1556 val = XCHAR_TABLE (array)->defalt;
1557 while (NILP (val)) /* Follow parents until we find some value. */
1558 {
1559 array = XCHAR_TABLE (array)->parent;
1560 if (NILP (array))
1561 return Qnil;
1562 val = XCHAR_TABLE (array)->contents[idxval];
1563 if (NILP (val))
1564 val = XCHAR_TABLE (array)->defalt;
1565 }
1566 return val;
1567 }
1555 else 1568 else
1556 { 1569 {
1557 int charset; 1570 int idx[4]; /* For charset, code1, code2, and anchor. */
1558 unsigned char c1, c2; 1571 int i;
1559 Lisp_Object val, temp; 1572 Lisp_Object sub_array;
1560 1573
1561 BREAKUP_NON_ASCII_CHAR (idxval, charset, c1, c2); 1574 /* There's no reason to treat a composite character
1575 specially here. */
1576#if 0
1577 if (COMPOSITE_CHAR_P (idxval))
1578 /* For a composite characters, we use the first element as
1579 the index. */
1580 idxval = cmpchar_component (idxval, 0);
1581#endif
1582 SPLIT_NON_ASCII_CHAR (idxval, idx[0], idx[1], idx[2]);
1583 idx[3] = 0;
1562 1584
1563 try_parent_char_table: 1585 try_parent_char_table:
1564 val = XCHAR_TABLE (array)->contents[charset]; 1586 sub_array = array;
1565 if (c1 == 0 || !CHAR_TABLE_P (val)) 1587 for (i = 0; idx[i]; i++)
1566 return val;
1567
1568 temp = XCHAR_TABLE (val)->contents[c1];
1569 if (NILP (temp))
1570 val = XCHAR_TABLE (val)->defalt;
1571 else
1572 val = temp;
1573
1574 if (NILP (val) && !NILP (XCHAR_TABLE (array)->parent))
1575 { 1588 {
1576 array = XCHAR_TABLE (array)->parent; 1589 val = XCHAR_TABLE (sub_array)->contents[idx[i]];
1577 goto try_parent_char_table; 1590 if (NILP (val))
1578 1591 val = XCHAR_TABLE (sub_array)->defalt;
1592 if (NILP (val))
1593 {
1594 array = XCHAR_TABLE (array)->parent;
1595 if (NILP (array))
1596 return Qnil;
1597 goto try_parent_char_table;
1598 }
1599 if (!CHAR_TABLE_P (val))
1600 return val;
1601 sub_array = val;
1579 } 1602 }
1580 1603 /* We come here because ARRAY is deeper than the specified
1581 if (c2 == 0 || !CHAR_TABLE_P (val)) 1604 indices. We return a default value stored at the deepest
1582 return val; 1605 level specified. */
1583 1606 val = XCHAR_TABLE (sub_array)->defalt;
1584 temp = XCHAR_TABLE (val)->contents[c2]; 1607 if (NILP (val))
1585 if (NILP (temp))
1586 val = XCHAR_TABLE (val)->defalt;
1587 else
1588 val = temp;
1589
1590 if (NILP (val) && !NILP (XCHAR_TABLE (array)->parent))
1591 { 1608 {
1592 array = XCHAR_TABLE (array)->parent; 1609 array = XCHAR_TABLE (array)->parent;
1610 if (NILP (array))
1611 return Qnil;
1593 goto try_parent_char_table; 1612 goto try_parent_char_table;
1594 } 1613 }
1595
1596 return val; 1614 return val;
1597 } 1615 }
1598#endif /* 0 */
1599 } 1616 }
1600 else 1617 else
1601 { 1618 {
@@ -1656,41 +1673,35 @@ ARRAY may be a vector or a string. IDX starts at 0.")
1656 1673
1657 if (idxval < 0) 1674 if (idxval < 0)
1658 args_out_of_range (array, idx); 1675 args_out_of_range (array, idx);
1659#if 1
1660 if (idxval >= CHAR_TABLE_ORDINARY_SLOTS)
1661 args_out_of_range (array, idx);
1662 XCHAR_TABLE (array)->contents[idxval] = newelt;
1663 return newelt;
1664#else /* 0 */
1665 if (idxval < CHAR_TABLE_ORDINARY_SLOTS) 1676 if (idxval < CHAR_TABLE_ORDINARY_SLOTS)
1666 val = XCHAR_TABLE (array)->contents[idxval]; 1677 XCHAR_TABLE (array)->contents[idxval] = newelt;
1667 else 1678 else
1668 { 1679 {
1669 int charset; 1680 int idx[4]; /* For charset, code1, code2, and anchor. */
1670 unsigned char c1, c2; 1681 int i;
1671 Lisp_Object val, val2; 1682 Lisp_Object val;
1672
1673 BREAKUP_NON_ASCII_CHAR (idxval, charset, c1, c2);
1674 1683
1675 if (c1 == 0) 1684 SPLIT_NON_ASCII_CHAR (idxval, idx[0], idx[1], idx[2]);
1676 return XCHAR_TABLE (array)->contents[charset] = newelt; 1685 idx[3] = 0;
1677 1686
1678 val = XCHAR_TABLE (array)->contents[charset]; 1687 for (i = 0; idx[i + 1]; i++)
1679 if (!CHAR_TABLE_P (val)) 1688 {
1680 XCHAR_TABLE (array)->contents[charset] 1689 val = XCHAR_TABLE (array)->contents[idx[i]];
1681 = val = Fmake_char_table (Qnil); 1690 if (CHAR_TABLE_P (val))
1682 1691 /* Look into this deeper array. */
1683 if (c2 == 0) 1692 array = val;
1684 return XCHAR_TABLE (val)->contents[c1] = newelt; 1693 else
1685 1694 {
1686 val2 = XCHAR_TABLE (val)->contents[c2]; 1695 /* VAL is the leaf. Create a deeper array with the
1687 if (!CHAR_TABLE_P (val2)) 1696 default value VAL, set it in the slot of VAL, and
1688 XCHAR_TABLE (val)->contents[charset] 1697 look into it. */
1689 = val2 = Fmake_char_table (Qnil); 1698 array = XCHAR_TABLE (array)->contents[idx[i]]
1690 1699 = Fmake_char_table (Qnil, Qnil);
1691 return XCHAR_TABLE (val2)->contents[c2] = newelt; 1700 XCHAR_TABLE (array)->defalt = val;
1701 }
1702 }
1703 return XCHAR_TABLE (array)->contents[idx[i]] = newelt;
1692 } 1704 }
1693#endif /* 0 */
1694 } 1705 }
1695 else 1706 else
1696 { 1707 {