aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-03-01 01:47:11 +0000
committerKenichi Handa2002-03-01 01:47:11 +0000
commit5c7b02aba7f9668ed27f746265e7b0e152abaa1b (patch)
tree27c05dd5aeefac012c711dd7c0891a4761a77013 /src
parent76eb08813630dd6ebc21674ae8c820b0a926250a (diff)
downloademacs-5c7b02aba7f9668ed27f746265e7b0e152abaa1b.tar.gz
emacs-5c7b02aba7f9668ed27f746265e7b0e152abaa1b.zip
Include "character.h" instead of "charset.h".
(syntax_parent_lookup): Deleted. (Fmodify_syntax_entry): Accept a cons as CHAR. (skip_chars): Adjusted for the new multibyte form. (init_syntax_once): Call char_table_set_range instead of directly accessing the structure of a char table.
Diffstat (limited to 'src')
-rw-r--r--src/syntax.c175
1 files changed, 86 insertions, 89 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 30b9eb1f4c4..8b2c273166c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA. */
24#include "lisp.h" 24#include "lisp.h"
25#include "commands.h" 25#include "commands.h"
26#include "buffer.h" 26#include "buffer.h"
27#include "charset.h" 27#include "character.h"
28#include "keymap.h" 28#include "keymap.h"
29 29
30/* Make syntax table lookup grant data in gl_state. */ 30/* Make syntax table lookup grant data in gl_state. */
@@ -835,29 +835,6 @@ char syntax_code_spec[16] =
835static Lisp_Object Vsyntax_code_object; 835static Lisp_Object Vsyntax_code_object;
836 836
837 837
838/* Look up the value for CHARACTER in syntax table TABLE's parent
839 and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil
840 for CHARACTER. It's actually used only when not compiled with GCC. */
841
842Lisp_Object
843syntax_parent_lookup (table, character)
844 Lisp_Object table;
845 int character;
846{
847 Lisp_Object value;
848
849 while (1)
850 {
851 table = XCHAR_TABLE (table)->parent;
852 if (NILP (table))
853 return Qnil;
854
855 value = XCHAR_TABLE (table)->contents[character];
856 if (!NILP (value))
857 return value;
858 }
859}
860
861DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, 838DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0,
862 doc: /* Return the syntax code of CHARACTER, described by a character. 839 doc: /* Return the syntax code of CHARACTER, described by a character.
863For example, if CHARACTER is a word constituent, 840For example, if CHARACTER is a word constituent,
@@ -976,6 +953,8 @@ DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
976 doc: /* Set syntax for character CHAR according to string NEWENTRY. 953 doc: /* Set syntax for character CHAR according to string NEWENTRY.
977The syntax is changed only for table SYNTAX_TABLE, which defaults to 954The syntax is changed only for table SYNTAX_TABLE, which defaults to
978 the current buffer's syntax table. 955 the current buffer's syntax table.
956CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters
957in the range MIN and MAX are changed.
979The first character of NEWENTRY should be one of the following: 958The first character of NEWENTRY should be one of the following:
980 Space or - whitespace syntax. w word constituent. 959 Space or - whitespace syntax. w word constituent.
981 _ symbol constituent. . punctuation. 960 _ symbol constituent. . punctuation.
@@ -1012,14 +991,24 @@ usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */)
1012 (c, newentry, syntax_table) 991 (c, newentry, syntax_table)
1013 Lisp_Object c, newentry, syntax_table; 992 Lisp_Object c, newentry, syntax_table;
1014{ 993{
1015 CHECK_NUMBER (c); 994 if (CONSP (c))
995 {
996 CHECK_CHARACTER (XCAR (c));
997 CHECK_CHARACTER (XCDR (c));
998 }
999 else
1000 CHECK_CHARACTER (c);
1016 1001
1017 if (NILP (syntax_table)) 1002 if (NILP (syntax_table))
1018 syntax_table = current_buffer->syntax_table; 1003 syntax_table = current_buffer->syntax_table;
1019 else 1004 else
1020 check_syntax_table (syntax_table); 1005 check_syntax_table (syntax_table);
1021 1006
1022 SET_RAW_SYNTAX_ENTRY (syntax_table, XINT (c), Fstring_to_syntax (newentry)); 1007 newentry = Fstring_to_syntax (newentry);
1008 if (CONSP (c))
1009 SET_RAW_SYNTAX_ENTRY_RANGE (syntax_table, c, newentry);
1010 else
1011 SET_RAW_SYNTAX_ENTRY (syntax_table, XINT (c), newentry);
1023 return Qnil; 1012 return Qnil;
1024} 1013}
1025 1014
@@ -1418,22 +1407,21 @@ skip_chars (forwardp, syntaxp, string, lim)
1418 If syntaxp, each character counts as itself. 1407 If syntaxp, each character counts as itself.
1419 Otherwise, handle backslashes and ranges specially. */ 1408 Otherwise, handle backslashes and ranges specially. */
1420 1409
1421 while (i_byte < size_byte) 1410 if (size_byte == XSTRING (string)->size)
1422 { 1411 while (i_byte < size_byte)
1423 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte - i_byte, len); 1412 {
1424 i_byte += len; 1413 c = str[i_byte++];
1425 1414
1426 if (syntaxp) 1415 if (syntaxp)
1427 fastmap[syntax_spec_code[c & 0377]] = 1; 1416 fastmap[syntax_spec_code[c]] = 1;
1428 else 1417 else
1429 { 1418 {
1430 if (c == '\\') 1419 if (c == '\\')
1431 { 1420 {
1432 if (i_byte == size_byte) 1421 if (i_byte == size_byte)
1433 break; 1422 break;
1434 1423
1435 c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); 1424 c = str[i_byte++];
1436 i_byte += len;
1437 } 1425 }
1438 if (i_byte < size_byte 1426 if (i_byte < size_byte
1439 && str[i_byte] == '-') 1427 && str[i_byte] == '-')
@@ -1447,50 +1435,68 @@ skip_chars (forwardp, syntaxp, string, lim)
1447 break; 1435 break;
1448 1436
1449 /* Get the end of the range. */ 1437 /* Get the end of the range. */
1450 c2 =STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); 1438 c2 = str[i_byte++];
1451 i_byte += len; 1439 while (c <= c2)
1452 1440 fastmap[c++] = 1;
1453 if (SINGLE_BYTE_CHAR_P (c))
1454 {
1455 if (! SINGLE_BYTE_CHAR_P (c2))
1456 {
1457 /* Handle a range starting with a character of
1458 less than 256, and ending with a character of
1459 not less than 256. Split that into two
1460 ranges, the low one ending at 0377, and the
1461 high one starting at the smallest character
1462 in the charset of C2 and ending at C2. */
1463 int charset = CHAR_CHARSET (c2);
1464 int c1 = MAKE_CHAR (charset, 0, 0);
1465
1466 char_ranges[n_char_ranges++] = c1;
1467 char_ranges[n_char_ranges++] = c2;
1468 c2 = 0377;
1469 }
1470 while (c <= c2)
1471 {
1472 fastmap[c] = 1;
1473 c++;
1474 }
1475 }
1476 else if (c <= c2) /* Both C and C2 are multibyte char. */
1477 {
1478 char_ranges[n_char_ranges++] = c;
1479 char_ranges[n_char_ranges++] = c2;
1480 }
1481 } 1441 }
1482 else 1442 else
1483 { 1443 fastmap[c] = 1;
1484 if (SINGLE_BYTE_CHAR_P (c))
1485 fastmap[c] = 1;
1486 else
1487 {
1488 char_ranges[n_char_ranges++] = c;
1489 char_ranges[n_char_ranges++] = c;
1490 }
1491 }
1492 } 1444 }
1493 } 1445 }
1446 else
1447 while (i_byte < size_byte)
1448 {
1449 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1450 i_byte += len;
1451
1452 if (syntaxp)
1453 fastmap[syntax_spec_code[c & 0377]] = 1;
1454 else
1455 {
1456 if (c == '\\')
1457 {
1458 if (i_byte == size_byte)
1459 break;
1460
1461 c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len);
1462 i_byte += len;
1463 }
1464 if (i_byte < size_byte
1465 && str[i_byte] == '-')
1466 {
1467 unsigned int c2;
1468
1469 /* Skip over the dash. */
1470 i_byte++;
1471
1472 if (i_byte == size_byte)
1473 break;
1474
1475 /* Get the end of the range. */
1476 c2 =STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1477 i_byte += len;
1478
1479 if (ASCII_CHAR_P (c))
1480 while (c <= c2 && c < 0x80)
1481 fastmap[c++] = 1;
1482 if (c <= c2)
1483 {
1484 char_ranges[n_char_ranges++] = c;
1485 char_ranges[n_char_ranges++] = c2;
1486 }
1487 }
1488 else
1489 {
1490 if (ASCII_CHAR_P (c))
1491 fastmap[c] = 1;
1492 else
1493 {
1494 char_ranges[n_char_ranges++] = c;
1495 char_ranges[n_char_ranges++] = c;
1496 }
1497 }
1498 }
1499 }
1494 1500
1495 /* If ^ was the first character, complement the fastmap. */ 1501 /* If ^ was the first character, complement the fastmap. */
1496 if (negate) 1502 if (negate)
@@ -1573,7 +1579,7 @@ skip_chars (forwardp, syntaxp, string, lim)
1573 while (pos < XINT (lim)) 1579 while (pos < XINT (lim))
1574 { 1580 {
1575 c = FETCH_MULTIBYTE_CHAR (pos_byte); 1581 c = FETCH_MULTIBYTE_CHAR (pos_byte);
1576 if (SINGLE_BYTE_CHAR_P (c)) 1582 if (ASCII_CHAR_P (c))
1577 { 1583 {
1578 if (!fastmap[c]) 1584 if (!fastmap[c])
1579 break; 1585 break;
@@ -1633,14 +1639,6 @@ skip_chars (forwardp, syntaxp, string, lim)
1633 } 1639 }
1634 } 1640 }
1635 1641
1636#if 0 /* Not needed now that a position in mid-character
1637 cannot be specified in Lisp. */
1638 if (multibyte
1639 /* INC_POS or DEC_POS might have moved POS over LIM. */
1640 && (forwardp ? (pos > XINT (lim)) : (pos < XINT (lim))))
1641 pos = XINT (lim);
1642#endif
1643
1644 if (! multibyte) 1642 if (! multibyte)
1645 pos_byte = pos; 1643 pos_byte = pos;
1646 1644
@@ -2945,8 +2943,7 @@ init_syntax_once ()
2945 2943
2946 /* All multibyte characters have syntax `word' by default. */ 2944 /* All multibyte characters have syntax `word' by default. */
2947 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword]; 2945 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword];
2948 for (i = CHAR_TABLE_SINGLE_BYTE_SLOTS; i < CHAR_TABLE_ORDINARY_SLOTS; i++) 2946 char_table_set_range (Vstandard_syntax_table, 0x80, MAX_CHAR, temp);
2949 XCHAR_TABLE (Vstandard_syntax_table)->contents[i] = temp;
2950} 2947}
2951 2948
2952void 2949void