Mercurial > hg > xemacs-beta
comparison src/chartab.c @ 181:bfd6434d15b3 r20-3b17
Import from CVS: tag r20-3b17
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:53:19 +0200 |
parents | fe104dbd9147 |
children | e121b013d1f0 |
comparison
equal
deleted
inserted
replaced
180:add28d59e586 | 181:bfd6434d15b3 |
---|---|
465 `valid-char-table-type-p', `char-table-type-list', `valid-char-table-value-p', | 465 `valid-char-table-type-p', `char-table-type-list', `valid-char-table-value-p', |
466 and `check-char-table-value'. | 466 and `check-char-table-value'. |
467 */ | 467 */ |
468 (object)) | 468 (object)) |
469 { | 469 { |
470 return (CHAR_TABLEP (object) ? Qt : Qnil); | 470 return CHAR_TABLEP (object) ? Qt : Qnil; |
471 } | 471 } |
472 | 472 |
473 DEFUN ("char-table-type-list", Fchar_table_type_list, 0, 0, 0, /* | 473 DEFUN ("char-table-type-list", Fchar_table_type_list, 0, 0, 0, /* |
474 Return a list of the recognized char table types. | 474 Return a list of the recognized char table types. |
475 See `valid-char-table-type-p'. | 475 See `valid-char-table-type-p'. |
511 working with syntax tables. The valid values are integers. | 511 working with syntax tables. The valid values are integers. |
512 | 512 |
513 */ | 513 */ |
514 (type)) | 514 (type)) |
515 { | 515 { |
516 if (EQ (type, Qchar) | 516 return (EQ (type, Qchar) || |
517 #ifdef MULE | 517 #ifdef MULE |
518 || EQ (type, Qcategory) | 518 EQ (type, Qcategory) || |
519 #endif | 519 #endif |
520 || EQ (type, Qdisplay) | 520 EQ (type, Qdisplay) || |
521 || EQ (type, Qgeneric) | 521 EQ (type, Qgeneric) || |
522 || EQ (type, Qsyntax)) | 522 EQ (type, Qsyntax)) ? Qt : Qnil; |
523 return Qt; | |
524 | |
525 return Qnil; | |
526 } | 523 } |
527 | 524 |
528 DEFUN ("char-table-type", Fchar_table_type, 1, 1, 0, /* | 525 DEFUN ("char-table-type", Fchar_table_type, 1, 1, 0, /* |
529 Return the type of char table TABLE. | 526 Return the type of char table TABLE. |
530 See `valid-char-table-type-p'. | 527 See `valid-char-table-type-p'. |
840 CHECK_CHAR_TABLE (table); | 837 CHECK_CHAR_TABLE (table); |
841 ct = XCHAR_TABLE (table); | 838 ct = XCHAR_TABLE (table); |
842 CHECK_CHAR_COERCE_INT (ch); | 839 CHECK_CHAR_COERCE_INT (ch); |
843 chr = XCHAR(ch); | 840 chr = XCHAR(ch); |
844 | 841 |
845 return (get_char_table (chr, ct)); | 842 return get_char_table (chr, ct); |
846 } | 843 } |
847 | 844 |
848 DEFUN ("get-range-char-table", Fget_range_char_table, 2, 3, 0, /* | 845 DEFUN ("get-range-char-table", Fget_range_char_table, 2, 3, 0, /* |
849 Find value for a range in TABLE. | 846 Find value for a range in TABLE. |
850 If there is more than one value, return MULTI (defaults to nil). | 847 If there is more than one value, return MULTI (defaults to nil). |
1272 map_over_other_charset (struct Lisp_Char_Table *ct, int lb, | 1269 map_over_other_charset (struct Lisp_Char_Table *ct, int lb, |
1273 int (*fn) (struct chartab_range *range, | 1270 int (*fn) (struct chartab_range *range, |
1274 Lisp_Object val, void *arg), | 1271 Lisp_Object val, void *arg), |
1275 void *arg) | 1272 void *arg) |
1276 { | 1273 { |
1277 Lisp_Object charset; | 1274 Lisp_Object val = ct->level1[lb - MIN_LEADING_BYTE]; |
1278 Lisp_Object val; | 1275 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (lb); |
1279 | 1276 |
1280 val = ct->level1[lb - MIN_LEADING_BYTE]; | 1277 if (!CHARSETP (charset) |
1281 | 1278 || lb == LEADING_BYTE_ASCII |
1282 charset = CHARSET_BY_LEADING_BYTE (lb); | |
1283 if (!CHARSETP (charset) || lb == LEADING_BYTE_ASCII | |
1284 || lb == LEADING_BYTE_CONTROL_1) | 1279 || lb == LEADING_BYTE_CONTROL_1) |
1285 return 0; | 1280 return 0; |
1281 | |
1286 if (!CHAR_TABLE_ENTRYP (val)) | 1282 if (!CHAR_TABLE_ENTRYP (val)) |
1287 { | 1283 { |
1288 struct chartab_range rainj; | 1284 struct chartab_range rainj; |
1289 | 1285 |
1290 rainj.type = CHARTAB_RANGE_CHARSET; | 1286 rainj.type = CHARTAB_RANGE_CHARSET; |
1291 rainj.charset = charset; | 1287 rainj.charset = charset; |
1292 return (fn) (&rainj, val, arg); | 1288 return (fn) (&rainj, val, arg); |
1293 } | 1289 } |
1294 else if (XCHARSET_DIMENSION (charset) == 1) | 1290 |
1295 { | 1291 { |
1296 int i; | 1292 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); |
1297 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); | 1293 int charset94_p = (XCHARSET_CHARS (charset) == 94); |
1298 int start, stop; | 1294 int start = charset94_p ? 33 : 32; |
1299 | 1295 int stop = charset94_p ? 127 : 128; |
1300 if (XCHARSET_CHARS (charset) == 94) | 1296 int i, retval; |
1301 { | 1297 |
1302 start = 33; | 1298 if (XCHARSET_DIMENSION (charset) == 1) |
1303 stop = 127; | |
1304 } | |
1305 else | |
1306 { | |
1307 start = 32; | |
1308 stop = 128; | |
1309 } | |
1310 | |
1311 for (i = start; i < stop; i++) | 1299 for (i = start; i < stop; i++) |
1312 { | 1300 { |
1313 int retval; | |
1314 struct chartab_range rainj; | 1301 struct chartab_range rainj; |
1315 | 1302 |
1316 rainj.type = CHARTAB_RANGE_CHAR; | 1303 rainj.type = CHARTAB_RANGE_CHAR; |
1317 rainj.ch = MAKE_CHAR (charset, i, 0); | 1304 rainj.ch = MAKE_CHAR (charset, i, 0); |
1318 retval = (fn) (&rainj, cte->level2[i - 32], arg); | 1305 retval = (fn) (&rainj, cte->level2[i - 32], arg); |
1319 if (retval) | 1306 if (retval) |
1320 return retval; | 1307 return retval; |
1321 } | 1308 } |
1322 } | 1309 else |
1323 else | |
1324 { | |
1325 int i; | |
1326 struct Lisp_Char_Table_Entry *cte = XCHAR_TABLE_ENTRY (val); | |
1327 int start, stop; | |
1328 | |
1329 if (XCHARSET_CHARS (charset) == 94) | |
1330 { | |
1331 start = 33; | |
1332 stop = 127; | |
1333 } | |
1334 else | |
1335 { | |
1336 start = 32; | |
1337 stop = 128; | |
1338 } | |
1339 | |
1340 for (i = start; i < stop; i++) | 1310 for (i = start; i < stop; i++) |
1341 { | 1311 { |
1342 int retval = | 1312 retval = map_over_charset_row (cte, charset, i, fn, arg); |
1343 map_over_charset_row (cte, charset, i, fn, arg); | |
1344 if (retval) | 1313 if (retval) |
1345 return retval; | 1314 return retval; |
1346 } | 1315 } |
1347 } | 1316 } |
1348 | 1317 |
1349 return 0; | 1318 return 0; |
1350 } | 1319 } |
1351 | 1320 |
1352 #endif /* MULE */ | 1321 #endif /* MULE */ |
1383 retval = map_over_other_charset (ct, i, fn, arg); | 1352 retval = map_over_other_charset (ct, i, fn, arg); |
1384 if (retval) | 1353 if (retval) |
1385 return retval; | 1354 return retval; |
1386 } | 1355 } |
1387 } | 1356 } |
1388 #endif | 1357 #endif /* MULE */ |
1389 } | 1358 } |
1390 break; | 1359 break; |
1391 | 1360 |
1392 #ifdef MULE | 1361 #ifdef MULE |
1393 case CHARTAB_RANGE_CHARSET: | 1362 case CHARTAB_RANGE_CHARSET: |
1659 ctbl = XCHAR_TABLE(table); | 1628 ctbl = XCHAR_TABLE(table); |
1660 temp = get_char_table(ch, ctbl); | 1629 temp = get_char_table(ch, ctbl); |
1661 if (EQ (temp, Qnil)) return not; | 1630 if (EQ (temp, Qnil)) return not; |
1662 | 1631 |
1663 designator -= ' '; | 1632 designator -= ' '; |
1664 return (bit_vector_bit(XBIT_VECTOR (temp), designator) ? !not : not); | 1633 return bit_vector_bit(XBIT_VECTOR (temp), designator) ? !not : not; |
1665 } | 1634 } |
1666 | 1635 |
1667 DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /* | 1636 DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /* |
1668 Return t if category of a character at POS includes DESIGNATOR, | 1637 Return t if category of a character at POS includes DESIGNATOR, |
1669 else return nil. Optional third arg specifies which buffer | 1638 else return nil. Optional third arg specifies which buffer |
1680 CHECK_INT (pos); | 1649 CHECK_INT (pos); |
1681 CHECK_CATEGORY_DESIGNATOR (designator); | 1650 CHECK_CATEGORY_DESIGNATOR (designator); |
1682 des = XREALINT(designator); | 1651 des = XREALINT(designator); |
1683 ctbl = check_category_table (category_table, Vstandard_category_table); | 1652 ctbl = check_category_table (category_table, Vstandard_category_table); |
1684 ch = BUF_FETCH_CHAR (buf, XINT(pos)); | 1653 ch = BUF_FETCH_CHAR (buf, XINT(pos)); |
1685 return (check_category_char(ch, ctbl, des, 0) | 1654 return check_category_char(ch, ctbl, des, 0) ? Qt : Qnil; |
1686 ? Qt : Qnil); | |
1687 } | 1655 } |
1688 | 1656 |
1689 DEFUN ("char-in-category-p", Fchar_in_category_p, 2, 3, 0, /* | 1657 DEFUN ("char-in-category-p", Fchar_in_category_p, 2, 3, 0, /* |
1690 Return t if category of character CHR includes DESIGNATOR, else | 1658 Return t if category of character CHR includes DESIGNATOR, else |
1691 return nil. Optional third arg specifies the CATEGORY-TABLE to use, | 1659 return nil. Optional third arg specifies the CATEGORY-TABLE to use, |
1701 CHECK_CATEGORY_DESIGNATOR (designator); | 1669 CHECK_CATEGORY_DESIGNATOR (designator); |
1702 des = XREALINT(designator); | 1670 des = XREALINT(designator); |
1703 CHECK_CHAR(chr); | 1671 CHECK_CHAR(chr); |
1704 ch = XCHAR(chr); | 1672 ch = XCHAR(chr); |
1705 ctbl = check_category_table (category_table, Vstandard_category_table); | 1673 ctbl = check_category_table (category_table, Vstandard_category_table); |
1706 return (check_category_char(ch, ctbl, des, 0) | 1674 return check_category_char(ch, ctbl, des, 0) ? Qt : Qnil; |
1707 ? Qt : Qnil); | |
1708 } | 1675 } |
1709 | 1676 |
1710 DEFUN ("category-table", Fcategory_table, 0, 1, 0, /* | 1677 DEFUN ("category-table", Fcategory_table, 0, 1, 0, /* |
1711 Return the current category table. | 1678 Return the current category table. |
1712 This is the one specified by the current buffer, or by BUFFER if it | 1679 This is the one specified by the current buffer, or by BUFFER if it |
1757 DEFUN ("category-designator-p", Fcategory_designator_p, 1, 1, 0, /* | 1724 DEFUN ("category-designator-p", Fcategory_designator_p, 1, 1, 0, /* |
1758 Return t if ARG is a category designator (a char in the range ' ' to '~'). | 1725 Return t if ARG is a category designator (a char in the range ' ' to '~'). |
1759 */ | 1726 */ |
1760 (obj)) | 1727 (obj)) |
1761 { | 1728 { |
1762 if (CATEGORY_DESIGNATORP (obj)) | 1729 return CATEGORY_DESIGNATORP (obj) ? Qt : Qnil; |
1763 return Qt; | |
1764 return Qnil; | |
1765 } | 1730 } |
1766 | 1731 |
1767 DEFUN ("category-table-value-p", Fcategory_table_value_p, 1, 1, 0, /* | 1732 DEFUN ("category-table-value-p", Fcategory_table_value_p, 1, 1, 0, /* |
1768 Return t if ARG is a category table value. | 1733 Return t if ARG is a category table value. |
1769 Valid values are nil or a bit vector of size 95. | 1734 Valid values are nil or a bit vector of size 95. |
1770 */ | 1735 */ |
1771 (obj)) | 1736 (obj)) |
1772 { | 1737 { |
1773 if (CATEGORY_TABLE_VALUEP (obj)) | 1738 return CATEGORY_TABLE_VALUEP (obj) ? Qt : Qnil; |
1774 return Qt; | |
1775 return Qnil; | |
1776 } | 1739 } |
1777 | 1740 |
1778 #endif /* MULE */ | 1741 #endif /* MULE */ |
1779 | 1742 |
1780 | 1743 |