comparison src/syntax.c @ 89943:4c90ffeb71c5

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 28 Jun 2004 07:56:49 +0000
parents 68c22ea6027c 6725db0f57d5
children d8411455de48
comparison
equal deleted inserted replaced
89942:9cb747ae49af 89943:4c90ffeb71c5
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 "character.h" 27 #include "character.h"
28 #include "keymap.h" 28 #include "keymap.h"
29 #include "regex.h"
29 30
30 /* Make syntax table lookup grant data in gl_state. */ 31 /* Make syntax table lookup grant data in gl_state. */
31 #define SYNTAX_ENTRY_VIA_PROPERTY 32 #define SYNTAX_ENTRY_VIA_PROPERTY
32 33
33 #include "syntax.h" 34 #include "syntax.h"
95 96
96 97
97 static int find_defun_start P_ ((int, int)); 98 static int find_defun_start P_ ((int, int));
98 static int back_comment P_ ((int, int, int, int, int, int *, int *)); 99 static int back_comment P_ ((int, int, int, int, int, int *, int *));
99 static int char_quoted P_ ((int, int)); 100 static int char_quoted P_ ((int, int));
100 static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object)); 101 static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int));
101 static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object)); 102 static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object));
102 static Lisp_Object scan_lists P_ ((int, int, int, int)); 103 static Lisp_Object scan_lists P_ ((int, int, int, int));
103 static void scan_sexps_forward P_ ((struct lisp_parse_state *, 104 static void scan_sexps_forward P_ ((struct lisp_parse_state *,
104 int, int, int, int, 105 int, int, int, int,
105 int, Lisp_Object, int)); 106 int, Lisp_Object, int));
107 static int in_classes P_ ((int, Lisp_Object));
106 108
107 109
108 struct gl_state_s gl_state; /* Global state of syntax parser. */ 110 struct gl_state_s gl_state; /* Global state of syntax parser. */
109 111
110 INTERVAL interval_of (); 112 INTERVAL interval_of ();
291 293
292 DEC_BOTH (charpos, bytepos); 294 DEC_BOTH (charpos, bytepos);
293 295
294 while (bytepos >= beg) 296 while (bytepos >= beg)
295 { 297 {
298 int c;
299
296 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); 300 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
297 code = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (bytepos)); 301 c = FETCH_CHAR_AS_MULTIBYTE (bytepos);
302 code = SYNTAX (c);
298 if (! (code == Scharquote || code == Sescape)) 303 if (! (code == Scharquote || code == Sescape))
299 break; 304 break;
300 305
301 DEC_BOTH (charpos, bytepos); 306 DEC_BOTH (charpos, bytepos);
302 quoted = !quoted; 307 quoted = !quoted;
379 syntax-tables. */ 384 syntax-tables. */
380 gl_state.current_syntax_table = current_buffer->syntax_table; 385 gl_state.current_syntax_table = current_buffer->syntax_table;
381 gl_state.use_global = 0; 386 gl_state.use_global = 0;
382 while (PT > BEGV) 387 while (PT > BEGV)
383 { 388 {
389 int c;
390
384 /* Open-paren at start of line means we may have found our 391 /* Open-paren at start of line means we may have found our
385 defun-start. */ 392 defun-start. */
386 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 393 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
394 if (SYNTAX (c) == Sopen)
387 { 395 {
388 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ 396 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */
389 if (SYNTAX (FETCH_CHAR_AS_MULTIBYTE (PT_BYTE)) == Sopen) 397 c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE);
398 if (SYNTAX (c) == Sopen)
390 break; 399 break;
391 /* Now fallback to the default value. */ 400 /* Now fallback to the default value. */
392 gl_state.current_syntax_table = current_buffer->syntax_table; 401 gl_state.current_syntax_table = current_buffer->syntax_table;
393 gl_state.use_global = 0; 402 gl_state.use_global = 0;
394 } 403 }
953 /* I really don't know why this is interactive 962 /* I really don't know why this is interactive
954 help-form should at least be made useful whilst reading the second arg. */ 963 help-form should at least be made useful whilst reading the second arg. */
955 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, 964 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
956 "cSet syntax for character: \nsSet syntax for %s to: ", 965 "cSet syntax for character: \nsSet syntax for %s to: ",
957 doc: /* Set syntax for character CHAR according to string NEWENTRY. 966 doc: /* Set syntax for character CHAR according to string NEWENTRY.
958 The syntax is changed only for table SYNTAX_TABLE, which defaults to 967 The syntax is changed only for table SYNTAX-TABLE, which defaults to
959 the current buffer's syntax table. 968 the current buffer's syntax table.
960 CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters 969 CHAR may be a cons (MIN . MAX), in which case, syntaxes of all characters
961 in the range MIN and MAX are changed. 970 in the range MIN and MAX are changed.
962 The first character of NEWENTRY should be one of the following: 971 The first character of NEWENTRY should be one of the following:
963 Space or - whitespace syntax. w word constituent. 972 Space or - whitespace syntax. w word constituent.
1337 STRING is like the inside of a `[...]' in a regular expression 1346 STRING is like the inside of a `[...]' in a regular expression
1338 except that `]' is never special and `\\' quotes `^', `-' or `\\' 1347 except that `]' is never special and `\\' quotes `^', `-' or `\\'
1339 (but not as the end of a range; quoting is never needed there). 1348 (but not as the end of a range; quoting is never needed there).
1340 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter. 1349 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
1341 With arg "^a-zA-Z", skips nonletters stopping before first letter. 1350 With arg "^a-zA-Z", skips nonletters stopping before first letter.
1342 Returns the distance traveled, either zero or positive. 1351 Char classes, e.g. `[:alpha:]', are supported.
1343 Note that char classes, e.g. `[:alpha:]', are not currently supported; 1352
1344 they will be treated as literals. */) 1353 Returns the distance traveled, either zero or positive. */)
1345 (string, lim) 1354 (string, lim)
1346 Lisp_Object string, lim; 1355 Lisp_Object string, lim;
1347 { 1356 {
1348 return skip_chars (1, string, lim); 1357 return skip_chars (1, string, lim, 1);
1349 } 1358 }
1350 1359
1351 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, 1360 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0,
1352 doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM. 1361 doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM.
1353 See `skip-chars-forward' for details. 1362 See `skip-chars-forward' for details.
1354 Returns the distance traveled, either zero or negative. */) 1363 Returns the distance traveled, either zero or negative. */)
1355 (string, lim) 1364 (string, lim)
1356 Lisp_Object string, lim; 1365 Lisp_Object string, lim;
1357 { 1366 {
1358 return skip_chars (0, string, lim); 1367 return skip_chars (0, string, lim, 1);
1359 } 1368 }
1360 1369
1361 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, 1370 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0,
1362 doc: /* Move point forward across chars in specified syntax classes. 1371 doc: /* Move point forward across chars in specified syntax classes.
1363 SYNTAX is a string of syntax code characters. 1372 SYNTAX is a string of syntax code characters.
1381 { 1390 {
1382 return skip_syntaxes (0, syntax, lim); 1391 return skip_syntaxes (0, syntax, lim);
1383 } 1392 }
1384 1393
1385 static Lisp_Object 1394 static Lisp_Object
1386 skip_chars (forwardp, string, lim) 1395 skip_chars (forwardp, string, lim, handle_iso_classes)
1387 int forwardp; 1396 int forwardp;
1388 Lisp_Object string, lim; 1397 Lisp_Object string, lim;
1398 int handle_iso_classes;
1389 { 1399 {
1390 register unsigned int c; 1400 register unsigned int c;
1391 unsigned char fastmap[0400]; 1401 unsigned char fastmap[0400];
1392 /* Store the ranges of non-ASCII characters. */ 1402 /* Store the ranges of non-ASCII characters. */
1393 int *char_ranges; 1403 int *char_ranges;
1401 chars. */ 1411 chars. */
1402 int string_multibyte; 1412 int string_multibyte;
1403 int size_byte; 1413 int size_byte;
1404 const unsigned char *str; 1414 const unsigned char *str;
1405 int len; 1415 int len;
1416 Lisp_Object iso_classes;
1406 1417
1407 CHECK_STRING (string); 1418 CHECK_STRING (string);
1419 iso_classes = Qnil;
1408 1420
1409 if (NILP (lim)) 1421 if (NILP (lim))
1410 XSETINT (lim, forwardp ? ZV : BEGV); 1422 XSETINT (lim, forwardp ? ZV : BEGV);
1411 else 1423 else
1412 CHECK_NUMBER_COERCE_MARKER (lim); 1424 CHECK_NUMBER_COERCE_MARKER (lim);
1446 /* At first setup fastmap. */ 1458 /* At first setup fastmap. */
1447 while (i_byte < size_byte) 1459 while (i_byte < size_byte)
1448 { 1460 {
1449 c = str[i_byte++]; 1461 c = str[i_byte++];
1450 1462
1463 if (handle_iso_classes && c == '['
1464 && i_byte < size_byte
1465 && str[i_byte] == ':')
1466 {
1467 const unsigned char *class_beg = str + i_byte + 1;
1468 const unsigned char *class_end = class_beg;
1469 const unsigned char *class_limit = str + size_byte - 2;
1470 /* Leave room for the null. */
1471 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1472 re_wctype_t cc;
1473
1474 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1475 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1476
1477 while (class_end < class_limit
1478 && *class_end >= 'a' && *class_end <= 'z')
1479 class_end++;
1480
1481 if (class_end == class_beg
1482 || *class_end != ':' || class_end[1] != ']')
1483 goto not_a_class_name;
1484
1485 bcopy (class_beg, class_name, class_end - class_beg);
1486 class_name[class_end - class_beg] = 0;
1487
1488 cc = re_wctype (class_name);
1489 if (cc == 0)
1490 error ("Invalid ISO C character class");
1491
1492 iso_classes = Fcons (make_number (cc), iso_classes);
1493
1494 i_byte = class_end + 2 - str;
1495 continue;
1496 }
1497
1498 not_a_class_name:
1451 if (c == '\\') 1499 if (c == '\\')
1452 { 1500 {
1453 if (i_byte == size_byte) 1501 if (i_byte == size_byte)
1454 break; 1502 break;
1455 1503
1532 1580
1533 leading_code = str[i_byte]; 1581 leading_code = str[i_byte];
1534 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len); 1582 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte-i_byte, len);
1535 i_byte += len; 1583 i_byte += len;
1536 1584
1585 if (handle_iso_classes && c == '['
1586 && i_byte < size_byte
1587 && STRING_CHAR (str + i_byte, size_byte - i_byte) == ':')
1588 {
1589 const unsigned char *class_beg = str + i_byte + 1;
1590 const unsigned char *class_end = class_beg;
1591 const unsigned char *class_limit = str + size_byte - 2;
1592 /* Leave room for the null. */
1593 unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1];
1594 re_wctype_t cc;
1595
1596 if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH)
1597 class_limit = class_beg + CHAR_CLASS_MAX_LENGTH;
1598
1599 while (class_end < class_limit
1600 && *class_end >= 'a' && *class_end <= 'z')
1601 class_end++;
1602
1603 if (class_end == class_beg
1604 || *class_end != ':' || class_end[1] != ']')
1605 goto not_a_class_name_multibyte;
1606
1607 bcopy (class_beg, class_name, class_end - class_beg);
1608 class_name[class_end - class_beg] = 0;
1609
1610 cc = re_wctype (class_name);
1611 if (cc == 0)
1612 error ("Invalid ISO C character class");
1613
1614 iso_classes = Fcons (make_number (cc), iso_classes);
1615
1616 i_byte = class_end + 2 - str;
1617 continue;
1618 }
1619
1620 not_a_class_name_multibyte:
1537 if (c == '\\') 1621 if (c == '\\')
1538 { 1622 {
1539 if (i_byte == size_byte) 1623 if (i_byte == size_byte)
1540 break; 1624 break;
1541 1625
1641 int pos_byte = PT_BYTE; 1725 int pos_byte = PT_BYTE;
1642 unsigned char *p = PT_ADDR, *endp, *stop; 1726 unsigned char *p = PT_ADDR, *endp, *stop;
1643 1727
1644 if (forwardp) 1728 if (forwardp)
1645 { 1729 {
1646 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); 1730 endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
1647 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp; 1731 stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp;
1648 } 1732 }
1649 else 1733 else
1650 { 1734 {
1651 endp = CHAR_POS_ADDR (XINT (lim)); 1735 endp = CHAR_POS_ADDR (XINT (lim));
1652 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1736 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1653 } 1737 }
1654 1738
1655 immediate_quit = 1; 1739 immediate_quit = 1;
1656 if (forwardp) 1740 if (forwardp)
1657 { 1741 {
1665 if (p >= endp) 1749 if (p >= endp)
1666 break; 1750 break;
1667 p = GAP_END_ADDR; 1751 p = GAP_END_ADDR;
1668 stop = endp; 1752 stop = endp;
1669 } 1753 }
1754 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1755 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1756 {
1757 if (negate)
1758 break;
1759 else
1760 goto fwd_ok;
1761 }
1762
1670 if (! fastmap[*p]) 1763 if (! fastmap[*p])
1671 break; 1764 break;
1672 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes);
1673 if (! ASCII_CHAR_P (c)) 1765 if (! ASCII_CHAR_P (c))
1674 { 1766 {
1675 /* As we are looking at a multibyte character, we 1767 /* As we are looking at a multibyte character, we
1676 must look up the character in the table 1768 must look up the character in the table
1677 CHAR_RANGES. If there's no data in the table, 1769 CHAR_RANGES. If there's no data in the table,
1684 if (c >= char_ranges[i] && c <= char_ranges[i + 1]) 1776 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1685 break; 1777 break;
1686 if (!(negate ^ (i < n_char_ranges))) 1778 if (!(negate ^ (i < n_char_ranges)))
1687 break; 1779 break;
1688 } 1780 }
1781 fwd_ok:
1689 p += nbytes, pos++, pos_byte += nbytes; 1782 p += nbytes, pos++, pos_byte += nbytes;
1690 } 1783 }
1691 else 1784 else
1692 while (1) 1785 while (1)
1693 { 1786 {
1696 if (p >= endp) 1789 if (p >= endp)
1697 break; 1790 break;
1698 p = GAP_END_ADDR; 1791 p = GAP_END_ADDR;
1699 stop = endp; 1792 stop = endp;
1700 } 1793 }
1794
1795 if (!NILP (iso_classes) && in_classes (*p, iso_classes))
1796 {
1797 if (negate)
1798 break;
1799 else
1800 goto fwd_unibyte_ok;
1801 }
1802
1701 if (!fastmap[*p]) 1803 if (!fastmap[*p])
1702 break; 1804 break;
1805 fwd_unibyte_ok:
1703 p++, pos++, pos_byte++; 1806 p++, pos++, pos_byte++;
1704 } 1807 }
1705 } 1808 }
1706 else 1809 else
1707 { 1810 {
1717 p = GPT_ADDR; 1820 p = GPT_ADDR;
1718 stop = endp; 1821 stop = endp;
1719 } 1822 }
1720 prev_p = p; 1823 prev_p = p;
1721 while (--p >= stop && ! CHAR_HEAD_P (*p)); 1824 while (--p >= stop && ! CHAR_HEAD_P (*p));
1825 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1826
1827 if (! NILP (iso_classes) && in_classes (c, iso_classes))
1828 {
1829 if (negate)
1830 break;
1831 else
1832 goto back_ok;
1833 }
1834
1722 if (! fastmap[*p]) 1835 if (! fastmap[*p])
1723 break; 1836 break;
1724 c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH);
1725 if (! ASCII_CHAR_P (c)) 1837 if (! ASCII_CHAR_P (c))
1726 { 1838 {
1727 /* See the comment in the previous similar code. */ 1839 /* See the comment in the previous similar code. */
1728 for (i = 0; i < n_char_ranges; i += 2) 1840 for (i = 0; i < n_char_ranges; i += 2)
1729 if (c >= char_ranges[i] && c <= char_ranges[i + 1]) 1841 if (c >= char_ranges[i] && c <= char_ranges[i + 1])
1730 break; 1842 break;
1731 if (!(negate ^ (i < n_char_ranges))) 1843 if (!(negate ^ (i < n_char_ranges)))
1732 break; 1844 break;
1733 } 1845 }
1846 back_ok:
1734 pos--, pos_byte -= prev_p - p; 1847 pos--, pos_byte -= prev_p - p;
1735 } 1848 }
1736 else 1849 else
1737 while (1) 1850 while (1)
1738 { 1851 {
1741 if (p <= endp) 1854 if (p <= endp)
1742 break; 1855 break;
1743 p = GPT_ADDR; 1856 p = GPT_ADDR;
1744 stop = endp; 1857 stop = endp;
1745 } 1858 }
1859
1860 if (! NILP (iso_classes) && in_classes (p[-1], iso_classes))
1861 {
1862 if (negate)
1863 break;
1864 else
1865 goto back_unibyte_ok;
1866 }
1867
1746 if (!fastmap[p[-1]]) 1868 if (!fastmap[p[-1]])
1747 break; 1869 break;
1870 back_unibyte_ok:
1748 p--, pos--, pos_byte--; 1871 p--, pos--, pos_byte--;
1749 } 1872 }
1750 } 1873 }
1751 1874
1752 SET_PT_BOTH (pos, pos_byte); 1875 SET_PT_BOTH (pos, pos_byte);
1925 immediate_quit = 0; 2048 immediate_quit = 0;
1926 2049
1927 return make_number (PT - start_point); 2050 return make_number (PT - start_point);
1928 } 2051 }
1929 } 2052 }
2053
2054 /* Return 1 if character C belongs to one of the ISO classes
2055 in the list ISO_CLASSES. Each class is represented by an
2056 integer which is its type according to re_wctype. */
2057
2058 static int
2059 in_classes (c, iso_classes)
2060 int c;
2061 Lisp_Object iso_classes;
2062 {
2063 int fits_class = 0;
2064
2065 while (! NILP (iso_classes))
2066 {
2067 Lisp_Object elt;
2068 elt = XCAR (iso_classes);
2069 iso_classes = XCDR (iso_classes);
2070
2071 if (re_iswctype (c, XFASTINT (elt)))
2072 fits_class = 1;
2073 }
2074
2075 return fits_class;
2076 }
1930 2077
1931 /* Jump over a comment, assuming we are at the beginning of one. 2078 /* Jump over a comment, assuming we are at the beginning of one.
1932 FROM is the current position. 2079 FROM is the current position.
1933 FROM_BYTE is the bytepos corresponding to FROM. 2080 FROM_BYTE is the bytepos corresponding to FROM.
1934 Do not move past STOP (a charpos). 2081 Do not move past STOP (a charpos).
2308 if (depth == min_depth) 2455 if (depth == min_depth)
2309 last_good = from; 2456 last_good = from;
2310 INC_BOTH (from, from_byte); 2457 INC_BOTH (from, from_byte);
2311 UPDATE_SYNTAX_TABLE_FORWARD (from); 2458 UPDATE_SYNTAX_TABLE_FORWARD (from);
2312 if (from < stop && comstart_first 2459 if (from < stop && comstart_first
2313 && SYNTAX_COMSTART_SECOND (FETCH_CHAR_AS_MULTIBYTE (from_byte)) 2460 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte),
2461 SYNTAX_COMSTART_SECOND (c))
2314 && parse_sexp_ignore_comments) 2462 && parse_sexp_ignore_comments)
2315 { 2463 {
2316 /* we have encountered a comment start sequence and we 2464 /* we have encountered a comment start sequence and we
2317 are ignoring all text inside comments. We must record 2465 are ignoring all text inside comments. We must record
2318 the comment style this sequence begins so that later, 2466 the comment style this sequence begins so that later,
2634 lose: 2782 lose:
2635 Fsignal (Qscan_error, 2783 Fsignal (Qscan_error,
2636 Fcons (build_string ("Unbalanced parentheses"), 2784 Fcons (build_string ("Unbalanced parentheses"),
2637 Fcons (make_number (last_good), 2785 Fcons (make_number (last_good),
2638 Fcons (make_number (from), Qnil)))); 2786 Fcons (make_number (from), Qnil))));
2639 2787 abort ();
2640 /* NOTREACHED */ 2788 /* NOTREACHED */
2641 } 2789 }
2642 2790
2643 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0, 2791 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0,
2644 doc: /* Scan from character number FROM by COUNT lists. 2792 doc: /* Scan from character number FROM by COUNT lists.
2774 2922
2775 /* Use this macro instead of `from++'. */ 2923 /* Use this macro instead of `from++'. */
2776 #define INC_FROM \ 2924 #define INC_FROM \
2777 do { prev_from = from; \ 2925 do { prev_from = from; \
2778 prev_from_byte = from_byte; \ 2926 prev_from_byte = from_byte; \
2779 prev_from_syntax \ 2927 temp = FETCH_CHAR_AS_MULTIBYTE (prev_from_byte); \
2780 = SYNTAX_WITH_FLAGS (FETCH_CHAR_AS_MULTIBYTE (prev_from_byte)); \ 2928 prev_from_syntax = SYNTAX_WITH_FLAGS (temp); \
2781 INC_BOTH (from, from_byte); \ 2929 INC_BOTH (from, from_byte); \
2782 if (from < end) \ 2930 if (from < end) \
2783 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 2931 UPDATE_SYNTAX_TABLE_FORWARD (from); \
2784 } while (0) 2932 } while (0)
2785 2933
2850 2998
2851 curlevel->prev = -1; 2999 curlevel->prev = -1;
2852 curlevel->last = -1; 3000 curlevel->last = -1;
2853 3001
2854 SETUP_SYNTAX_TABLE (prev_from, 1); 3002 SETUP_SYNTAX_TABLE (prev_from, 1);
2855 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); 3003 temp = FETCH_CHAR (prev_from_byte);
3004 prev_from_syntax = SYNTAX_WITH_FLAGS (temp);
2856 UPDATE_SYNTAX_TABLE_FORWARD (from); 3005 UPDATE_SYNTAX_TABLE_FORWARD (from);
2857 3006
2858 /* Enter the loop at a place appropriate for initial state. */ 3007 /* Enter the loop at a place appropriate for initial state. */
2859 3008
2860 if (state.incomment) 3009 if (state.incomment)
2929 curlevel->last = prev_from; 3078 curlevel->last = prev_from;
2930 symstarted: 3079 symstarted:
2931 while (from < end) 3080 while (from < end)
2932 { 3081 {
2933 /* Some compilers can't handle this inside the switch. */ 3082 /* Some compilers can't handle this inside the switch. */
2934 temp = SYNTAX (FETCH_CHAR_AS_MULTIBYTE (from_byte)); 3083 temp = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3084 temp = SYNTAX (temp);
2935 switch (temp) 3085 switch (temp)
2936 { 3086 {
2937 case Scharquote: 3087 case Scharquote:
2938 case Sescape: 3088 case Sescape:
2939 INC_FROM; 3089 INC_FROM;