aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.c
diff options
context:
space:
mode:
authorKenichi Handa2010-07-08 17:09:35 +0900
committerKenichi Handa2010-07-08 17:09:35 +0900
commit80d4189187791916590b6c2b20b54588d432bb75 (patch)
treee59e52ee4a456f3235bff0e7fba4362681dba7dd /src/syntax.c
parenta7840ffb291e13c2a2386ccbd58089e1d7461c16 (diff)
parent0216627eb39f77958e30f4750f581714fdfd7faf (diff)
downloademacs-80d4189187791916590b6c2b20b54588d432bb75.tar.gz
emacs-80d4189187791916590b6c2b20b54588d432bb75.zip
merge trunk
Diffstat (limited to 'src/syntax.c')
-rw-r--r--src/syntax.c91
1 files changed, 34 insertions, 57 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 4741fa260d2..7f3557f8441 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -98,18 +98,18 @@ static EMACS_INT find_start_begv;
98static int find_start_modiff; 98static int find_start_modiff;
99 99
100 100
101static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int)); 101static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int);
102static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object)); 102static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object);
103static Lisp_Object scan_lists P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int)); 103static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int);
104static void scan_sexps_forward P_ ((struct lisp_parse_state *, 104static void scan_sexps_forward (struct lisp_parse_state *,
105 EMACS_INT, EMACS_INT, EMACS_INT, int, 105 EMACS_INT, EMACS_INT, EMACS_INT, int,
106 int, Lisp_Object, int)); 106 int, Lisp_Object, int);
107static int in_classes P_ ((int, Lisp_Object)); 107static int in_classes (int, Lisp_Object);
108 108
109 109
110struct gl_state_s gl_state; /* Global state of syntax parser. */ 110struct gl_state_s gl_state; /* Global state of syntax parser. */
111 111
112INTERVAL interval_of (); 112INTERVAL interval_of (int, Lisp_Object);
113#define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals 113#define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals
114 to scan to property-change. */ 114 to scan to property-change. */
115 115
@@ -127,9 +127,7 @@ INTERVAL interval_of ();
127 start/end of OBJECT. */ 127 start/end of OBJECT. */
128 128
129void 129void
130update_syntax_table (charpos, count, init, object) 130update_syntax_table (int charpos, int count, int init, Lisp_Object object)
131 int charpos, count, init;
132 Lisp_Object object;
133{ 131{
134 Lisp_Object tmp_table; 132 Lisp_Object tmp_table;
135 int cnt = 0, invalidate = 1; 133 int cnt = 0, invalidate = 1;
@@ -318,8 +316,7 @@ char_quoted (EMACS_INT charpos, EMACS_INT bytepos)
318 We assume that BYTEPOS is not at the end of the buffer. */ 316 We assume that BYTEPOS is not at the end of the buffer. */
319 317
320INLINE EMACS_INT 318INLINE EMACS_INT
321inc_bytepos (bytepos) 319inc_bytepos (EMACS_INT bytepos)
322 EMACS_INT bytepos;
323{ 320{
324 if (NILP (current_buffer->enable_multibyte_characters)) 321 if (NILP (current_buffer->enable_multibyte_characters))
325 return bytepos + 1; 322 return bytepos + 1;
@@ -332,8 +329,7 @@ inc_bytepos (bytepos)
332 We assume that BYTEPOS is not at the start of the buffer. */ 329 We assume that BYTEPOS is not at the start of the buffer. */
333 330
334INLINE EMACS_INT 331INLINE EMACS_INT
335dec_bytepos (bytepos) 332dec_bytepos (EMACS_INT bytepos)
336 EMACS_INT bytepos;
337{ 333{
338 if (NILP (current_buffer->enable_multibyte_characters)) 334 if (NILP (current_buffer->enable_multibyte_characters))
339 return bytepos - 1; 335 return bytepos - 1;
@@ -357,8 +353,7 @@ dec_bytepos (bytepos)
357 update the global data. */ 353 update the global data. */
358 354
359static EMACS_INT 355static EMACS_INT
360find_defun_start (pos, pos_byte) 356find_defun_start (EMACS_INT pos, EMACS_INT pos_byte)
361 EMACS_INT pos, pos_byte;
362{ 357{
363 EMACS_INT opoint = PT, opoint_byte = PT_BYTE; 358 EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
364 359
@@ -422,8 +417,7 @@ find_defun_start (pos, pos_byte)
422/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ 417/* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
423 418
424static int 419static int
425prev_char_comend_first (pos, pos_byte) 420prev_char_comend_first (int pos, int pos_byte)
426 int pos, pos_byte;
427{ 421{
428 int c, val; 422 int c, val;
429 423
@@ -465,10 +459,7 @@ prev_char_comend_first (pos, pos_byte)
465 the returned value (or at FROM, if the search was not successful). */ 459 the returned value (or at FROM, if the search was not successful). */
466 460
467static int 461static int
468back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_ptr) 462back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested, int comstyle, EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr)
469 EMACS_INT from, from_byte, stop;
470 int comnested, comstyle;
471 EMACS_INT *charpos_ptr, *bytepos_ptr;
472{ 463{
473 /* Look back, counting the parity of string-quotes, 464 /* Look back, counting the parity of string-quotes,
474 and recording the comment-starters seen. 465 and recording the comment-starters seen.
@@ -740,8 +731,7 @@ Currently, any char-table counts as a syntax table. */)
740} 731}
741 732
742static void 733static void
743check_syntax_table (obj) 734check_syntax_table (Lisp_Object obj)
744 Lisp_Object obj;
745{ 735{
746 CHECK_TYPE (CHAR_TABLE_P (obj) && EQ (XCHAR_TABLE (obj)->purpose, Qsyntax_table), 736 CHECK_TYPE (CHAR_TABLE_P (obj) && EQ (XCHAR_TABLE (obj)->purpose, Qsyntax_table),
747 Qsyntax_table_p, obj); 737 Qsyntax_table_p, obj);
@@ -1185,8 +1175,7 @@ Lisp_Object Vfind_word_boundary_function_table;
1185 COUNT negative means scan backward and stop at word beginning. */ 1175 COUNT negative means scan backward and stop at word beginning. */
1186 1176
1187int 1177int
1188scan_words (from, count) 1178scan_words (register int from, register int count)
1189 register int from, count;
1190{ 1179{
1191 register int beg = BEGV; 1180 register int beg = BEGV;
1192 register int end = ZV; 1181 register int end = ZV;
@@ -1342,7 +1331,7 @@ and the function returns nil. Field boundaries are not noticed if
1342 return val == orig_val ? Qt : Qnil; 1331 return val == orig_val ? Qt : Qnil;
1343} 1332}
1344 1333
1345Lisp_Object skip_chars (); 1334Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int);
1346 1335
1347DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, 1336DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0,
1348 doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM. 1337 doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM.
@@ -1395,10 +1384,7 @@ This function returns the distance traveled, either zero or negative. */)
1395} 1384}
1396 1385
1397static Lisp_Object 1386static Lisp_Object
1398skip_chars (forwardp, string, lim, handle_iso_classes) 1387skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_classes)
1399 int forwardp;
1400 Lisp_Object string, lim;
1401 int handle_iso_classes;
1402{ 1388{
1403 register unsigned int c; 1389 register unsigned int c;
1404 unsigned char fastmap[0400]; 1390 unsigned char fastmap[0400];
@@ -1436,7 +1422,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1436 && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE)); 1422 && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE));
1437 string_multibyte = SBYTES (string) > SCHARS (string); 1423 string_multibyte = SBYTES (string) > SCHARS (string);
1438 1424
1439 bzero (fastmap, sizeof fastmap); 1425 memset (fastmap, 0, sizeof fastmap);
1440 1426
1441 str = SDATA (string); 1427 str = SDATA (string);
1442 size_byte = SBYTES (string); 1428 size_byte = SBYTES (string);
@@ -1485,7 +1471,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1485 || *class_end != ':' || class_end[1] != ']') 1471 || *class_end != ':' || class_end[1] != ']')
1486 goto not_a_class_name; 1472 goto not_a_class_name;
1487 1473
1488 bcopy (class_beg, class_name, class_end - class_beg); 1474 memcpy (class_name, class_beg, class_end - class_beg);
1489 class_name[class_end - class_beg] = 0; 1475 class_name[class_end - class_beg] = 0;
1490 1476
1491 cc = re_wctype (class_name); 1477 cc = re_wctype (class_name);
@@ -1546,8 +1532,8 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1546 unsigned char fastmap2[0400]; 1532 unsigned char fastmap2[0400];
1547 int range_start_byte, range_start_char; 1533 int range_start_byte, range_start_char;
1548 1534
1549 bcopy (fastmap2 + 0200, fastmap + 0200, 0200); 1535 memcpy (fastmap + 0200, fastmap2 + 0200, 0200);
1550 bzero (fastmap + 0200, 0200); 1536 memset (fastmap + 0200, 0, 0200);
1551 /* We are sure that this loop stops. */ 1537 /* We are sure that this loop stops. */
1552 for (i = 0200; ! fastmap2[i]; i++); 1538 for (i = 0200; ! fastmap2[i]; i++);
1553 c = BYTE8_TO_CHAR (i); 1539 c = BYTE8_TO_CHAR (i);
@@ -1607,7 +1593,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1607 || *class_end != ':' || class_end[1] != ']') 1593 || *class_end != ':' || class_end[1] != ']')
1608 goto not_a_class_name_multibyte; 1594 goto not_a_class_name_multibyte;
1609 1595
1610 bcopy (class_beg, class_name, class_end - class_beg); 1596 memcpy (class_name, class_beg, class_end - class_beg);
1611 class_name[class_end - class_beg] = 0; 1597 class_name[class_end - class_beg] = 0;
1612 1598
1613 cc = re_wctype (class_name); 1599 cc = re_wctype (class_name);
@@ -1692,7 +1678,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1692 1678
1693 if (! multibyte && n_char_ranges > 0) 1679 if (! multibyte && n_char_ranges > 0)
1694 { 1680 {
1695 bzero (fastmap + 0200, 0200); 1681 memset (fastmap + 0200, 0, 0200);
1696 for (i = 0; i < n_char_ranges; i += 2) 1682 for (i = 0; i < n_char_ranges; i += 2)
1697 { 1683 {
1698 int c1 = char_ranges[i]; 1684 int c1 = char_ranges[i];
@@ -1892,9 +1878,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes)
1892 1878
1893 1879
1894static Lisp_Object 1880static Lisp_Object
1895skip_syntaxes (forwardp, string, lim) 1881skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim)
1896 int forwardp;
1897 Lisp_Object string, lim;
1898{ 1882{
1899 register unsigned int c; 1883 register unsigned int c;
1900 unsigned char fastmap[0400]; 1884 unsigned char fastmap[0400];
@@ -1923,7 +1907,7 @@ skip_syntaxes (forwardp, string, lim)
1923 multibyte = (!NILP (current_buffer->enable_multibyte_characters) 1907 multibyte = (!NILP (current_buffer->enable_multibyte_characters)
1924 && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE)); 1908 && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE));
1925 1909
1926 bzero (fastmap, sizeof fastmap); 1910 memset (fastmap, 0, sizeof fastmap);
1927 1911
1928 if (SBYTES (string) > SCHARS (string)) 1912 if (SBYTES (string) > SCHARS (string))
1929 /* As this is very rare case (syntax spec is ASCII only), don't 1913 /* As this is very rare case (syntax spec is ASCII only), don't
@@ -2067,9 +2051,7 @@ skip_syntaxes (forwardp, string, lim)
2067 integer which is its type according to re_wctype. */ 2051 integer which is its type according to re_wctype. */
2068 2052
2069static int 2053static int
2070in_classes (c, iso_classes) 2054in_classes (int c, Lisp_Object iso_classes)
2071 int c;
2072 Lisp_Object iso_classes;
2073{ 2055{
2074 int fits_class = 0; 2056 int fits_class = 0;
2075 2057
@@ -2111,12 +2093,10 @@ in_classes (c, iso_classes)
2111 remains valid for forward search starting at the returned position. */ 2093 remains valid for forward search starting at the returned position. */
2112 2094
2113static int 2095static int
2114forw_comment (from, from_byte, stop, nesting, style, prev_syntax, 2096forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop,
2115 charpos_ptr, bytepos_ptr, incomment_ptr) 2097 int nesting, int style, int prev_syntax,
2116 EMACS_INT from, from_byte, stop; 2098 EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr,
2117 int nesting, style, prev_syntax; 2099 int *incomment_ptr)
2118 EMACS_INT *charpos_ptr, *bytepos_ptr;
2119 int *incomment_ptr;
2120{ 2100{
2121 register int c, c1; 2101 register int c, c1;
2122 register enum syntaxcode code; 2102 register enum syntaxcode code;
@@ -2422,10 +2402,7 @@ between them, return t; otherwise return nil. */)
2422 ? SYNTAX (c) : Ssymbol) 2402 ? SYNTAX (c) : Ssymbol)
2423 2403
2424static Lisp_Object 2404static Lisp_Object
2425scan_lists (from, count, depth, sexpflag) 2405scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpflag)
2426 register EMACS_INT from;
2427 EMACS_INT count, depth;
2428 int sexpflag;
2429{ 2406{
2430 Lisp_Object val; 2407 Lisp_Object val;
2431 register EMACS_INT stop = count > 0 ? ZV : BEGV; 2408 register EMACS_INT stop = count > 0 ? ZV : BEGV;
@@ -3324,7 +3301,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
3324} 3301}
3325 3302
3326void 3303void
3327init_syntax_once () 3304init_syntax_once (void)
3328{ 3305{
3329 register int i, c; 3306 register int i, c;
3330 Lisp_Object temp; 3307 Lisp_Object temp;
@@ -3414,7 +3391,7 @@ init_syntax_once ()
3414} 3391}
3415 3392
3416void 3393void
3417syms_of_syntax () 3394syms_of_syntax (void)
3418{ 3395{
3419 Qsyntax_table_p = intern_c_string ("syntax-table-p"); 3396 Qsyntax_table_p = intern_c_string ("syntax-table-p");
3420 staticpro (&Qsyntax_table_p); 3397 staticpro (&Qsyntax_table_p);