aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-11-10 00:24:40 +0000
committerKenichi Handa1998-11-10 00:24:40 +0000
commitde54b0d5ecbfdc1f0ba37e2148d65ff7a6dd22aa (patch)
treeff207192e7f9a95c2e7f26ed73bafee311967b7b
parentcf36cf3f21f3bd63035967a11a33e5eb0691f9af (diff)
downloademacs-de54b0d5ecbfdc1f0ba37e2148d65ff7a6dd22aa.tar.gz
emacs-de54b0d5ecbfdc1f0ba37e2148d65ff7a6dd22aa.zip
(cmpchar_component): New arg NOERROR. Check
composition char ID more strictly. (Fcmpchar_component): Call cmpchar_component with NOERROR arg zero. (Fcmpchar_cmp_rule): If CHARACTER should be composed relatively, return 255. (Fcompose_string): Signal error if STR contains a rule-based composition character.
-rw-r--r--src/charset.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/charset.c b/src/charset.c
index a65de79c8a6..41b90189f1d 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1597,16 +1597,27 @@ str_cmpchar_id (str, len)
1597 return n_cmpchars++; 1597 return n_cmpchars++;
1598} 1598}
1599 1599
1600/* Return the Nth element of the composite character C. */ 1600/* Return the Nth element of the composite character C. If NOERROR is
1601 nonzero, return 0 on error condition (C is an invalid composite
1602 charcter, or N is out of range). */
1601int 1603int
1602cmpchar_component (c, n) 1604cmpchar_component (c, n, noerror)
1603 unsigned int c, n; 1605 int c, n, noerror;
1604{ 1606{
1605 int id = COMPOSITE_CHAR_ID (c); 1607 int id = COMPOSITE_CHAR_ID (c);
1606 1608
1607 if (id >= n_cmpchars /* C is not a valid composite character. */ 1609 if (id < 0 || id >= n_cmpchars)
1608 || n >= cmpchar_table[id]->glyph_len) /* No such component. */ 1610 {
1609 return -1; 1611 /* C is not a valid composite character. */
1612 if (noerror) return 0;
1613 error ("Invalid composite character: %d", c) ;
1614 }
1615 if (n >= cmpchar_table[id]->glyph_len)
1616 {
1617 /* No such component. */
1618 if (noerror) return 0;
1619 args_out_of_range (make_number (c), make_number (n));
1620 }
1610 /* No face data is stored in glyph code. */ 1621 /* No face data is stored in glyph code. */
1611 return ((int) (cmpchar_table[id]->glyph[n])); 1622 return ((int) (cmpchar_table[id]->glyph[n]));
1612} 1623}
@@ -1622,30 +1633,28 @@ DEFUN ("cmpcharp", Fcmpcharp, Scmpcharp, 1, 1, 0,
1622 1633
1623DEFUN ("composite-char-component", Fcmpchar_component, Scmpchar_component, 1634DEFUN ("composite-char-component", Fcmpchar_component, Scmpchar_component,
1624 2, 2, 0, 1635 2, 2, 0,
1625 "Return the IDXth component character of composite character CHARACTER.") 1636 "Return the Nth component character of composite character CHARACTER.")
1626 (character, idx) 1637 (character, n)
1627 Lisp_Object character, idx; 1638 Lisp_Object character, n;
1628{ 1639{
1629 int c; 1640 int id;
1630 1641
1631 CHECK_NUMBER (character, 0); 1642 CHECK_NUMBER (character, 0);
1632 CHECK_NUMBER (idx, 1); 1643 CHECK_NUMBER (n, 1);
1633
1634 if ((c = cmpchar_component (XINT (character), XINT (idx))) < 0)
1635 args_out_of_range (character, idx);
1636 1644
1637 return make_number (c); 1645 return (make_number (cmpchar_component (XINT (character), XINT (n), 0)));
1638} 1646}
1639 1647
1640DEFUN ("composite-char-composition-rule", Fcmpchar_cmp_rule, Scmpchar_cmp_rule, 1648DEFUN ("composite-char-composition-rule", Fcmpchar_cmp_rule, Scmpchar_cmp_rule,
1641 2, 2, 0, 1649 2, 2, 0,
1642 "Return the Nth composition rule embedded in composite character CHARACTER.\n\ 1650 "Return the Nth composition rule of composite character CHARACTER.\n\
1643The returned rule is for composing the Nth component\n\ 1651The returned rule is for composing the Nth component\n\
1644on the (N-1)th component. If N is 0, the returned value is always 255.") 1652on the (N-1)th component.\n\
1653If CHARACTER should be composed relatively or N is 0, return 255.")
1645 (character, n) 1654 (character, n)
1646 Lisp_Object character, n; 1655 Lisp_Object character, n;
1647{ 1656{
1648 int id, i; 1657 int id;
1649 1658
1650 CHECK_NUMBER (character, 0); 1659 CHECK_NUMBER (character, 0);
1651 CHECK_NUMBER (n, 1); 1660 CHECK_NUMBER (n, 1);
@@ -1653,11 +1662,12 @@ on the (N-1)th component. If N is 0, the returned value is always 255.")
1653 id = COMPOSITE_CHAR_ID (XINT (character)); 1662 id = COMPOSITE_CHAR_ID (XINT (character));
1654 if (id < 0 || id >= n_cmpchars) 1663 if (id < 0 || id >= n_cmpchars)
1655 error ("Invalid composite character: %d", XINT (character)); 1664 error ("Invalid composite character: %d", XINT (character));
1656 i = XINT (n); 1665 if (XINT (n) < 0 || XINT (n) >= cmpchar_table[id]->glyph_len)
1657 if (i > cmpchar_table[id]->glyph_len)
1658 args_out_of_range (character, n); 1666 args_out_of_range (character, n);
1659 1667
1660 return make_number (cmpchar_table[id]->cmp_rule[i]); 1668 return make_number (cmpchar_table[id]->cmp_rule
1669 ? cmpchar_table[id]->cmp_rule[XINT (n)]
1670 : 255);
1661} 1671}
1662 1672
1663DEFUN ("composite-char-composition-rule-p", Fcmpchar_cmp_rule_p, 1673DEFUN ("composite-char-composition-rule-p", Fcmpchar_cmp_rule_p,
@@ -1726,6 +1736,8 @@ DEFUN ("compose-string", Fcompose_string, Scompose_string,
1726 LEADING_CODE_COMPOSITION, keep the remaining bytes 1736 LEADING_CODE_COMPOSITION, keep the remaining bytes
1727 unchanged. */ 1737 unchanged. */
1728 p++; 1738 p++;
1739 if (*p == 255)
1740 error ("Can't compose a rule-based composition character");
1729 ptemp = p; 1741 ptemp = p;
1730 while (! CHAR_HEAD_P (*p)) p++; 1742 while (! CHAR_HEAD_P (*p)) p++;
1731 if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM) 1743 if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM)